Add init_features to list_channels filter callback
What changed, and why it matters
This is a small, internal code change that adds extra information (a peer's feature flags) to a channel-listing filter callback. It does not fix a bug or change any security behavior on its own; it simply prepares the code for future filtering capabilities.
No security action needed. Treat as normal development refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies list_funded_channels_with_filter in lightning/src/ln/channelmanager.rs so the filter closure receives &InitFeatures in addition to the channel ID and channel object. The existing live-channel filter is updated to ignore the new first tuple element. This is a pure API/internal refactor with no functional or security change.
Changed components
lightning/src/ln/channelmanager.rsInspect captured patch +11 / −5
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 53f45f3..3f722ae 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -4086,7 +4086,9 @@ where
Ok(temporary_channel_id)
}
- fn list_funded_channels_with_filter<Fn: FnMut(&(&ChannelId, &Channel<SP>)) -> bool + Copy>(
+ fn list_funded_channels_with_filter<
+ Fn: FnMut(&(&InitFeatures, &ChannelId, &Channel<SP>)) -> bool + Copy,
+ >(
&self, f: Fn,
) -> Vec<ChannelDetails> {
// Allocate our best estimate of the number of channels we have in the `res`
@@ -4102,9 +4104,13 @@ where
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
let peer_state = &mut *peer_state_lock;
// Only `Channels` in the `Channel::Funded` phase can be considered funded.
- let filtered_chan_by_id =
- peer_state.channel_by_id.iter().filter(|(_, chan)| chan.is_funded()).filter(f);
- res.extend(filtered_chan_by_id.map(|(_channel_id, channel)| {
+ let filtered_chan_by_id = peer_state
+ .channel_by_id
+ .iter()
+ .map(|(cid, c)| (&peer_state.latest_features, cid, c))
+ .filter(|(_, _, chan)| chan.is_funded())
+ .filter(f);
+ res.extend(filtered_chan_by_id.map(|(_, _channel_id, channel)| {
ChannelDetails::from_channel(
channel,
best_block_height,
@@ -4156,7 +4162,7 @@ where
// Note we use is_live here instead of usable which leads to somewhat confused
// internal/external nomenclature, but that's ok cause that's probably what the user
// really wanted anyway.
- self.list_funded_channels_with_filter(|&(_, ref channel)| channel.context().is_live())
+ self.list_funded_channels_with_filter(|&(_, _, ref channel)| channel.context().is_live())
}
/// Gets the list of channels we have with a given counterparty, in random order.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.