Skip to content

Commit 8f4a22f

Browse files
committed
Support the channel_type feature bit.
Note that this feature bit does absolutely nothing. We signal it (as we already support channel type negotiation), but do not bother to look to see if peers support it, as we don't care - we simply look for the TLV entry and deduce if a peer supports channel type negotiation from that. The only behavioral change at all here is that we don't barf if a peer sets channel type negotiation to required via the feature bit (instead of failing the channel at open-time), but of course no implementations do this, and likely won't for some time (if ever - you can simply fail channels with unknown types later, and there's no reason to refuse connections, really). As defined in lightning/bolts#906
1 parent aa5e5f9 commit 8f4a22f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lightning/src/ln/features.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ mod sealed {
126126
,
127127
// Byte 3
128128
,
129+
// Byte 4
130+
,
131+
// Byte 5
132+
,
129133
],
130134
optional_features: [
131135
// Byte 0
@@ -136,6 +140,10 @@ mod sealed {
136140
BasicMPP,
137141
// Byte 3
138142
ShutdownAnySegwit,
143+
// Byte 4
144+
,
145+
// Byte 5
146+
ChannelType,
139147
],
140148
});
141149
define_context!(NodeContext {
@@ -167,7 +175,7 @@ mod sealed {
167175
// Byte 4
168176
,
169177
// Byte 5
170-
,
178+
ChannelType,
171179
// Byte 6
172180
Keysend,
173181
],
@@ -379,6 +387,9 @@ mod sealed {
379387
define_feature!(27, ShutdownAnySegwit, [InitContext, NodeContext],
380388
"Feature flags for `opt_shutdown_anysegwit`.", set_shutdown_any_segwit_optional,
381389
set_shutdown_any_segwit_required, supports_shutdown_anysegwit, requires_shutdown_anysegwit);
390+
define_feature!(45, ChannelType, [InitContext, NodeContext],
391+
"Feature flags for `option_channel_type`.", set_channel_type_optional,
392+
set_channel_type_required, supports_channel_type, requires_channel_type);
382393
define_feature!(55, Keysend, [NodeContext],
383394
"Feature flags for keysend payments.", set_keysend_optional, set_keysend_required,
384395
supports_keysend, requires_keysend);
@@ -807,6 +818,11 @@ mod tests {
807818
assert!(!NodeFeatures::known().requires_basic_mpp());
808819
assert!(!InvoiceFeatures::known().requires_basic_mpp());
809820

821+
assert!(InitFeatures::known().supports_channel_type());
822+
assert!(NodeFeatures::known().supports_channel_type());
823+
assert!(!InitFeatures::known().requires_channel_type());
824+
assert!(!NodeFeatures::known().requires_channel_type());
825+
810826
assert!(InitFeatures::known().supports_shutdown_anysegwit());
811827
assert!(NodeFeatures::known().supports_shutdown_anysegwit());
812828

@@ -845,11 +861,15 @@ mod tests {
845861
// - var_onion_optin (req) | static_remote_key (req) | payment_secret(req)
846862
// - basic_mpp
847863
// - opt_shutdown_anysegwit
848-
assert_eq!(node_features.flags.len(), 4);
864+
// -
865+
// - option_channel_type
866+
assert_eq!(node_features.flags.len(), 6);
849867
assert_eq!(node_features.flags[0], 0b00000010);
850868
assert_eq!(node_features.flags[1], 0b01010001);
851869
assert_eq!(node_features.flags[2], 0b00000010);
852870
assert_eq!(node_features.flags[3], 0b00001000);
871+
assert_eq!(node_features.flags[4], 0b00000000);
872+
assert_eq!(node_features.flags[5], 0b00100000);
853873
}
854874

855875
// Check that cleared flags are kept blank when converting back:

0 commit comments

Comments
 (0)