Skip to content

Conversation

@ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Oct 30, 2025

We also log the amounts to the user so they know whether it is worth taking the risk publishing a potential outdated transaction.

@guggero guggero requested review from Copilot and guggero October 31, 2025 15:22
Copy link

Copilot AI left a 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.

Copy link
Contributor

@starius starius left a 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!

Comment on lines +347 to +374
case chanbackup.AnchorsCommitVersion:
chanType = channeldb.AnchorOutputsBit
chanType |= channeldb.SingleFunderTweaklessBit

case chanbackup.AnchorsZeroFeeHtlcTxCommitVersion:
chanType = channeldb.ZeroHtlcTxFeeBit
chanType |= channeldb.AnchorOutputsBit
chanType |= channeldb.SingleFunderTweaklessBit
Copy link
Contributor

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.

Copy link
Collaborator Author

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 ?

@ziggie1984 ziggie1984 force-pushed the show-local-amount branch 3 times, most recently from 099ca6c to b896dfb Compare November 2, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants