You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A finishing LDK send clears another in-flight send of the same invoice #2011
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
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.
A finishes and removes the key from ldkSendsInFlight.
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.
B is submitted and pays. Its hash is not saved again.
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
ovitrif commentedon Nov 24, 2026
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.