From 7a6d3097a6aa59b5aa2e8e83527cd3ee79560750 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Fri, 22 Sep 2023 15:56:07 +0200 Subject: [PATCH] Also add route hints if we are the source Previously, we would only consider route hints if we had a direct channel to the first node in the hint or if the first node in the hint was part of the public network graph. However, this left out the possiblity of us being part of the first hop, especially if our own node is not announced and part of the graph. --- lightning/src/routing/router.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 8db682ebd..0a8ee4258 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -2142,14 +2142,15 @@ where L::Target: Logger { for route in payment_params.payee.unblinded_route_hints().iter() .filter(|route| !route.0.is_empty()) { - let first_hop_in_route = &(route.0)[0]; - let have_hop_src_in_graph = - // Only add the hops in this route to our candidate set if either - // we have a direct channel to the first hop or the first hop is - // in the regular network graph. - first_hop_targets.get(&NodeId::from_pubkey(&first_hop_in_route.src_node_id)).is_some() || - network_nodes.get(&NodeId::from_pubkey(&first_hop_in_route.src_node_id)).is_some(); - if have_hop_src_in_graph { + let first_hop_src_id = NodeId::from_pubkey(&route.0.first().unwrap().src_node_id); + let first_hop_src_is_reachable = + // Only add the hops in this route to our candidate set if either we are part of + // the first hop, we have a direct channel to the first hop, or the first hop is in + // the regular network graph. + our_node_id == first_hop_src_id || + first_hop_targets.get(&first_hop_src_id).is_some() || + network_nodes.get(&first_hop_src_id).is_some(); + if first_hop_src_is_reachable { // We start building the path from reverse, i.e., from payee // to the first RouteHintHop in the path. let hop_iter = route.0.iter().rev(); -- 2.39.5