-
Notifications
You must be signed in to change notification settings - Fork 2.2k
input+lnwallet: update taproot scripts to accept optional aux leaf #8556
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
Conversation
In this commit, we update all the taproot scripts to also accept an optional aux leaf. This aux leaf can be used to add more redemption paths for advanced channels, or just as an extra commitment space.
|
Important Auto Review SkippedAuto reviews are limited to the following labels: llm-review. Please add one of these labels to enable auto reviews. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
| // HTLC script tree with new spend paths, or just as extra commitment | ||
| // space. When present, this leaf will always be in the left-most or | ||
| // right-most area of the tapscript tree. | ||
| AuxLeaf fn.Option[txscript.TapLeaf] |
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.
in order to be open-ended with regards to flexibility, couldn't we have multiple aux leaves here? something like fn.Slice
we could hide everything under a single AuxLeaf but I think just having multiple leaves will keep it simpler overall on the script level itself
guggero
left a comment
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.
Very nice, super small diff for what we get out of it. It's obvious a lot of thought already went into this while refactoring for the Simple Taproot Channels 💯
| } | ||
|
|
||
| tapLeaves := []txscript.TapLeaf{successTapLeaf, timeoutTapLeaf} | ||
| auxLeaf.WhenSome(func(l txscript.TapLeaf) { |
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.
Is it worth noting here that if there is an odd number of leaves, then the last one will always end up being a level higher than the other leaves. Which in our case works out to exactly what we want, with just three leaves. But the assumptions here (with using AssembleTaprootScriptTree) would break down for let's say 5 leaves.
Then again, we never have more than 3 leaves in any LN use cases, so maybe not worth spending more time on.
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.
Yeah this is a somewhat specific cut out that should work for our use case until there's some drastic overhaul of taproot chans.
| func senderHtlcTapScriptTree(senderHtlcKey, receiverHtlcKey, | ||
| revokeKey *btcec.PublicKey, payHash []byte, | ||
| hType htlcType) (*HtlcScriptTree, error) { | ||
| hType htlcType, |
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.
micro-nit: looks like hType could fit on previous line.
| // commitment space. When present, this leaf will always be in the | ||
| // left-most or right-most area of the tapscript tree. | ||
| // | ||
| // TODO(roasbeeF): need to ensure commitment position... |
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.
Is this TODO related to my comment above? About relying on the logic in txscript.AssembleTaprootScriptTree?
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.
Yep, but as it it works since here we have it be that odd element out, which'll give it the top right position in the tree.
|
|
||
| script, _ := input.NewLocalCommitScriptTree( | ||
| csvDelay, delay, rev, | ||
| csvDelay, delay, rev, fn.None[txscript.TapLeaf](), |
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.
We need similar changes in other watchtower related code, see linter failures.
|
@GeorgeTsagk: review reminder |
|
The single commit of this PR is included in #8684. |
In this commit, we update all the taproot scripts to also accept an optional aux leaf. This aux leaf can be used to add more redemption paths for advanced channels, or just as an extra commitment space. All the
input/taproot_test.gohave also been updated to ensure that the new slightly larger control blocks are always properly generated.