Trait breez_sdk_liquid::lightning::ln::msgs::OnionMessageHandler
pub trait OnionMessageHandler {
// Required methods
fn handle_onion_message(&self, peer_node_id: &PublicKey, msg: &OnionMessage);
fn next_onion_message_for_peer(
&self,
peer_node_id: PublicKey,
) -> Option<OnionMessage>;
fn peer_connected(
&self,
their_node_id: &PublicKey,
init: &Init,
inbound: bool,
) -> Result<(), ()>;
fn peer_disconnected(&self, their_node_id: &PublicKey);
fn provided_node_features(&self) -> Features<NodeContext>;
fn provided_init_features(
&self,
their_node_id: &PublicKey,
) -> Features<InitContext>;
}
Expand description
A handler for received OnionMessage
s and for providing generated ones to send.
Required Methods§
fn handle_onion_message(&self, peer_node_id: &PublicKey, msg: &OnionMessage)
fn handle_onion_message(&self, peer_node_id: &PublicKey, msg: &OnionMessage)
Handle an incoming onion_message
message from the given peer.
fn next_onion_message_for_peer(
&self,
peer_node_id: PublicKey,
) -> Option<OnionMessage>
fn next_onion_message_for_peer( &self, peer_node_id: PublicKey, ) -> Option<OnionMessage>
Returns the next pending onion message for the peer with the given node id.
fn peer_connected(
&self,
their_node_id: &PublicKey,
init: &Init,
inbound: bool,
) -> Result<(), ()>
fn peer_connected( &self, their_node_id: &PublicKey, init: &Init, inbound: bool, ) -> Result<(), ()>
Called when a connection is established with a peer. Can be used to track which peers advertise onion message support and are online.
May return an Err(())
if the features the peer supports are not sufficient to communicate
with us. Implementors should be somewhat conservative about doing so, however, as other
message handlers may still wish to communicate with this peer.
fn peer_disconnected(&self, their_node_id: &PublicKey)
fn peer_disconnected(&self, their_node_id: &PublicKey)
Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to drop and refuse to forward onion messages to this peer.
fn provided_node_features(&self) -> Features<NodeContext>
fn provided_node_features(&self) -> Features<NodeContext>
Gets the node feature flags which this handler itself supports. All available handlers are
queried similarly and their feature flags are OR’d together to form the NodeFeatures
which are broadcasted in our NodeAnnouncement
message.
fn provided_init_features(
&self,
their_node_id: &PublicKey,
) -> Features<InitContext>
fn provided_init_features( &self, their_node_id: &PublicKey, ) -> Features<InitContext>
Gets the init feature flags which should be sent to the given peer. All available handlers
are queried similarly and their feature flags are OR’d together to form the InitFeatures
which are sent in our Init
message.
Note that this method is called before Self::peer_connected
.