Repository navigation
Conversation
Allow callers to derive one public commitment point without printing the shaseed or any per-commitment secrets. Co-authored-by: Cursor <cursoragent@cursor.com>
Move the historical channel-seed calculation into common/hsm_secret and reuse it from hsmd, checkchannels and lightning-hsmtool. Co-authored-by: Cursor <cursoragent@cursor.com>
The recovery tool is long, so it is best kept in its own file. Expose load_hsm_secret in a header so it can be shared with the recovery tool. Co-authored-by: Cursor <cursoragent@cursor.com>
Derive the channel basepoints and commitment-specific keys needed to recover HTLC outputs without contacting lightningd or hsmd. Co-authored-by: Cursor <cursoragent@cursor.com>
Build offered and received HTLC scripts for the peer’s commitment, including anchor channels and CLTV expiry. Co-authored-by: Cursor <cursoragent@cursor.com>
Match reconstructed P2WSH scripts against commitment outputs and retain every matching index so identical MPP parts can be recovered together. Co-authored-by: Cursor <cursoragent@cursor.com>
Build both anchor variants of the requested HTLC script and use the commitment transaction to determine which one contains the outputs. Co-authored-by: Cursor <cursoragent@cursor.com>
Build a single transaction spending every matched HTLC output and sign each input with the appropriate timeout or preimage witness. Co-authored-by: Cursor <cursoragent@cursor.com>
Sum the matched HTLC outputs and calculate the fee and destination amount from the estimated signed transaction weight. Co-authored-by: Cursor <cursoragent@cursor.com>
Read versioned recovery data from JSON so the command line only needs operational inputs such as the destination and fee rate. Co-authored-by: Cursor <cursoragent@cursor.com>
Read a recovery bundle, validate its external inputs, and print signed transactions for each matching HTLC claim. Co-authored-by: Cursor <cursoragent@cursor.com>
Show the recovered inputs, output amount, fee, transaction ID, and verification and broadcast instructions. Co-authored-by: Cursor <cursoragent@cursor.com>
Reproduce stale channel state with pending HTLCs and prove recoverhtlc signs broadcastable anchor and non-anchor spends. Cover identical MPP outputs, same-hash opposite directions, strict JSON validation, and skipped unmatched claims. Co-authored-by: Cursor <cursoragent@cursor.com>
Document the recovery bundle, where each input comes from, the point-only peer workflow, transaction timing, and operator verification steps. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue
This came out of #9200.
When we have lost channel state, the peer may close with a commitment transaction we have never seen. We can recover our main output, but we cannot recognise the HTLC outputs because we no longer have the peer's per-commitment point or the HTLC information.
This adds:
lightning-hsmtool recoverhtlc <bundle.json> <hsm_secret>
The bundle contains the commitment transaction, channel information and the HTLCs we want to recover. The tool rebuilds the HTLC scripts and checks that they actually match outputs in the commitment transaction before signing anything.
It supports:
If one HTLC was trimmed or does not match, we skip it and continue with the others.
This prints one public commitment point without exposing the shaseed or any commitment secrets, so a cooperative peer can safely give us what we need.
This is not general recovery from only an
hsm_secret. We still need the channel information, HTLC details, commitment transaction and help from the peer. It is intended for cases like #9200, where that information can still be recovered.The channel-seed derivation is moved into
common/hsm_secretso hsmd and the recovery tools all use the same implementation.Limitations
This is not recovery from
hsm_secretalone. The operator still needs the peer ID, channel DBID, peer HTLC basepoint, commitment transaction, HTLC details, and the peer's per-commitment point.