Skip to content

Commit 3d5225a

Browse files
Make OnionMessageHandler indicate whether forwarding is supported
Used in upcoming commit(s) to decide whether to advertise onion message support in features.
1 parent 123a0fc commit 3d5225a

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

lightning/src/ln/msgs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,8 @@ pub trait OnionMessageHandler : OnionMessageProvider {
955955
/// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
956956
/// drop and refuse to forward onion messages to this peer.
957957
fn peer_disconnected(&self, their_node_id: &PublicKey, no_connection_possible: bool);
958+
/// Whether this object supports forwarding onion messages.
959+
fn supports_onion_message_forwarding(&self) -> bool;
958960
}
959961

960962
mod fuzzy_internal_msgs {

lightning/src/ln/peer_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl OnionMessageHandler for IgnoringMessageHandler {
8383
fn handle_onion_message(&self, _their_node_id: &PublicKey, _msg: &msgs::OnionMessage) {}
8484
fn peer_connected(&self, _their_node_id: &PublicKey, _init: &msgs::Init) {}
8585
fn peer_disconnected(&self, _their_node_id: &PublicKey, _no_connection_possible: bool) {}
86+
fn supports_onion_message_forwarding(&self) -> bool { false }
8687
}
8788
impl Deref for IgnoringMessageHandler {
8889
type Target = IgnoringMessageHandler;

lightning/src/onion_message/messenger.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ impl<Signer: Sign, K: Deref, L: Deref> OnionMessageHandler for OnionMessenger<Si
318318
let mut pending_msgs = self.pending_messages.lock().unwrap();
319319
pending_msgs.remove(their_node_id);
320320
}
321+
322+
fn supports_onion_message_forwarding(&self) -> bool { true }
321323
}
322324

323325
impl<Signer: Sign, K: Deref, L: Deref> OnionMessageProvider for OnionMessenger<Signer, K, L>

0 commit comments

Comments
 (0)