- let intro_node_id = NodeId::from_pubkey(&hint.1.introduction_node_id);
- let have_intro_node_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(&intro_node_id).is_some() ||
- network_nodes.get(&intro_node_id).is_some();
- if !have_intro_node_in_graph || our_node_id == intro_node_id { continue }
+ // 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.
+ let source_node_id = match introduction_node_id_cache[hint_idx] {
+ Some(node_id) => node_id,
+ None => match &hint.1.introduction_node {
+ IntroductionNode::NodeId(pubkey) => {
+ let node_id = NodeId::from_pubkey(&pubkey);
+ match first_hop_targets.get_key_value(&node_id).map(|(key, _)| key) {
+ Some(node_id) => node_id,
+ None => continue,
+ }
+ },
+ IntroductionNode::DirectedShortChannelId(direction, scid) => {
+ let first_hop = first_hop_targets.iter().find(|(_, channels)|
+ channels
+ .iter()
+ .any(|details| Some(*scid) == details.get_outbound_payment_scid())
+ );
+ match first_hop {
+ Some((counterparty_node_id, _)) => {
+ direction.select_node_id(&our_node_id, counterparty_node_id)
+ },
+ None => continue,
+ }
+ },
+ },
+ };
+ if our_node_id == *source_node_id { continue }