Skip to content

Commit ae8cc52

Browse files
OR NodeFeatures from both Channel and Routing message handlers
When we broadcast a node announcement, the features we support are really a combination of all the various features our different handlers support. This commit captures this concept by OR'ing our NodeFeatures across both our channel and routing message handlers.
1 parent fe8b4c7 commit ae8cc52

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ mod tests {
582582
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
583583
fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: QueryChannelRange) -> Result<(), LightningError> { Ok(()) }
584584
fn handle_query_short_channel_ids(&self, _their_node_id: &PublicKey, _msg: QueryShortChannelIds) -> Result<(), LightningError> { Ok(()) }
585+
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::known() }
585586
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures { InitFeatures::known() }
586587
}
587588
impl ChannelMessageHandler for MsgHandler {

lightning/src/ln/msgs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,10 @@ pub trait RoutingMessageHandler : MessageSendEventsProvider {
958958
fn handle_query_short_channel_ids(&self, their_node_id: &PublicKey, msg: QueryShortChannelIds) -> Result<(), LightningError>;
959959

960960
// Handler information:
961+
/// Gets the node feature flags which this handler itself supports. All available handlers are
962+
/// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
963+
/// which are broadcasted in our node_announcement message.
964+
fn provided_node_features(&self) -> NodeFeatures;
961965
/// Gets the init feature flags which should be sent to the given peer. All available handlers
962966
/// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
963967
/// which are sent in our [`Init`] message.

lightning/src/ln/peer_handler.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl RoutingMessageHandler for IgnoringMessageHandler {
7777
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
7878
fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::QueryChannelRange) -> Result<(), LightningError> { Ok(()) }
7979
fn handle_query_short_channel_ids(&self, _their_node_id: &PublicKey, _msg: msgs::QueryShortChannelIds) -> Result<(), LightningError> { Ok(()) }
80+
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
8081
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
8182
InitFeatures::empty()
8283
}
@@ -1969,8 +1970,10 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
19691970
// addresses be sorted for future compatibility.
19701971
addresses.sort_by_key(|addr| addr.get_id());
19711972

1973+
let features = self.message_handler.chan_handler.provided_node_features()
1974+
.or(self.message_handler.route_handler.provided_node_features());
19721975
let announcement = msgs::UnsignedNodeAnnouncement {
1973-
features: self.message_handler.chan_handler.provided_node_features(),
1976+
features,
19741977
timestamp: self.last_node_announcement_serial.fetch_add(1, Ordering::AcqRel) as u32,
19751978
node_id: PublicKey::from_secret_key(&self.secp_ctx, &self.our_node_secret),
19761979
rgb, alias, addresses,

lightning/src/routing/gossip.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,12 @@ where C::Target: chain::Access, L::Target: Logger
571571
})
572572
}
573573

574+
fn provided_node_features(&self) -> NodeFeatures {
575+
let mut features = NodeFeatures::empty();
576+
features.set_gossip_queries_optional();
577+
features
578+
}
579+
574580
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
575581
let mut features = InitFeatures::empty();
576582
features.set_gossip_queries_optional();

lightning/src/util/test_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,12 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
511511
Ok(())
512512
}
513513

514+
fn provided_node_features(&self) -> NodeFeatures {
515+
let mut features = NodeFeatures::empty();
516+
features.set_gossip_queries_optional();
517+
features
518+
}
519+
514520
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
515521
let mut features = InitFeatures::empty();
516522
features.set_gossip_queries_optional();

0 commit comments

Comments
 (0)