@@ -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 }
@@ -424,7 +439,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
424439 chanType |= channeldb .FrozenBit
425440 }
426441
427- if req .CommitType == CommitmentTypeSimpleTaproot {
442+ if req .CommitType . IsTaproot () {
428443 chanType |= channeldb .SimpleTaprootFeatureBit
429444 }
430445
@@ -440,7 +455,15 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
440455 chanType |= channeldb .ScidAliasFeatureBit
441456 }
442457
443- if req .TapscriptRoot .IsSome () {
458+ taprootOverlay := req .CommitType == CommitmentTypeSimpleTaprootOverlay
459+ switch {
460+ case taprootOverlay && req .TapscriptRoot .IsNone ():
461+ fallthrough
462+ case ! taprootOverlay && req .TapscriptRoot .IsSome ():
463+ return nil , fmt .Errorf ("taproot overlay chans must be set " +
464+ "with tapscript root" )
465+
466+ case taprootOverlay && req .TapscriptRoot .IsSome ():
444467 chanType |= channeldb .TapscriptRootBit
445468 }
446469
0 commit comments