From ccf18e1b47f7f3b5134f3a73dfa2bf56c13fd762 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 23 Jul 2018 21:51:19 -0400 Subject: [PATCH] Short-circuit router for an outbound specified direct channel --- src/ln/router.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ln/router.rs b/src/ln/router.rs index 9e3272c13..0ee6450fa 100644 --- a/src/ln/router.rs +++ b/src/ln/router.rs @@ -403,7 +403,18 @@ impl Router { let mut first_hop_targets = HashMap::with_capacity(if first_hops.is_some() { first_hops.as_ref().unwrap().len() } else { 0 }); if let Some(hops) = first_hops { for chan in hops { - first_hop_targets.insert(chan.remote_network_id, chan.short_channel_id.expect("first_hops should be filled in with usable channels, not pending ones")); + let short_channel_id = chan.short_channel_id.expect("first_hops should be filled in with usable channels, not pending ones"); + if chan.remote_network_id == *target { + return Ok(Route { + hops: vec![RouteHop { + pubkey: chan.remote_network_id, + short_channel_id, + fee_msat: final_value_msat, + cltv_expiry_delta: final_cltv, + }], + }); + } + first_hop_targets.insert(chan.remote_network_id, short_channel_id); } if first_hop_targets.is_empty() { return Err(HandleError{err: "Cannot route when there are no outbound routes away from us", action: None}); -- 2.39.5