Skip to content

Commit

Permalink
Relax channel count check for unannounced nodes
Browse files Browse the repository at this point in the history
When creating blinded paths, introduction nodes are limited to peers
with at least three channels to prevent easily guessing the recipient.
Relax this check when the recipient is unannounced since they won't be
in the NetworkGraph.
  • Loading branch information
jkczyz committed Jun 17, 2024
1 parent aa0a091 commit 2046b4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lightning/src/onion_message/messenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ where
.filter_map(|peer|
network_graph
.node(&NodeId::from_pubkey(&peer.node_id))
.filter(|info| info.channels.len() >= MIN_PEER_CHANNELS)
.filter(|info|
!is_recipient_announced || info.channels.len() >= MIN_PEER_CHANNELS
)
.map(|info| (peer, info.is_tor_only(), info.channels.len()))
// Allow messages directly with the only peer when unannounced.
.or_else(|| (!is_recipient_announced && has_one_peer)
Expand Down
3 changes: 2 additions & 1 deletion lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ impl<G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, ES: Deref, S: Deref,
.filter(|details| amount_msats <= details.inbound_capacity_msat)
.filter(|details| amount_msats >= details.inbound_htlc_minimum_msat.unwrap_or(0))
.filter(|details| amount_msats <= details.inbound_htlc_maximum_msat.unwrap_or(u64::MAX))
// Limit to peers with announced channels unless the recipient is unannounced.
.filter(|details| network_graph
.node(&NodeId::from_pubkey(&details.counterparty.node_id))
.map(|node_info| node_info.channels.len() >= MIN_PEER_CHANNELS)
.map(|node| !is_recipient_announced || node.channels.len() >= MIN_PEER_CHANNELS)
// Allow payments directly with the only peer when unannounced.
.unwrap_or(!is_recipient_announced && has_one_peer)
)
Expand Down

0 comments on commit 2046b4a

Please sign in to comment.