mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 23:08:36 +01:00
Fetch our InitFeatures
from ChannelMessageHandler
Like we now do for `NodeFeatures`, this converts to asking our registered `ChannelMessageHandler` for our `InitFeatures` instead of hard-coding them to the global LDK known set. This allows handlers to set different feature bits based on what our configuration actually supports rather than what LDK supports in aggregate.
This commit is contained in:
parent
ba69536843
commit
950ccc4340
5 changed files with 18 additions and 2 deletions
|
@ -614,6 +614,7 @@ mod tests {
|
|||
fn handle_channel_reestablish(&self, _their_node_id: &PublicKey, _msg: &ChannelReestablish) {}
|
||||
fn handle_error(&self, _their_node_id: &PublicKey, _msg: &ErrorMessage) {}
|
||||
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::known() }
|
||||
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures { InitFeatures::known() }
|
||||
}
|
||||
impl MessageSendEventsProvider for MsgHandler {
|
||||
fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent> {
|
||||
|
|
|
@ -6124,6 +6124,10 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
|
|||
fn provided_node_features(&self) -> NodeFeatures {
|
||||
NodeFeatures::known()
|
||||
}
|
||||
|
||||
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
|
||||
InitFeatures::known()
|
||||
}
|
||||
}
|
||||
|
||||
const SERIALIZATION_VERSION: u8 = 1;
|
||||
|
|
|
@ -902,6 +902,13 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
|
|||
/// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
|
||||
/// which are broadcasted in our node_announcement message.
|
||||
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.
|
||||
///
|
||||
/// Note that this method is called before [`Self::peer_connected`].
|
||||
fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures;
|
||||
}
|
||||
|
||||
/// A trait to describe an object which can receive routing messages.
|
||||
|
|
|
@ -203,6 +203,7 @@ impl ChannelMessageHandler for ErroringMessageHandler {
|
|||
fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &msgs::Init) {}
|
||||
fn handle_error(&self, _their_node_id: &PublicKey, _msg: &msgs::ErrorMessage) {}
|
||||
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
|
||||
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures { InitFeatures::known() }
|
||||
}
|
||||
impl Deref for ErroringMessageHandler {
|
||||
type Target = ErroringMessageHandler;
|
||||
|
@ -1052,7 +1053,7 @@ 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 = self.message_handler.chan_handler.provided_init_features(&their_node_id);
|
||||
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;
|
||||
|
@ -1064,7 +1065,7 @@ 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 = self.message_handler.chan_handler.provided_init_features(&their_node_id);
|
||||
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;
|
||||
|
|
|
@ -360,6 +360,9 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
|
|||
fn provided_node_features(&self) -> NodeFeatures {
|
||||
NodeFeatures::empty()
|
||||
}
|
||||
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
|
||||
InitFeatures::known()
|
||||
}
|
||||
}
|
||||
|
||||
impl events::MessageSendEventsProvider for TestChannelMessageHandler {
|
||||
|
|
Loading…
Add table
Reference in a new issue