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

lnutil: change ReceivedMPPStatus.htlcs to frozenset, i.e. immutable

Public commit record

What the developer wrote

Authored by SomberNight

81/100 · Strong
lnutil: change ReceivedMPPStatus.htlcs to frozenset, i.e. immutable

As ThomasV says:

> ReceivedMPPStatus is a Namedtuple, which is immutable, but it contains
> a mutable field. Since ReceivedMPPStatus is not a StoredObject,
> no patch will be created when the htlcs list is modified, and we may
> end up not saving the change to disk if partial writes are enabled.

patch taken from https://github.com/spesmilo/electrum/pull/10395#pullrequestreview-3634244541
closes https://github.com/spesmilo/electrum/pull/10395

Co-authored-by: f321x <f@f321x.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a data-integrity bug in Electrum's Lightning payment handling. A particular data structure was supposed to be immutable, but it secretly contained a mutable list. When the list changed, Electrum's storage system did not notice, so the change might not be saved to disk—especially when partial writes are enabled. That could leave the wallet's record of incoming Lightning payments inconsistent after a restart or crash, potentially causing funds to appear stuck or payments to be mishandled. The fix makes the list truly immutable and updates the code to create new copies whenever it changes, so the storage layer reliably saves the state.

Recommended action

Apply the patch. It is a defensive correctness fix for Lightning state persistence. Users running Lightning nodes, especially with partial writes enabled, should upgrade. No immediate emergency response is indicated, but verify backups and wallet state after updating.

Security signals we found

01

Mutable field inside an immutable NamedTuple bypasses storage change detection

02

Potential state inconsistency for received multi-path Lightning payments after crash or restart

03

Partial-write mode increases risk of unsaved mutations

04

Type mismatch fix: payment_hash.hex() used instead of raw bytes for set membership check

05

Patch converts all in-place set mutations to immutable frozenset replacements

Risk score

Why this scored 55/100

Our methodology →
Potential impact 18/30
Exploitability 8/25
Stealth signal 10/15
Affected reach 8/15
Confidence 7/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.