Skip to content

Commit 7a6d309

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 a8eef29 commit 7a6d309

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lightning/src/routing/router.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,14 +2142,15 @@ where L::Target: Logger {
21422142
for route in payment_params.payee.unblinded_route_hints().iter()
21432143
.filter(|route| !route.0.is_empty())
21442144
{
2145-
let first_hop_in_route = &(route.0)[0];
2146-
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();
2152-
if have_hop_src_in_graph {
2145+
let first_hop_src_id = NodeId::from_pubkey(&route.0.first().unwrap().src_node_id);
2146+
let first_hop_src_is_reachable =
2147+
// Only add the hops in this route to our candidate set if either we are part of
2148+
// the first hop, we have a direct channel to the first hop, or the first hop is in
2149+
// the regular network graph.
2150+
our_node_id == first_hop_src_id ||
2151+
first_hop_targets.get(&first_hop_src_id).is_some() ||
2152+
network_nodes.get(&first_hop_src_id).is_some();
2153+
if first_hop_src_is_reachable {
21532154
// We start building the path from reverse, i.e., from payee
21542155
// to the first RouteHintHop in the path.
21552156
let hop_iter = route.0.iter().rev();

0 commit comments

Comments
 (0)