From d0779e2ec2d51fd22ef3d463abaf990f322586f9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 3 Mar 2021 19:39:12 -0800 Subject: [PATCH] lnwire: add new feature bits for explicit channel type negotiation If these bits are present, then both sides can examine the new CommitmentType TLV field that's present and use this in place of the existing implicit commiment type negotiation. With this change, it's now possible to actually deprecate old unsupported commitment types properly. --- feature/default_sets.go | 4 ++++ feature/deps.go | 4 ++++ lnwire/features.go | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/feature/default_sets.go b/feature/default_sets.go index 9103f903..5ee98792 100644 --- a/feature/default_sets.go +++ b/feature/default_sets.go @@ -60,4 +60,8 @@ var defaultSetDesc = setDesc{ lnwire.AMPRequired: { SetInvoiceAmp: {}, // 9A }, + lnwire.ExplicitChannelTypeOptional: { + SetInit: {}, // I + SetNodeAnn: {}, // N + }, } diff --git a/feature/deps.go b/feature/deps.go index 51ee37e9..d6f57cb9 100644 --- a/feature/deps.go +++ b/feature/deps.go @@ -58,9 +58,13 @@ var deps = depDesc{ lnwire.AnchorsOptional: { lnwire.StaticRemoteKeyOptional: {}, }, + lnwire.AnchorsZeroFeeHtlcTxOptional: { + lnwire.StaticRemoteKeyOptional: {}, + }, lnwire.AMPOptional: { lnwire.PaymentAddrOptional: {}, }, + lnwire.ExplicitChannelTypeOptional: {}, } // ValidateDeps asserts that a feature vector sets all features and their diff --git a/lnwire/features.go b/lnwire/features.go index 675ba0f5..70aa2315 100644 --- a/lnwire/features.go +++ b/lnwire/features.go @@ -139,6 +139,26 @@ const ( // sender-generated preimages according to BOLT XX. AMPOptional FeatureBit = 31 + // ExplicitChannelTypeRequired is a required bit that denotes that a + // connection established with this node is to use explicit channel + // commitment types for negotiation instead of the existing implicit + // negotiation methods. With this bit, there is no longer a "default" + // implicit channel commitment type, allowing a connection to + // open/maintain types of several channels over its lifetime. + // + // TODO: Decide on actual feature bit value. + ExplicitChannelTypeRequired = 2020 + + // ExplicitChannelTypeOptional is an optional bit that denotes that a + // connection established with this node is to use explicit channel + // commitment types for negotiation instead of the existing implicit + // negotiation methods. With this bit, there is no longer a "default" + // implicit channel commitment type, allowing a connection to + // open/maintain types of several channels over its lifetime. + // + // TODO: Decide on actual feature bit value. + ExplicitChannelTypeOptional = 2021 + // maxAllowedSize is a maximum allowed size of feature vector. // // NOTE: Within the protocol, the maximum allowed message size is 65535 @@ -184,6 +204,8 @@ var Features = map[FeatureBit]string{ WumboChannelsOptional: "wumbo-channels", AMPRequired: "amp", AMPOptional: "amp", + ExplicitChannelTypeOptional: "explicit-commitment-type", + ExplicitChannelTypeRequired: "explicit-commitment-type", } // RawFeatureVector represents a set of feature bits as defined in BOLT-09. A