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:
Olaoluwa Osuntokun
2024-03-15 11:43:21 -04:00
committed by Oliver Gugger
parent 8588c9bfd7
commit 1aae47fd71
11 changed files with 273 additions and 108 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/lightningnetwork/lnd/fn"
)
const (
@@ -21,6 +22,15 @@ const (
PubKeyFormatCompressedOdd byte = 0x03
)
// AuxTapLeaf is a type alias for an optional tapscript leaf that may be added
// to the tapscript tree of HTLC and commitment outputs.
type AuxTapLeaf = fn.Option[txscript.TapLeaf]
// NoneTapLeaf returns an empty optional tapscript leaf.
func NoneTapLeaf() AuxTapLeaf {
return fn.None[txscript.TapLeaf]()
}
// NewTxSigHashesV0Only returns a new txscript.TxSigHashes instance that will
// only calculate the sighash midstate values for segwit v0 inputs and can
// therefore never be used for transactions that want to spend segwit v1