@@ -247,6 +247,10 @@ type chanAuxData struct {
247247 // memo is an optional text field that gives context to the user about
248248 // the channel.
249249 memo tlv.OptionalRecordT [tlv.TlvType5 , []byte ]
250+
251+ // tapscriptRoot is the optional Tapscript root the channel funding
252+ // output commits to.
253+ tapscriptRoot tlv.OptionalRecordT [tlv.TlvType6 , [32 ]byte ]
250254}
251255
252256// encode serializes the chanAuxData to the given io.Writer.
@@ -260,6 +264,11 @@ func (c *chanAuxData) encode(w io.Writer) error {
260264 c .memo .WhenSome (func (memo tlv.RecordT [tlv.TlvType5 , []byte ]) {
261265 tlvRecords = append (tlvRecords , memo .Record ())
262266 })
267+ c .tapscriptRoot .WhenSome (
268+ func (root tlv.RecordT [tlv.TlvType6 , [32 ]byte ]) {
269+ tlvRecords = append (tlvRecords , root .Record ())
270+ },
271+ )
263272
264273 // Create the tlv stream.
265274 tlvStream , err := tlv .NewStream (tlvRecords ... )
@@ -273,6 +282,7 @@ func (c *chanAuxData) encode(w io.Writer) error {
273282// decode deserializes the chanAuxData from the given io.Reader.
274283func (c * chanAuxData ) decode (r io.Reader ) error {
275284 memo := c .memo .Zero ()
285+ tapscriptRoot := c .tapscriptRoot .Zero ()
276286
277287 // Create the tlv stream.
278288 tlvStream , err := tlv .NewStream (
@@ -281,6 +291,7 @@ func (c *chanAuxData) decode(r io.Reader) error {
281291 c .initialRemoteBalance .Record (),
282292 c .realScid .Record (),
283293 memo .Record (),
294+ tapscriptRoot .Record (),
284295 )
285296 if err != nil {
286297 return err
@@ -294,6 +305,9 @@ func (c *chanAuxData) decode(r io.Reader) error {
294305 if _ , ok := tlvs [memo .TlvType ()]; ok {
295306 c .memo = tlv .SomeRecordT (memo )
296307 }
308+ if _ , ok := tlvs [tapscriptRoot .TlvType ()]; ok {
309+ c .tapscriptRoot = tlv .SomeRecordT (tapscriptRoot )
310+ }
297311
298312 return nil
299313}
@@ -308,6 +322,9 @@ func (c *chanAuxData) toOpenChan(o *OpenChannel) {
308322 c .memo .WhenSomeV (func (memo []byte ) {
309323 o .Memo = memo
310324 })
325+ c .tapscriptRoot .WhenSomeV (func (h [32 ]byte ) {
326+ o .TapscriptRoot = fn.Some [chainhash.Hash ](h )
327+ })
311328}
312329
313330// newChanAuxDataFromChan creates a new chanAuxData from the given channel.
@@ -332,6 +349,11 @@ func newChanAuxDataFromChan(openChan *OpenChannel) *chanAuxData {
332349 tlv.NewPrimitiveRecord [tlv.TlvType5 ](openChan .Memo ),
333350 )
334351 }
352+ openChan .TapscriptRoot .WhenSome (func (h chainhash.Hash ) {
353+ c .tapscriptRoot = tlv .SomeRecordT (
354+ tlv.NewPrimitiveRecord [tlv.TlvType6 , [32 ]byte ](h ),
355+ )
356+ })
335357
336358 return c
337359}
@@ -413,6 +435,11 @@ const (
413435 // SimpleTaprootFeatureBit indicates that the simple-taproot-chans
414436 // feature bit was negotiated during the lifetime of the channel.
415437 SimpleTaprootFeatureBit ChannelType = 1 << 10
438+
439+ // TapscriptRootBit indicates that this is a MuSig2 channel with a top
440+ // level tapscript commitment. This MUST be set along with the
441+ // SimpleTaprootFeatureBit.
442+ TapscriptRootBit ChannelType = 1 << 11
416443)
417444
418445// IsSingleFunder returns true if the channel type if one of the known single
@@ -483,6 +510,12 @@ func (c ChannelType) IsTaproot() bool {
483510 return c & SimpleTaprootFeatureBit == SimpleTaprootFeatureBit
484511}
485512
513+ // HasTapscriptRoot returns true if the channel is using a top level tapscript
514+ // root commitment.
515+ func (c ChannelType ) HasTapscriptRoot () bool {
516+ return c & TapscriptRootBit == TapscriptRootBit
517+ }
518+
486519// ChannelConstraints represents a set of constraints meant to allow a node to
487520// limit their exposure, enact flow control and ensure that all HTLCs are
488521// economically relevant. This struct will be mirrored for both sides of the
0 commit comments