Skip to content

Commit 123a0fc

Browse files
Support forwarding onion messages in advertised features
In upcoming commit(s), onion message support will be advertised conditionally based on the OnionMessageProvider provided to PeerManager.
1 parent 65a3b92 commit 123a0fc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lightning/src/ln/features.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information).
4444
//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown`
4545
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
46+
//! - `OnionMessages` - requires/supports forwarding onion messages
47+
//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information).
48+
//! TODO: update link
4649
//! - `ChannelType` - node supports the channel_type field in open/accept
4750
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
4851
//! - `SCIDPrivacy` - supply channel aliases for routing
@@ -174,7 +177,7 @@ mod sealed {
174177
// Byte 3
175178
ShutdownAnySegwit,
176179
// Byte 4
177-
,
180+
OnionMessages,
178181
// Byte 5
179182
ChannelType | SCIDPrivacy,
180183
// Byte 6
@@ -208,7 +211,7 @@ mod sealed {
208211
// Byte 3
209212
ShutdownAnySegwit,
210213
// Byte 4
211-
,
214+
OnionMessages,
212215
// Byte 5
213216
ChannelType | SCIDPrivacy,
214217
// Byte 6
@@ -435,8 +438,6 @@ mod sealed {
435438
define_feature!(27, ShutdownAnySegwit, [InitContext, NodeContext],
436439
"Feature flags for `opt_shutdown_anysegwit`.", set_shutdown_any_segwit_optional,
437440
set_shutdown_any_segwit_required, supports_shutdown_anysegwit, requires_shutdown_anysegwit);
438-
// We do not yet advertise the onion messages feature bit, but we need to detect when peers
439-
// support it.
440441
define_feature!(39, OnionMessages, [InitContext, NodeContext],
441442
"Feature flags for `option_onion_messages`.", set_onion_messages_optional,
442443
set_onion_messages_required, supports_onion_messages, requires_onion_messages);
@@ -908,6 +909,11 @@ mod tests {
908909
assert!(!InitFeatures::known().requires_wumbo());
909910
assert!(!NodeFeatures::known().requires_wumbo());
910911

912+
assert!(InitFeatures::known().supports_onion_messages());
913+
assert!(NodeFeatures::known().supports_onion_messages());
914+
assert!(!InitFeatures::known().requires_onion_messages());
915+
assert!(!NodeFeatures::known().requires_onion_messages());
916+
911917
assert!(InitFeatures::known().supports_zero_conf());
912918
assert!(!InitFeatures::known().requires_zero_conf());
913919
assert!(NodeFeatures::known().supports_zero_conf());
@@ -952,15 +958,15 @@ mod tests {
952958
// - var_onion_optin (req) | static_remote_key (req) | payment_secret(req)
953959
// - basic_mpp | wumbo
954960
// - opt_shutdown_anysegwit
955-
// -
961+
// - onion_messages
956962
// - option_channel_type | option_scid_alias
957963
// - option_zeroconf
958964
assert_eq!(node_features.flags.len(), 7);
959965
assert_eq!(node_features.flags[0], 0b00000010);
960966
assert_eq!(node_features.flags[1], 0b01010001);
961967
assert_eq!(node_features.flags[2], 0b00001010);
962968
assert_eq!(node_features.flags[3], 0b00001000);
963-
assert_eq!(node_features.flags[4], 0b00000000);
969+
assert_eq!(node_features.flags[4], 0b10000000);
964970
assert_eq!(node_features.flags[5], 0b10100000);
965971
assert_eq!(node_features.flags[6], 0b00001000);
966972
}

0 commit comments

Comments
 (0)