Skip to content

Commit c1eda4b

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 642913c commit c1eda4b

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
@@ -511,7 +511,9 @@ where
511511
.filter_map(|peer|
512512
network_graph
513513
.node(&NodeId::from_pubkey(&peer.node_id))
514-
.filter(|info| info.channels.len() >= MIN_PEER_CHANNELS)
514+
.filter(|info|
515+
!is_recipient_announced || info.channels.len() >= MIN_PEER_CHANNELS
516+
)
515517
.map(|info| (peer, info.is_tor_only(), info.channels.len()))
516518
// Allow messages directly with the only peer when unannounced.
517519
.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)