Skip to content

Commit 7619f6f

Browse files
Conditionally advertise onion msgs in node features in ChannelManager
1 parent fa92865 commit 7619f6f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lightning/src/ln/channelmanager.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2973,8 +2973,10 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
29732973
// addresses be sorted for future compatibility.
29742974
addresses.sort_by_key(|addr| addr.get_id());
29752975

2976+
let node_features = if self.advertise_onion_message_support.load(Ordering::Acquire) {
2977+
NodeFeatures::known() } else { NodeFeatures::known_without_onion_messages() };
29762978
let announcement = msgs::UnsignedNodeAnnouncement {
2977-
features: NodeFeatures::known(),
2979+
features: node_features,
29782980
timestamp: self.last_node_announcement_serial.fetch_add(1, Ordering::AcqRel) as u32,
29792981
node_id: self.get_our_node_id(),
29802982
rgb, alias, addresses,

lightning/src/ln/features.rs

+10
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,14 @@ impl InitFeatures {
550550
}
551551
}
552552

553+
impl NodeFeatures {
554+
pub(crate) fn known_without_onion_messages() -> Self {
555+
let mut features = Self::known();
556+
features.flags[4] &= 0b00111111;
557+
features
558+
}
559+
}
560+
553561
impl InvoiceFeatures {
554562
/// Converts `InvoiceFeatures` to `Features<C>`. Only known `InvoiceFeatures` relevant to
555563
/// context `C` are included in the result.
@@ -913,6 +921,8 @@ mod tests {
913921
assert!(NodeFeatures::known().supports_onion_messages());
914922
assert!(!InitFeatures::known().requires_onion_messages());
915923
assert!(!NodeFeatures::known().requires_onion_messages());
924+
assert!(!NodeFeatures::known_without_onion_messages().supports_onion_messages());
925+
assert!(!NodeFeatures::known_without_onion_messages().requires_onion_messages());
916926

917927
assert!(InitFeatures::known().supports_zero_conf());
918928
assert!(!InitFeatures::known().requires_zero_conf());

0 commit comments

Comments
 (0)