Skip to content

A finishing LDK send clears another in-flight send of the same invoice #2011

Done

Description

@jvsena42

Problem

LightningRepo.ldkSendsInFlight is a set of send keys (ConcurrentHashMap.newKeySet). admitSend lets repeat node (LDK) sends of the same key through, so two node sends of one invoice can be in flight together. When either one returns, payInvoiceWithLdk runs ldkSendsInFlight -= key, which also clears the flag the other, still queued, send relies on.

How it can pay twice

  1. Two node sends of the same invoice are in flight. Send A fails or is stopped before submission; send B is still queued on the LDK service queue and the node does not list it yet.
  2. A finishes and removes the key from ldkSendsInFlight.
  3. A Spark attempt of the invoice runs earlierNodeSend. The node lists no payment for the hash and isRetried is false (the key is no longer in flight, and B recorded before this attempt's mark), so it calls removeLdkSendHash(key). Spark admission is still refused while B holds admittedSends.
  4. B is submitted and pays. Its hash is not saved again.
  5. Later, while the node cannot list payments (stopped, restarting, or after an app restart before it starts), a Spark attempt of the same invoice finds no kept hash and pays it a second time.

It needs two concurrent node sends of one invoice, so it is rare.

Suggested fix

Count in-flight node sends per key instead of keeping a set, or treat a key that admittedSends still holds as retried in earlierNodeSend.

Found while reviewing #1883. The set exists on master and that PR does not change it.

Activity

  1. self-assigned this
    on Nov 24, 2026
  2. added this to the 3.2.0 milestone on Nov 24, 2026
  3. ovitrif commented on Nov 24, 2026

    @ovitrif
    Collaborator

    In 3.2.0: it can pay an invoice twice across the node and Spark send paths that 3.2.0 ships, so it is fixed before the release.

  4. self-assigned this
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions