AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 37 Bitcoin

ln: fix race when doing concurrent ln payments

Public commit record

What the developer wrote

Authored by f321x

68/100 · Adequate
ln: fix race when doing concurrent ln payments

There is a race when initiating multiple lightning payments concurrently
(e.g. when doing a reverse swap with prepayment + swap payment).
suggest_splits might overallocate
split amounts for a channel as the splitting of both invoice amounts runs
concurrently and before acutal htlcs that reduce the channels balance
have been added to the channel yet. This results in a "not
enough balance" PaymentFailure once we try to send the htlcs and the
other payment attempt already reduced the available balance of the
channel.

This fix takes a lock from splitting the amount until the htlcs are
put on the channel, so suggest_splits always acts on the correct channel
balance.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a timing bug in Electrum's Lightning payments. If a user started multiple Lightning payments at the same time, the wallet could plan routes using outdated channel balances, promising more money than was actually available. When the payments were then sent, one would fail with a 'not enough balance' error. The fix adds a lock so that balance checks and route creation happen one payment at a time, preventing the stale-balance problem.

Recommended action

No immediate security response required; this is a reliability/DoS-avoidance fix. Users running concurrent Lightning payments should update to the patched version to avoid spurious payment failures. Reviewers may want to confirm the lock is held for the minimal necessary duration and does not introduce deadlocks with other locks in the Lightning path.

Security signals we found

01

Race condition in concurrent Lightning payment handling

02

Potential payment failure due to stale channel balance reads

03

Addition of asyncio.Lock to serialize balance-sensitive split/route creation

04

Fix explicitly described as preventing 'not enough balance' PaymentFailure

Risk score

Why this scored 37/100

Our methodology →
Potential impact 8/30
Exploitability 4/25
Stealth signal 6/15
Affected reach 7/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.