Skip to content

Commit ca3cc60

Browse files
committed
f - try avoid leaking the recipient's node_id
1 parent 0f741ab commit ca3cc60

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lightning/src/routing/router.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,21 @@ impl< G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, S: Deref, SP: Sized,
9090
&self, recipient: PublicKey, first_hops: Vec<ChannelDetails>, tlvs: ReceiveTlvs,
9191
amount_msats: u64, entropy_source: &ES, secp_ctx: &Secp256k1<T>
9292
) -> Result<Vec<(BlindedPayInfo, BlindedPath)>, ()> {
93+
// Ensure peers have at least three channels so that it is more difficult to infer the
94+
// recipient's node_id.
95+
const MIN_PEER_CHANNELS: usize = 3;
96+
let network_graph = self.network_graph.deref().read_only();
97+
9398
first_hops.into_iter()
9499
.filter(|details| details.is_public)
95100
.filter(|details| details.counterparty.features.supports_route_blinding())
96101
.filter(|details| amount_msats >= details.inbound_htlc_minimum_msat.unwrap_or(0))
97102
.filter(|details| amount_msats <= details.inbound_htlc_maximum_msat.unwrap_or(0))
103+
.filter(|details| network_graph
104+
.node(&NodeId::from_pubkey(&details.counterparty.node_id))
105+
.map(|node_info| node_info.channels.len() >= MIN_PEER_CHANNELS)
106+
.unwrap_or(false)
107+
)
98108
.map(|details| {
99109
let short_channel_id = details.get_inbound_payment_scid().unwrap();
100110
let payment_relay: PaymentRelay = details.counterparty.forwarding_info.unwrap().into();

0 commit comments

Comments
 (0)