@@ -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,8 +65,11 @@ func (c CommitmentType) HasStaticRemoteKey() bool {
5965 case CommitmentTypeTweakless ,
6066 CommitmentTypeAnchorsZeroFeeHtlcTx ,
6167 CommitmentTypeScriptEnforcedLease ,
62- CommitmentTypeSimpleTaproot :
68+ CommitmentTypeSimpleTaproot ,
69+ CommitmentTypeSimpleTaprootOverlay :
70+
6371 return true
72+
6473 default :
6574 return false
6675 }
@@ -71,16 +80,20 @@ func (c CommitmentType) HasAnchors() bool {
7180 switch c {
7281 case CommitmentTypeAnchorsZeroFeeHtlcTx ,
7382 CommitmentTypeScriptEnforcedLease ,
74- CommitmentTypeSimpleTaproot :
83+ CommitmentTypeSimpleTaproot ,
84+ CommitmentTypeSimpleTaprootOverlay :
85+
7586 return true
87+
7688 default :
7789 return false
7890 }
7991}
8092
8193// IsTaproot returns true if the channel type is a taproot channel.
8294func (c CommitmentType ) IsTaproot () bool {
83- return c == CommitmentTypeSimpleTaproot
95+ return c == CommitmentTypeSimpleTaproot ||
96+ c == CommitmentTypeSimpleTaprootOverlay
8497}
8598
8699// String returns the name of the CommitmentType.
@@ -96,6 +109,8 @@ func (c CommitmentType) String() string {
96109 return "script-enforced-lease"
97110 case CommitmentTypeSimpleTaproot :
98111 return "simple-taproot"
112+ case CommitmentTypeSimpleTaprootOverlay :
113+ return "simple-taproot-overlay"
99114 default :
100115 return "invalid"
101116 }
@@ -400,7 +415,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
400415 chanType |= channeldb .FrozenBit
401416 }
402417
403- if req .CommitType == CommitmentTypeSimpleTaproot {
418+ if req .CommitType . IsTaproot () {
404419 chanType |= channeldb .SimpleTaprootFeatureBit
405420 }
406421
@@ -416,7 +431,15 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
416431 chanType |= channeldb .ScidAliasFeatureBit
417432 }
418433
419- if req .TapscriptRoot .IsSome () {
434+ taprootOverlay := req .CommitType == CommitmentTypeSimpleTaprootOverlay
435+ switch {
436+ case taprootOverlay && req .TapscriptRoot .IsNone ():
437+ fallthrough
438+ case ! taprootOverlay && req .TapscriptRoot .IsSome ():
439+ return nil , fmt .Errorf ("taproot overlay chans must be set " +
440+ "with tapscript root" )
441+
442+ case taprootOverlay && req .TapscriptRoot .IsSome ():
420443 chanType |= channeldb .TapscriptRootBit
421444 }
422445
0 commit comments