From fc44ff4bffe7b346f0dc95f93e818b38e3c25d8d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 1 Apr 2024 19:52:21 -0700 Subject: [PATCH] input: add some utility type definitions for aux leaves In this commit, we add some useful type definitions for the aux leaf. --- input/taproot.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/input/taproot.go b/input/taproot.go index 0fcd1df4e..6edaf5de6 100644 --- a/input/taproot.go +++ b/input/taproot.go @@ -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