Skip to content

Commit 9eec9b5

Browse files
authored
Merge pull request #8867 from lightningnetwork/custom-chans-feature-bit
multi: add taproot chans overlay feature bit
2 parents a3a50c3 + c748709 commit 9eec9b5

16 files changed

+593
-416
lines changed

feature/default_sets.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@ var defaultSetDesc = setDesc{
9292
SetInit: {}, // I
9393
SetNodeAnn: {}, // N
9494
},
95+
lnwire.SimpleTaprootOverlayChansOptional: {
96+
SetInit: {}, // I
97+
SetNodeAnn: {}, // N
98+
},
9599
}

feature/deps.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ var deps = depDesc{
8585
lnwire.RouteBlindingRequired: {
8686
lnwire.TLVOnionPayloadRequired: {},
8787
},
88+
lnwire.SimpleTaprootOverlayChansOptional: {
89+
lnwire.SimpleTaprootChannelsOptionalStaging: {},
90+
lnwire.TLVOnionPayloadOptional: {},
91+
lnwire.ScidAliasOptional: {},
92+
},
8893
}
8994

9095
// ValidateDeps asserts that a feature vector sets all features and their

feature/manager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ type Config struct {
6363
// NoRouteBlinding unsets route blinding feature bits.
6464
NoRouteBlinding bool
6565

66+
// NoTaprootOverlay unsets the taproot overlay channel feature bits.
67+
NoTaprootOverlay bool
68+
6669
// CustomFeatures is a set of custom features to advertise in each
6770
// set.
6871
CustomFeatures map[Set][]lnwire.FeatureBit
@@ -188,6 +191,10 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
188191
raw.Unset(lnwire.RouteBlindingOptional)
189192
raw.Unset(lnwire.RouteBlindingRequired)
190193
}
194+
if cfg.NoTaprootOverlay {
195+
raw.Unset(lnwire.SimpleTaprootOverlayChansOptional)
196+
raw.Unset(lnwire.SimpleTaprootOverlayChansRequired)
197+
}
191198
for _, custom := range cfg.CustomFeatures[set] {
192199
if custom > set.Maximum() {
193200
return nil, fmt.Errorf("feature bit: %v "+

funding/commitment_type_negotiation.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,74 @@ func explicitNegotiateCommitmentType(channelType lnwire.ChannelType, local,
307307

308308
return lnwallet.CommitmentTypeSimpleTaproot, nil
309309

310+
// Simple taproot channels overlay only.
311+
case channelFeatures.OnlyContains(
312+
lnwire.SimpleTaprootOverlayChansRequired,
313+
):
314+
315+
if !hasFeatures(
316+
local, remote,
317+
lnwire.SimpleTaprootOverlayChansOptional,
318+
) {
319+
320+
return 0, errUnsupportedChannelType
321+
}
322+
323+
return lnwallet.CommitmentTypeSimpleTaprootOverlay, nil
324+
325+
// Simple taproot overlay channels with scid only.
326+
case channelFeatures.OnlyContains(
327+
lnwire.SimpleTaprootOverlayChansRequired,
328+
lnwire.ScidAliasRequired,
329+
):
330+
331+
if !hasFeatures(
332+
local, remote,
333+
lnwire.SimpleTaprootOverlayChansOptional,
334+
lnwire.ScidAliasOptional,
335+
) {
336+
337+
return 0, errUnsupportedChannelType
338+
}
339+
340+
return lnwallet.CommitmentTypeSimpleTaprootOverlay, nil
341+
342+
// Simple taproot overlay channels with zero conf only.
343+
case channelFeatures.OnlyContains(
344+
lnwire.SimpleTaprootOverlayChansRequired,
345+
lnwire.ZeroConfRequired,
346+
):
347+
348+
if !hasFeatures(
349+
local, remote,
350+
lnwire.SimpleTaprootOverlayChansOptional,
351+
lnwire.ZeroConfOptional,
352+
) {
353+
354+
return 0, errUnsupportedChannelType
355+
}
356+
357+
return lnwallet.CommitmentTypeSimpleTaprootOverlay, nil
358+
359+
// Simple taproot overlay channels with scid and zero conf.
360+
case channelFeatures.OnlyContains(
361+
lnwire.SimpleTaprootOverlayChansRequired,
362+
lnwire.ZeroConfRequired,
363+
lnwire.ScidAliasRequired,
364+
):
365+
366+
if !hasFeatures(
367+
local, remote,
368+
lnwire.SimpleTaprootOverlayChansOptional,
369+
lnwire.ZeroConfOptional,
370+
lnwire.ScidAliasOptional,
371+
) {
372+
373+
return 0, errUnsupportedChannelType
374+
}
375+
376+
return lnwallet.CommitmentTypeSimpleTaprootOverlay, nil
377+
310378
// No features, use legacy commitment type.
311379
case channelFeatures.IsEmpty():
312380
return lnwallet.CommitmentTypeLegacy, nil

funding/manager_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4642,8 +4642,8 @@ func testZeroConf(t *testing.T, chanType *lnwire.ChannelType) {
46424642
// opening behavior with a specified fundmax flag. To give a hypothetical
46434643
// example, if ANCHOR types had been introduced after the fundmax flag had been
46444644
// activated, the developer would have had to code for the anchor reserve in the
4645-
// funding manager in the context of public and private channels. Otherwise
4646-
// inconsistent bahvior would have resulted when specifying fundmax for
4645+
// funding manager in the context of public and private channels. Otherwise,
4646+
// inconsistent behavior would have resulted when specifying fundmax for
46474647
// different types of channel openings.
46484648
// To ensure consistency this test compares a map of locally defined channel
46494649
// commitment types to the list of channel types that are defined in the proto
@@ -4659,6 +4659,7 @@ func TestCommitmentTypeFundmaxSanityCheck(t *testing.T) {
46594659
"ANCHORS": 3,
46604660
"SCRIPT_ENFORCED_LEASE": 4,
46614661
"SIMPLE_TAPROOT": 5,
4662+
"SIMPLE_TAPROOT_OVERLAY": 6,
46624663
}
46634664

46644665
for commitmentType := range lnrpc.CommitmentType_value {

lncfg/protocol.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ type ProtocolOptions struct {
3131
// experimental simple taproot chans commitment type.
3232
TaprootChans bool `long:"simple-taproot-chans" description:"if set, then lnd will create and accept requests for channels using the simple taproot commitment type"`
3333

34+
// TaprootOverlayChans should be set if we want to enable support for
35+
// the experimental taproot overlay chan type.
36+
TaprootOverlayChans bool `long:"simple-taproot-overlay-chans" description:"if set, then lnd will create and accept requests for channels using the taproot overlay commitment type"`
37+
3438
// NoAnchors should be set if we don't want to support opening or accepting
3539
// channels having the anchor commitment type.
3640
NoAnchors bool `long:"no-anchors" description:"disable support for anchor commitments"`

lncfg/protocol_integration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ type ProtocolOptions struct {
3333
// experimental simple taproot chans commitment type.
3434
TaprootChans bool `long:"simple-taproot-chans" description:"if set, then lnd will create and accept requests for channels using the simple taproot commitment type"`
3535

36+
// TaprootOverlayChans should be set if we want to enable support for
37+
// the experimental taproot overlay chan type.
38+
TaprootOverlayChans bool `long:"simple-taproot-overlay-chans" description:"if set, then lnd will create and accept requests for channels using the taproot overlay commitment type"`
39+
3640
// Anchors enables anchor commitments.
3741
// TODO(halseth): transition itests to anchors instead!
3842
Anchors bool `long:"anchors" description:"enable support for anchor commitments"`

0 commit comments

Comments
 (0)