Also add route hints if we are the source
authorElias Rohrer <dev@tnull.de>
Fri, 22 Sep 2023 13:56:07 +0000 (15:56 +0200)
committerElias Rohrer <dev@tnull.de>
Thu, 28 Sep 2023 17:45:29 +0000 (19:45 +0200)
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

index 8db682ebdfedf63552c7bbcadee50556a76574f1..0a8ee425881b1c7bfdbe0201f24d2c5f841749c5 100644 (file)
@@ -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();