input+lnwallet: update taproot scripts to accept optional aux leaf
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.
This commit is contained in:
1 parent
8588c9bfd7
commit
1aae47fd71
11 files changed
+273
-108
No files matched your search
@@ -6669,6 +6669,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
|
||||
//nolint:lll
|
||||
secondLevelScriptTree, err := input.TaprootSecondLevelScriptTree(
|
||||
keyRing.RevocationKey, keyRing.ToLocalKey, csvDelay,
|
||||
fn.None[txscript.TapLeaf](),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -6915,6 +6916,7 @@ func newIncomingHtlcResolution(signer input.Signer,
|
||||
//nolint:lll
|
||||
secondLevelScriptTree, err := input.TaprootSecondLevelScriptTree(
|
||||
keyRing.RevocationKey, keyRing.ToLocalKey, csvDelay,
|
||||
fn.None[txscript.TapLeaf](),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -225,9 +225,8 @@ func (w *WitnessScriptDesc) WitnessScriptForPath(
|
||||
// party learns of the preimage to the revocation hash, then they can claim all
|
||||
// the settled funds in the channel, plus the unsettled funds.
|
||||
func CommitScriptToSelf(chanType channeldb.ChannelType, initiator bool,
|
||||
selfKey, revokeKey *btcec.PublicKey, csvDelay, leaseExpiry uint32,
|
||||
) (
|
||||
input.ScriptDescriptor, error) {
|
||||
selfKey, revokeKey *btcec.PublicKey, csvDelay,
|
||||
leaseExpiry uint32) (input.ScriptDescriptor, error) {
|
||||
|
||||
switch {
|
||||
// For taproot scripts, we'll need to make a slightly modified script
|
||||
@@ -237,7 +236,7 @@ func CommitScriptToSelf(chanType channeldb.ChannelType, initiator bool,
|
||||
// Our "redeem" script here is just the taproot witness program.
|
||||
case chanType.IsTaproot():
|
||||
return input.NewLocalCommitScriptTree(
|
||||
csvDelay, selfKey, revokeKey,
|
||||
csvDelay, selfKey, revokeKey, input.NoneTapLeaf(),
|
||||
)
|
||||
|
||||
// If we are the initiator of a leased channel, then we have an
|
||||
@@ -321,7 +320,7 @@ func CommitScriptToRemote(chanType channeldb.ChannelType, initiator bool,
|
||||
// with the sole tap leaf enforcing the 1 CSV delay.
|
||||
case chanType.IsTaproot():
|
||||
toRemoteScriptTree, err := input.NewRemoteCommitScriptTree(
|
||||
remoteKey,
|
||||
remoteKey, input.NoneTapLeaf(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -427,7 +426,7 @@ func SecondLevelHtlcScript(chanType channeldb.ChannelType, initiator bool,
|
||||
// For taproot channels, the pkScript is a segwit v1 p2tr output.
|
||||
case chanType.IsTaproot():
|
||||
return input.TaprootSecondLevelScriptTree(
|
||||
revocationKey, delayKey, csvDelay,
|
||||
revocationKey, delayKey, csvDelay, input.NoneTapLeaf(),
|
||||
)
|
||||
|
||||
// If we are the initiator of a leased channel, then we have an
|
||||
@@ -1095,6 +1094,7 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
|
||||
htlcScriptTree, err = input.ReceiverHTLCScriptTaproot(
|
||||
timeout, keyRing.RemoteHtlcKey, keyRing.LocalHtlcKey,
|
||||
keyRing.RevocationKey, rHash[:], whoseCommit,
|
||||
input.NoneTapLeaf(),
|
||||
)
|
||||
|
||||
// We're being paid via an HTLC by the remote party, and the HTLC is
|
||||
@@ -1104,6 +1104,7 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
|
||||
htlcScriptTree, err = input.SenderHTLCScriptTaproot(
|
||||
keyRing.RemoteHtlcKey, keyRing.LocalHtlcKey,
|
||||
keyRing.RevocationKey, rHash[:], whoseCommit,
|
||||
input.NoneTapLeaf(),
|
||||
)
|
||||
|
||||
// We're sending an HTLC which is being added to our commitment
|
||||
@@ -1113,6 +1114,7 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
|
||||
htlcScriptTree, err = input.SenderHTLCScriptTaproot(
|
||||
keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
|
||||
keyRing.RevocationKey, rHash[:], whoseCommit,
|
||||
input.NoneTapLeaf(),
|
||||
)
|
||||
|
||||
// Finally, we're paying the remote party via an HTLC, which is being
|
||||
@@ -1122,6 +1124,7 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
|
||||
htlcScriptTree, err = input.ReceiverHTLCScriptTaproot(
|
||||
timeout, keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
|
||||
keyRing.RevocationKey, rHash[:], whoseCommit,
|
||||
input.NoneTapLeaf(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user