Skip to content

Commit 6146772

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 f6ebf3b commit 6146772

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
@@ -177,7 +180,7 @@ mod sealed {
177180
// Byte 3
178181
ShutdownAnySegwit,
179182
// Byte 4
180-
,
183+
OnionMessages,
181184
// Byte 5
182185
ChannelType | SCIDPrivacy,
183186
// Byte 6
@@ -211,7 +214,7 @@ mod sealed {
211214
// Byte 3
212215
ShutdownAnySegwit,
213216
// Byte 4
214-
,
217+
OnionMessages,
215218
// Byte 5
216219
ChannelType | SCIDPrivacy,
217220
// Byte 6
@@ -438,8 +441,6 @@ mod sealed {
438441
define_feature!(27, ShutdownAnySegwit, [InitContext, NodeContext],
439442
"Feature flags for `opt_shutdown_anysegwit`.", set_shutdown_any_segwit_optional,
440443
set_shutdown_any_segwit_required, supports_shutdown_anysegwit, requires_shutdown_anysegwit);
441-
// We do not yet advertise the onion messages feature bit, but we need to detect when peers
442-
// support it.
443444
define_feature!(39, OnionMessages, [InitContext, NodeContext],
444445
"Feature flags for `option_onion_messages`.", set_onion_messages_optional,
445446
set_onion_messages_required, supports_onion_messages, requires_onion_messages);
@@ -924,6 +925,11 @@ mod tests {
924925
assert!(!InitFeatures::known().requires_wumbo());
925926
assert!(!NodeFeatures::known().requires_wumbo());
926927

928+
assert!(InitFeatures::known().supports_onion_messages());
929+
assert!(NodeFeatures::known().supports_onion_messages());
930+
assert!(!InitFeatures::known().requires_onion_messages());
931+
assert!(!NodeFeatures::known().requires_onion_messages());
932+
927933
assert!(InitFeatures::known().supports_zero_conf());
928934
assert!(!InitFeatures::known().requires_zero_conf());
929935
assert!(NodeFeatures::known().supports_zero_conf());
@@ -968,15 +974,15 @@ mod tests {
968974
// - var_onion_optin (req) | static_remote_key (req) | payment_secret(req)
969975
// - basic_mpp | wumbo
970976
// - opt_shutdown_anysegwit
971-
// -
977+
// - onion_messages
972978
// - option_channel_type | option_scid_alias
973979
// - option_zeroconf
974980
assert_eq!(node_features.flags.len(), 7);
975981
assert_eq!(node_features.flags[0], 0b00000010);
976982
assert_eq!(node_features.flags[1], 0b01010001);
977983
assert_eq!(node_features.flags[2], 0b00001010);
978984
assert_eq!(node_features.flags[3], 0b00001000);
979-
assert_eq!(node_features.flags[4], 0b00000000);
985+
assert_eq!(node_features.flags[4], 0b10000000);
980986
assert_eq!(node_features.flags[5], 0b10100000);
981987
assert_eq!(node_features.flags[6], 0b00001000);
982988
}

0 commit comments

Comments
 (0)