From c1eda4ba3d9189ea3831c705505c3e3f2edcdbbe Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Mon, 17 Jun 2024 14:41:32 -0500 Subject: [PATCH] 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. --- lightning/src/onion_message/messenger.rs | 4 +++- lightning/src/routing/router.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index d333eb210..859c3f2b5 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -511,7 +511,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) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 036d6372a..28aaba051 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -119,9 +119,10 @@ impl> + 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) ) -- 2.39.5