-
Notifications
You must be signed in to change notification settings - Fork 123
multi: changes to the taproot HTLC required for both client and server #477
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
274ec4c to
36da078
Compare
b332b53 to
61f729c
Compare
b947b1c to
fe94c3b
Compare
3583191 to
f4b2395
Compare
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.
Great cleanup and refactors! Only a few minor comments, nothing major.
872f647 to
b406ff9
Compare
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.
Awesome, LGTM 🎉
|
@arshbot ping |
carlaKC
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.
Nice refactor!
| var schnorrSenderKey, schnorrReceiverKey [32]byte | ||
| copy(schnorrSenderKey[:], schnorr.SerializePubKey(senderPubKey)) | ||
| copy(schnorrReceiverKey[:], schnorr.SerializePubKey(receiverPubKey)) | ||
| aggregateKey, _, _, err := musig2.AggregateKeys( |
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.
nice, much cleaner than passing it all the way through everywhere 🤦♀️
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.
Keys.. Keys everywhere...
sweep/sweeper.go
Outdated
| } | ||
|
|
||
| // We need our previous outputs for taproot spends, and there's no | ||
| // harm including them for segwit v0, so we always inlucde our prevOut. |
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.
s/inlucde/include
This is definitely my typo, I can feel it :')
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.
fixed
Use of the Script() function is problematic when we introduce taproot because our script will vary depending whether we use keyspend or a tapleaf spend path (and on the tapleaf spent). This has not previously been a problem for segwitv0 scripts, because they contain all of the logical branches for each of our spend conditions in a single script. This commit prepares for removal of the Script() function by moving our address/pkScript/sigScript generation (which need Script()) into each script's implementation of the HtlcScript interface so that they have access to the script directly.
Taproot spends require a different sighash, so we update our HtlcScript interface to provide the appropriate sighash when sweeping. We also add distinct Timeout/Success Script functions to allow for tapleaf spends which have different locking scripts for different paths. Note that the timeout and success paths will be the same for segwit v0 htlcs, because it has a single branched script containing all spend paths. In future iterations, this differentiation of claim scripts can also be used to use musig2 to collaboratively keyspend P2TR htlcs with the server. This script can be expressed as PriorityScript (because we'll try to keyspend as a priority, and then fall back to a tap leaf spend). As we've done here, segwit v0 spends would just return their single script for PriorityScript, and the claim would be no different from our other claims.
Thanks for the review, welcome back :) |
Came for the nits, stayed for the musig2 😜 |
arshbot
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.
LGTM! I really like this approach of abstracting away the output type logic so each type can figure out how to come up with the needed assets. Gives the right amount of flexibility because each htlc type conforms to lockingConditions, but doesn't commit to a path
| } | ||
|
|
||
| // Script is not implemented, but necessary to conform to interface. | ||
| func (h *HtlcScriptV3) Script() []byte { |
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.
This is certainly a much cleaner way of going about it
This PR adds a few changes to the already existing taproot HTLC code to make it simpler to integrate.