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

swaps: only set swap redeemed if preimage is available

Public commit record

What the developer wrote

Authored by f321x

73/100 · Adequate
swaps: only set swap redeemed if preimage is available

For forward swaps this will ensure that the swap only gets set redeemed
and cleaned up after the preimage has been extracted, as it could happen
that `current_height - spent_height > REDEEM_AFTER_DOUBLE_SPENT_DELAY`
is true even if the preimage has not been extracted yet.

For reverse swaps this changes nothing as they always have the preimage.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This change fixes a logic bug in Electrum's submarine swap handling. Previously, a forward swap could be marked as 'redeemed' and stop being watched before the secret payment proof (preimage) was actually extracted. Without the preimage, the wallet cannot claim the funds it is owed. The patch adds a check so the swap is only marked redeemed if the preimage is already known. This prevents premature cleanup that could strand funds or break swap accounting.

Recommended action

Review related swap lifecycle logic to ensure no other state transitions rely on spent_height without verifying preimage availability. Consider adding tests covering the forward-swap redemption path where the preimage is extracted from the spending transaction. Users running submarine swaps should upgrade to a version containing this fix.

Security signals we found

01

state-machine logic flaw

02

missing preimage validation before marking redemption

03

premature cleanup of watched swap

04

potential fund stranding in submarine swaps

Risk score

Why this scored 46/100

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