Skip to content

Commit 2046b4a

Browse files
committed
Relax channel count check for unannounced nodes
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.
1 parent aa0a091 commit 2046b4a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,9 @@ where
505505
.filter_map(|peer|
506506
network_graph
507507
.node(&NodeId::from_pubkey(&peer.node_id))
508-
.filter(|info| info.channels.len() >= MIN_PEER_CHANNELS)
508+
.filter(|info|
509+
!is_recipient_announced || info.channels.len() >= MIN_PEER_CHANNELS
510+
)
509511
.map(|info| (peer, info.is_tor_only(), info.channels.len()))
510512
// Allow messages directly with the only peer when unannounced.
511513
.or_else(|| (!is_recipient_announced && has_one_peer)

lightning/src/routing/router.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ impl<G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, ES: Deref, S: Deref,
119119
.filter(|details| amount_msats <= details.inbound_capacity_msat)
120120
.filter(|details| amount_msats >= details.inbound_htlc_minimum_msat.unwrap_or(0))
121121
.filter(|details| amount_msats <= details.inbound_htlc_maximum_msat.unwrap_or(u64::MAX))
122+
// Limit to peers with announced channels unless the recipient is unannounced.
122123
.filter(|details| network_graph
123124
.node(&NodeId::from_pubkey(&details.counterparty.node_id))
124-
.map(|node_info| node_info.channels.len() >= MIN_PEER_CHANNELS)
125+
.map(|node| !is_recipient_announced || node.channels.len() >= MIN_PEER_CHANNELS)
125126
// Allow payments directly with the only peer when unannounced.
126127
.unwrap_or(!is_recipient_announced && has_one_peer)
127128
)

0 commit comments

Comments
 (0)