Skip to content

lnchannel: extract_preimage: fix len(witness) check - #10906

Open
f321x wants to merge 1 commit into
spesmilo:masterfrom
f321x:fix_lnchannel_preimage_extraction
Open

lnchannel: extract_preimage: fix len(witness) check #10906
f321x wants to merge 1 commit into
spesmilo:masterfrom
f321x:fix_lnchannel_preimage_extraction

Conversation

@f321x

@f321x f321x commented Aug 28, 2026

Copy link
Copy Markdown
Member

Channel.extract_preimage_from_htlc_txin() would incorrectly assume a htlc revocation spends revocationpubkey to be the preimage of the htlc and then fail at the comparison against the payment hash.
This happened because the preimage was selected solely based on the length of the spending txin witness which consists of 3 elements both for the preimage spend path and the revocation spend path.

This PR takes over @SomberNight's b0650f1 commit as fix and adds some additional commits.

@f321x f321x added the bug 🐞 label Aug 28, 2026
@f321x
f321x force-pushed the fix_lnchannel_preimage_extraction branch 5 times, most recently from 4c3f609 to 46b1938 Compare August 28, 2026 15:00
@f321x
f321x marked this pull request as ready for review August 28, 2026 15:20
@f321x

f321x commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

The security review CI finding is addressed by #10910

SomberNight added a commit to SomberNight/electrum that referenced this pull request Aug 28, 2026
@SomberNight

Copy link
Copy Markdown
Member

Thanks! Looks excellent. I merged all but the last commit, in d698389.
I ran out of time before really thinking about the last commit.

@f321x
f321x force-pushed the fix_lnchannel_preimage_extraction branch from 46b1938 to 835d6eb Compare August 31, 2026 09:19
Comment thread electrum/lnwatcher.py Outdated
keep_watching |= self._sweep_ctx_output(prevout, sweep_info, chan, closing_tx, is_local_ctx)
except Exception as e:
# in case a single sweep crashes we keep sweeping the other outputs
send_exception_to_crash_reporter(e) # logs too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove that; see my comment in the other PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in df8fd78

Catch exceptions occuring during the sweep of a single
ctx output and keep going sweeping the other outputs so
we sweep at least those that do not crash and don't leave
them on the table.
@f321x
f321x force-pushed the fix_lnchannel_preimage_extraction branch from 835d6eb to df8fd78 Compare August 31, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants