X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fpeer_handler.rs;h=ae2a52378e4279337afe4e04731eb1e1727b6487;hb=3313abb37d8745597c7fe8aeaa230f4e89160e02;hp=25ac234a847c5959f5414c74755d975b56a173f3;hpb=14c6810e48ea9a36fc8efc9f2ed788691acb9a02;p=rust-lightning diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 25ac234a..ae2a5237 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -17,7 +17,7 @@ use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey}; -use crate::chain::keysinterface::{KeysManager, NodeSigner, Recipient}; +use crate::sign::{KeysManager, NodeSigner, Recipient}; use crate::events::{MessageSendEvent, MessageSendEventsProvider, OnionMessageProvider}; use crate::ln::features::{InitFeatures, NodeFeatures}; use crate::ln::msgs; @@ -64,6 +64,20 @@ pub trait CustomMessageHandler: wire::CustomMessageReader { /// 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 get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>; + + /// 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. + /// + /// [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement + fn provided_node_features(&self) -> NodeFeatures; + + /// 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. + /// + /// [`Init`]: crate::ln::msgs::Init + fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures; } /// A dummy struct which implements `RoutingMessageHandler` without storing any routing information @@ -149,6 +163,12 @@ impl CustomMessageHandler for IgnoringMessageHandler { } fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> { Vec::new() } + + fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() } + + fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures { + InitFeatures::empty() + } } /// A dummy struct which implements `ChannelMessageHandler` without having any channels. @@ -850,6 +870,13 @@ impl InitFeatures { + self.message_handler.chan_handler.provided_init_features(their_node_id) + | self.message_handler.route_handler.provided_init_features(their_node_id) + | self.message_handler.onion_message_handler.provided_init_features(their_node_id) + | self.message_handler.custom_message_handler.provided_init_features(their_node_id) + } + /// Indicates a new outbound connection has been established to a node with the given `node_id` /// and an optional remote network address. /// @@ -1245,9 +1272,7 @@ impl bool { #[cfg(test)] mod tests { - use crate::chain::keysinterface::{NodeSigner, Recipient}; + use crate::sign::{NodeSigner, Recipient}; use crate::events; use crate::ln::peer_channel_encryptor::PeerChannelEncryptor; use crate::ln::peer_handler::{PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler, filter_addresses};