Classify outputs and amounts for SCBForceCloseChannel#216
Classify outputs and amounts for SCBForceCloseChannel#216guggero merged 2 commits intolightninglabs:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds output classification functionality to the scbforceclose command, which helps users identify different types of outputs (to_remote, anchors, to_local/htlc) in force-close transactions derived from static channel backups (SCBs).
- Adds logic to classify transaction outputs by matching against known script templates
- Maps SCB backup versions to channel types for proper script derivation
- Includes a test with real-world transaction data to verify the classification logic
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/chantools/scbforceclose.go | Adds classifyOutputs, classifyAndLogOutputs, and chanTypeFromBackupVersion functions to identify and log different output types in force-close transactions |
| cmd/chantools/scbforceclose_test.go | Adds test case with real-world data to verify to_remote output identification across different channel versions and initiator roles |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
starius
left a comment
There was a problem hiding this comment.
LGTM! 💾
The code looks correct, but needs some shaving.
I tested the binary with my real backup and it works correctly.
Thanks for this improvement!
| case chanbackup.AnchorsCommitVersion: | ||
| chanType = channeldb.AnchorOutputsBit | ||
| chanType |= channeldb.SingleFunderTweaklessBit | ||
|
|
||
| case chanbackup.AnchorsZeroFeeHtlcTxCommitVersion: | ||
| chanType = channeldb.ZeroHtlcTxFeeBit | ||
| chanType |= channeldb.AnchorOutputsBit | ||
| chanType |= channeldb.SingleFunderTweaklessBit |
There was a problem hiding this comment.
Idea, if you like it:
case chanbackup.AnchorsCommitVersion:
chanType = channeldb.AnchorOutputsBit
chanType |= channeldb.SingleFunderTweaklessBit
fallthrough
case chanbackup.AnchorsZeroFeeHtlcTxCommitVersion:
chanType |= channeldb.ZeroHtlcTxFeeBit
Also SimpleTaprootVersion and SimpleTaprootVersion can be coupled.
There was a problem hiding this comment.
are you sure they can be couple because the version check for every backup version is different ?
For AnchorsZeroFeeHtlcTxCommitVersion we won't enter the AnchorsCommitVersion case or don't I understand your proposal here ?
b896dfb to
e42b598
Compare
e42b598 to
51b4cf3
Compare
guggero
left a comment
There was a problem hiding this comment.
Thanks a lot, this is great!
I added a --channel_point flag that allows to force close a single channel when specifying a multi backup file.
Also added an integration test for the command.
51b4cf3 to
0c4693c
Compare
We also log the amounts to the user so they know whether it is worth taking the risk publishing a potential outdated transaction.