Skip to content

Commit 9f1690c

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 decfe76 commit 9f1690c

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);
@@ -925,6 +926,11 @@ mod tests {
925926
assert!(!InitFeatures::known().requires_wumbo());
926927
assert!(!NodeFeatures::known().requires_wumbo());
927928

929+
assert!(InitFeatures::known().supports_onion_messages());
930+
assert!(NodeFeatures::known().supports_onion_messages());
931+
assert!(!InitFeatures::known().requires_onion_messages());
932+
assert!(!NodeFeatures::known().requires_onion_messages());
933+
928934
assert!(InitFeatures::known().supports_zero_conf());
929935
assert!(!InitFeatures::known().requires_zero_conf());
930936
assert!(NodeFeatures::known().supports_zero_conf());
@@ -969,15 +975,15 @@ mod tests {
969975
// - var_onion_optin (req) | static_remote_key (req) | payment_secret(req)
970976
// - basic_mpp | wumbo
971977
// - opt_shutdown_anysegwit
972-
// -
978+
// - onion_messages
973979
// - option_channel_type | option_scid_alias
974980
// - option_zeroconf
975981
assert_eq!(node_features.flags.len(), 7);
976982
assert_eq!(node_features.flags[0], 0b00000010);
977983
assert_eq!(node_features.flags[1], 0b01010001);
978984
assert_eq!(node_features.flags[2], 0b00001010);
979985
assert_eq!(node_features.flags[3], 0b00001000);
980-
assert_eq!(node_features.flags[4], 0b00000000);
986+
assert_eq!(node_features.flags[4], 0b10000000);
981987
assert_eq!(node_features.flags[5], 0b10100000);
982988
assert_eq!(node_features.flags[6], 0b00001000);
983989
}

0 commit comments

Comments
 (0)