input: add some utility type definitions for aux leaves

In this commit, we add some useful type definitions for the aux leaf.
This commit is contained in:
Olaoluwa Osuntokun 2024-04-01 19:52:21 -07:00 committed by Oliver Gugger
parent 12acbac16a
commit fc44ff4bff
No known key found for this signature in database
GPG key ID: 8E4256593F177720

View file

@ -31,6 +31,24 @@ func NoneTapLeaf() AuxTapLeaf {
return fn.None[txscript.TapLeaf]()
}
// HtlcIndex represents the monotonically increasing counter that is used to
// identify HTLCs created a peer.
type HtlcIndex = uint64
// HtlcAuxLeaf is a type that represents an auxiliary leaf for an HTLC output.
// An HTLC may have up to two aux leaves: one for the output on the commitment
// transaction, and one for the second level HTLC.
type HtlcAuxLeaf struct {
AuxTapLeaf
// SecondLevelLeaf is the auxiliary leaf for the second level HTLC
// success or timeout transaction.
SecondLevelLeaf AuxTapLeaf
}
// AuxTapLeaves is a type alias for a slice of optional tapscript leaves.
type AuxTapLeaves = map[HtlcIndex]HtlcAuxLeaf
// 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