Skip to content

Commit e2f0429

Browse files
committed
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.
1 parent 89b116b commit e2f0429

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lightning/src/routing/router.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,12 +2107,13 @@ where L::Target: Logger {
21072107
for (hint_idx, hint) in payment_params.payee.blinded_route_hints().iter().enumerate() {
21082108
let intro_node_id = NodeId::from_pubkey(&hint.1.introduction_node_id);
21092109
let have_intro_node_in_graph =
2110-
// Only add the hops in this route to our candidate set if either
2111-
// we have a direct channel to the first hop or the first hop is
2112-
// in the regular network graph.
2110+
// Only add the hops in this route to our candidate set if either we are part of
2111+
// the first hop, we have a direct channel to the first hop, or the first hop is in
2112+
// the regular network graph.
2113+
our_node_id == intro_node_id ||
21132114
first_hop_targets.get(&intro_node_id).is_some() ||
21142115
network_nodes.get(&intro_node_id).is_some();
2115-
if !have_intro_node_in_graph || our_node_id == intro_node_id { continue }
2116+
if !have_intro_node_in_graph { continue }
21162117
let candidate = if hint.1.blinded_hops.len() == 1 {
21172118
CandidateRouteHop::OneHopBlinded { hint, hint_idx }
21182119
} else { CandidateRouteHop::Blinded { hint, hint_idx } };
@@ -2143,12 +2144,14 @@ where L::Target: Logger {
21432144
.filter(|route| !route.0.is_empty())
21442145
{
21452146
let first_hop_in_route = &(route.0)[0];
2147+
let first_hop_src_id = NodeId::from_pubkey(&first_hop_in_route.src_node_id);
21462148
let have_hop_src_in_graph =
2147-
// Only add the hops in this route to our candidate set if either
2148-
// we have a direct channel to the first hop or the first hop is
2149-
// in the regular network graph.
2150-
first_hop_targets.get(&NodeId::from_pubkey(&first_hop_in_route.src_node_id)).is_some() ||
2151-
network_nodes.get(&NodeId::from_pubkey(&first_hop_in_route.src_node_id)).is_some();
2149+
// Only add the hops in this route to our candidate set if either we are part of
2150+
// the first hop, we have a direct channel to the first hop, or the first hop is in
2151+
// the regular network graph.
2152+
our_node_id == first_hop_src_id ||
2153+
first_hop_targets.get(&first_hop_src_id).is_some() ||
2154+
network_nodes.get(&first_hop_src_id).is_some();
21522155
if have_hop_src_in_graph {
21532156
// We start building the path from reverse, i.e., from payee
21542157
// to the first RouteHintHop in the path.

0 commit comments

Comments
 (0)