Skip to content

Commit f486644

Browse files
Roasbeefguggero
authored andcommitted
input: add some utility type definitions for aux leaves
In this commit, we add some useful type definitions for the aux leaf, and a helper function to cut down on some line noise.
1 parent c79648e commit f486644

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

input/taproot.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ func NoneTapLeaf() AuxTapLeaf {
3131
return fn.None[txscript.TapLeaf]()
3232
}
3333

34+
// HtlcIndex represents the monotonically increasing counter that is used to
35+
// identify HTLCs created a peer.
36+
type HtlcIndex = uint64
37+
38+
// HtlcAuxLeaf is a type that represents an auxiliary leaf for an HTLC output.
39+
// An HTLC may have up to two aux leaves: one for the output on the commitment
40+
// transaction, and one for the second level HTLC.
41+
type HtlcAuxLeaf struct {
42+
AuxTapLeaf
43+
44+
// SecondLevelLeaf is the auxiliary leaf for the second level HTLC
45+
// success or timeout transaction.
46+
SecondLevelLeaf AuxTapLeaf
47+
}
48+
49+
// AuxTapLeaves is a type alias for a slice of optional tapscript leaves.
50+
type AuxTapLeaves = map[HtlcIndex]HtlcAuxLeaf
51+
3452
// NewTxSigHashesV0Only returns a new txscript.TxSigHashes instance that will
3553
// only calculate the sighash midstate values for segwit v0 inputs and can
3654
// therefore never be used for transactions that want to spend segwit v1

0 commit comments

Comments
 (0)