Skip to content

Commit 139d3fb

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 a70c5ff commit 139d3fb

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
@@ -176,7 +179,7 @@ mod sealed {
176179
// Byte 3
177180
ShutdownAnySegwit,
178181
// Byte 4
179-
,
182+
OnionMessages,
180183
// Byte 5
181184
ChannelType | SCIDPrivacy,
182185
// Byte 6
@@ -210,7 +213,7 @@ mod sealed {
210213
// Byte 3
211214
ShutdownAnySegwit,
212215
// Byte 4
213-
,
216+
OnionMessages,
214217
// Byte 5
215218
ChannelType | SCIDPrivacy,
216219
// Byte 6
@@ -437,8 +440,6 @@ mod sealed {
437440
define_feature!(27, ShutdownAnySegwit, [InitContext, NodeContext],
438441
"Feature flags for `opt_shutdown_anysegwit`.", set_shutdown_any_segwit_optional,
439442
set_shutdown_any_segwit_required, supports_shutdown_anysegwit, requires_shutdown_anysegwit);
440-
// We do not yet advertise the onion messages feature bit, but we need to detect when peers
441-
// support it.
442443
define_feature!(39, OnionMessages, [InitContext, NodeContext],
443444
"Feature flags for `option_onion_messages`.", set_onion_messages_optional,
444445
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)