From 8ef3c9e620b7511e8a7ee88107b878585f2462da Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 31 Aug 2021 19:12:24 -0700 Subject: [PATCH] BOLT-02+09: introduce feature bit to gate new channel_type feature In this commit, we add a new feature bit to gate the new explicit channel type funding via the new `channel_type` TLV. The addition of this new bit allows peers to seek out other peers that understand the new explicit channel negotiation. This is useful in practice, as it allows peers to avoid needing to "downgrade" the feature bits advertised at the connection level due to one peer not understanding a new required feature bit while it has a channel with a connecting peer. Such a workaround is already deployed on the network between lnd peers and certain eclair peers, as the `lnd` peers require static key, but the feature bit is unknown to eclair peers. This situation (forced downgrade) is undesirable, as until the connected peer updates (or the channel is closed) and "worst" feature bit set must always be advertised in order to maintain connectivity. The other benefit of adding this feature bit is that it allows implementations to simplify their code by ensuring that the new feature will be used before sending any messages that include or reference that feature. Without a feature bit, peers are instead forced to essentially guess if a peer understands that feature, with logic to be able to "bail out" of an invalid state. The addition of this feature bit matches the prior precedent of adding feature bits when new fields in the channel negotiation message (last one was upfront shutdown) are added. --- 02-peer-protocol.md | 11 ++++++----- 09-features.md | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/02-peer-protocol.md b/02-peer-protocol.md index b869f02a4..daa5dc698 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -233,10 +233,11 @@ The sending node: - MAY include `upfront_shutdown_script`. - if it includes `open_channel_tlvs`: - MUST include `upfront_shutdown_script`. - - if it includes `channel_type`: - - MUST set it to a defined type representing the type it wants. - - MUST use the smallest bitmap possible to represent the channel type. - - SHOULD NOT set it to a type containing a feature which was not negotiated. + - if both peers advertised the `option_channel_type` feature: + - if it includes `channel_type`: + - MUST set it to a defined type representing the type it wants. + - MUST use the smallest bitmap possible to represent the channel type. + - SHOULD NOT set it to a type containing a feature which was not negotiated. The sending node SHOULD: - set `to_self_delay` sufficient to ensure the sender can irreversibly spend a commitment transaction output, in case of misbehavior by the receiver. @@ -412,7 +413,7 @@ This message introduces the `channel_id` to identify the channel. It's derived f #### Requirements Both peers: - - if `channel_type` was present in both `open_channel` and `accept_channel`: + - if the `option_channel_type` was advertised by both peers and `channel_type` was present in both `open_channel` and `accept_channel`: - This is the `channel_type` (they must be equal, required above) - otherwise: - if `option_anchors_zero_fee_htlc_tx` was negotiated: diff --git a/09-features.md b/09-features.md index 54cd2de6e..5154a0779 100644 --- a/09-features.md +++ b/09-features.md @@ -41,6 +41,7 @@ The Context column decodes as follows: | 20/21 | `option_anchor_outputs` | Anchor outputs | IN | `option_static_remotekey` | [BOLT #3](03-transactions.md) | | 22/23 | `option_anchors_zero_fee_htlc_tx` | Anchor commitment type with zero fee HTLC transactions | IN | | [BOLT #3][bolt03-htlc-tx], [lightning-dev][ml-sighash-single-harmful]| | 26/27 | `option_shutdown_anysegwit` | Future segwit versions allowed in `shutdown` | IN | | [BOLT #2][bolt02-shutdown] | +| 28/29 | `option_channel_type` | Node supports the `channel_type` field in open/accept | IN | | [BOLT #2](02-peer-protocol.md#the-open_channel-message) | ## Definitions