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

lnworker: split dont_settle_htlcs

Public commit record

What the developer wrote

Authored by f321x

58/100 · Thin
lnworker: split dont_settle_htlcs

Splits `LNWallet.dont_settle_htlcs` into `LNWallet.dont_settle_htlcs`
and `LNWallet.dont_expire_htlcs`.

Registering a payment hash in dont_settle_htlcs will prevent it from
getting fulfilled if we have the preimage stored. The preimage will not
be released before the the payment hash gets removed from
dont_settle_htlcs. Htlcs can still get expired as usual or failed if no
preimage is known.
This is only used by Just-in-time channel openings.

Registering a payment hash in dont_expire_htlcs allows to overwrite the
minimum final cltv delta value after which htlcs would usually get
expired. This allows to delay expiry of htlcs or, if the value in the
dont_settle_htlcs dict is None, completely prevent expiry and let the
htlc get expired onchain.

Splitting this up in two different dicts makes it more explicit and
easier to reason about what they are actually doing.

Please enter the commit message for your changes. Lines starting
✓ Descriptive subject✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit refactors how Electrum handles special Lightning payment hashes used for 'hold invoices' and 'just-in-time channel openings.' It splits one internal control list into two separate lists: one that prevents automatic settlement (releasing the secret that completes a payment) and one that prevents automatic expiry of pending payments. The change is described by the author as making the code easier to reason about and safer, but it also alters the timing rules for when pending payments can be cancelled. There is no direct evidence in the commit that this fixes a known exploitable bug, but the change touches security-sensitive payment logic.

Recommended action

Treat as a defensive refactor of Lightning HTLC lifecycle logic. Reviewers should verify that hold invoices cannot be settled automatically before explicit settlement, that cancellation properly removes entries from both dicts and fails HTLCs, and that JIT channel opening's use of dont_settle_htlcs does not create a window where an HTLC can expire while preimage is withheld. No immediate patch deployment is indicated solely from this commit, but it should be included in the next release.

Security signals we found

01

Refactor of security-sensitive HTLC settlement/expiry controls

02

New safety comment warning about preimage release near expiry and fee races

03

Explicit split between withholding preimage and delaying expiry

04

Hold invoice behavior changed: no longer registered in dont_settle_htlcs, instead in dont_expire_htlcs

05

JIT channel opening mentioned as consumer of dont_settle_htlcs

06

Added assertions in lnpeer.py around dict membership and cleanup

Risk score

Why this scored 32/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 4/15
Affected reach 6/15
Confidence 6/10
Evidence quality 3/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.