Skip to content

Commit

Permalink
Conditionally advertise OM support in InitFeatures
Browse files Browse the repository at this point in the history
Based on whether the PeerManager's OnionMessageHandler supports forwarding
  • Loading branch information
valentinewallace committed Sep 6, 2022
1 parent 602d739 commit 98ccbcc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lightning/src/ln/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ impl InitFeatures {
pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
self.to_context_internal()
}

pub(crate) fn known_without_onion_messages() -> Self {
let mut features = Self::known();
features.flags[4] &= 0b00111111;
features
}
}

impl InvoiceFeatures {
Expand Down
6 changes: 4 additions & 2 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,8 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM

peer.their_node_id = Some(their_node_id);
insert_node_id!();
let features = InitFeatures::known();
let features = if self.message_handler.onion_message_handler.supports_onion_message_forwarding()
{ InitFeatures::known() } else { InitFeatures::known_without_onion_messages() };
let resp = msgs::Init { features, remote_network_address: filter_addresses(peer.their_net_address.clone()) };
self.enqueue_message(peer, &resp);
peer.awaiting_pong_timer_tick_intervals = 0;
Expand All @@ -1045,7 +1046,8 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
peer.pending_read_is_header = true;
peer.their_node_id = Some(their_node_id);
insert_node_id!();
let features = InitFeatures::known();
let features = if self.message_handler.onion_message_handler.supports_onion_message_forwarding()
{ InitFeatures::known() } else { InitFeatures::known_without_onion_messages() };
let resp = msgs::Init { features, remote_network_address: filter_addresses(peer.their_net_address.clone()) };
self.enqueue_message(peer, &resp);
peer.awaiting_pong_timer_tick_intervals = 0;
Expand Down

0 comments on commit 98ccbcc

Please sign in to comment.