Skip to content

Commit 7144866

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 1b4c0e8 commit 7144866

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lightning/src/routing/router.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -2097,9 +2097,10 @@ where L::Target: Logger {
20972097
for (hint_idx, hint) in payment_params.payee.blinded_route_hints().iter().enumerate() {
20982098
let intro_node_id = NodeId::from_pubkey(&hint.1.introduction_node_id);
20992099
let have_intro_node_in_graph =
2100-
// Only add the hops in this route to our candidate set if either
2101-
// we have a direct channel to the first hop or the first hop is
2102-
// in the regular network graph.
2100+
// Only add the hops in this route to our candidate set if either we are part of
2101+
// the first hop, we have a direct channel to the first hop, or the first hop is in
2102+
// the regular network graph.
2103+
our_node_id == intro_node_id ||
21032104
first_hop_targets.get(&intro_node_id).is_some() ||
21042105
network_nodes.get(&intro_node_id).is_some();
21052106
if !have_intro_node_in_graph { continue }
@@ -2132,12 +2133,14 @@ where L::Target: Logger {
21322133
.filter(|route| !route.0.is_empty())
21332134
{
21342135
let first_hop_in_route = &(route.0)[0];
2136+
let first_hop_src_id = NodeId::from_pubkey(&first_hop_in_route.src_node_id);
21352137
let have_hop_src_in_graph =
2136-
// Only add the hops in this route to our candidate set if either
2137-
// we have a direct channel to the first hop or the first hop is
2138-
// in the regular network graph.
2139-
first_hop_targets.get(&NodeId::from_pubkey(&first_hop_in_route.src_node_id)).is_some() ||
2140-
network_nodes.get(&NodeId::from_pubkey(&first_hop_in_route.src_node_id)).is_some();
2138+
// Only add the hops in this route to our candidate set if either we are part of
2139+
// the first hop, we have a direct channel to the first hop, or the first hop is in
2140+
// the regular network graph.
2141+
our_node_id == first_hop_src_id ||
2142+
first_hop_targets.get(&first_hop_src_id).is_some() ||
2143+
network_nodes.get(&first_hop_src_id).is_some();
21412144
if have_hop_src_in_graph {
21422145
// We start building the path from reverse, i.e., from payee
21432146
// to the first RouteHintHop in the path.

0 commit comments

Comments
 (0)