-
Notifications
You must be signed in to change notification settings - Fork 41
Classify outputs and amounts for SCBForceCloseChannel #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ?
099ca6c to
b896dfb
Compare
b896dfb to
e42b598
Compare
We also log the amounts to the user so they know whether it is worth taking the risk publishing a potential outdated transaction.