@@ -2,6 +2,7 @@ package lnwallet
22
33import (
44 "errors"
5+ "fmt"
56 "net"
67 "sync"
78
@@ -50,6 +51,11 @@ const (
5051 // channels that use a musig2 funding output and the tapscript tree
5152 // where relevant for the commitment transaction pk scripts.
5253 CommitmentTypeSimpleTaproot
54+
55+ // CommitmentTypeSimpleTaprootOverlay builds on the existing
56+ // CommitmentTypeSimpleTaproot type but layers on a special overlay
57+ // protocol.
58+ CommitmentTypeSimpleTaprootOverlay
5359)
5460
5561// HasStaticRemoteKey returns whether the commitment type supports remote
@@ -59,6 +65,7 @@ func (c CommitmentType) HasStaticRemoteKey() bool {
5965 case CommitmentTypeTweakless ,
6066 CommitmentTypeAnchorsZeroFeeHtlcTx ,
6167 CommitmentTypeScriptEnforcedLease ,
68+ CommitmentTypeSimpleTaprootOverlay ,
6269 CommitmentTypeSimpleTaproot :
6370 return true
6471 default :
@@ -71,6 +78,7 @@ func (c CommitmentType) HasAnchors() bool {
7178 switch c {
7279 case CommitmentTypeAnchorsZeroFeeHtlcTx ,
7380 CommitmentTypeScriptEnforcedLease ,
81+ CommitmentTypeSimpleTaprootOverlay ,
7482 CommitmentTypeSimpleTaproot :
7583 return true
7684 default :
@@ -80,7 +88,8 @@ func (c CommitmentType) HasAnchors() bool {
8088
8189// IsTaproot returns true if the channel type is a taproot channel.
8290func (c CommitmentType ) IsTaproot () bool {
83- return c == CommitmentTypeSimpleTaproot
91+ return c == CommitmentTypeSimpleTaproot ||
92+ c == CommitmentTypeSimpleTaprootOverlay
8493}
8594
8695// String returns the name of the CommitmentType.
@@ -96,6 +105,8 @@ func (c CommitmentType) String() string {
96105 return "script-enforced-lease"
97106 case CommitmentTypeSimpleTaproot :
98107 return "simple-taproot"
108+ case CommitmentTypeSimpleTaprootOverlay :
109+ return "simple-taproot-overlay"
99110 default :
100111 return "invalid"
101112 }
@@ -400,7 +411,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
400411 chanType |= channeldb .FrozenBit
401412 }
402413
403- if req .CommitType == CommitmentTypeSimpleTaproot {
414+ if req .CommitType . IsTaproot () {
404415 chanType |= channeldb .SimpleTaprootFeatureBit
405416 }
406417
@@ -416,7 +427,15 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
416427 chanType |= channeldb .ScidAliasFeatureBit
417428 }
418429
419- if req .TapscriptRoot .IsSome () {
430+ taprootOverlay := req .CommitType == CommitmentTypeSimpleTaprootOverlay
431+ switch {
432+ case taprootOverlay && req .TapscriptRoot .IsNone ():
433+ fallthrough
434+ case ! taprootOverlay && req .TapscriptRoot .IsSome ():
435+ return nil , fmt .Errorf ("taproot overlay chans must be set " +
436+ "with tapscript root" )
437+
438+ case taprootOverlay && req .TapscriptRoot .IsSome ():
420439 chanType |= channeldb .TapscriptRootBit
421440 }
422441
0 commit comments