breez_sdk_liquid::lightning::ln::peer_handler

Trait CustomMessageHandler

pub trait CustomMessageHandler: CustomMessageReader {
    // Required methods
    fn handle_custom_message(
        &self,
        msg: Self::CustomMessage,
        sender_node_id: &PublicKey,
    ) -> Result<(), LightningError>;
    fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>;
    fn provided_node_features(&self) -> Features<NodeContext>;
    fn provided_init_features(
        &self,
        their_node_id: &PublicKey,
    ) -> Features<InitContext>;
}
Expand description

A handler provided to PeerManager for reading and handling custom messages.

BOLT 1 specifies a custom message type range for use with experimental or application-specific messages. CustomMessageHandler allows for user-defined handling of such types. See the lightning_custom_message crate for tools useful in composing more than one custom handler.

Required Methods§

fn handle_custom_message( &self, msg: Self::CustomMessage, sender_node_id: &PublicKey, ) -> Result<(), LightningError>

Handles the given message sent from sender_node_id, possibly producing messages for CustomMessageHandler::get_and_clear_pending_msg to return and thus for PeerManager to send.

fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>

Returns the list of pending messages that were generated by the handler, clearing the list in the process. Each message is paired with the node id of the intended recipient. If no connection to the node exists, then the message is simply not sent.

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>

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.

Object Safety§

This trait is not object safe.

Implementors§