Skip to content

Commit 38d196b

Browse files
committed
Probe up to second-to-last hop if last was provided by route hint
If the last hop was provided by route hint we assume it's not an announced channel. If furthermore only a single route hint is provided we refrain from probing through all the way to the end and instead probe up to the second-to-last channel. Optimally we'd do this not based on above mentioned assumption but rather by checking inclusion in our network graph. However, we don't have access to our graph in `ChannelManager`.
1 parent b4ce810 commit 38d196b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3520,7 +3520,26 @@ where
35203520
let mut used_liquidity_map = HashMap::with_capacity(first_hops.len());
35213521

35223522
let mut res = Vec::new();
3523-
for path in route.paths {
3523+
for mut path in route.paths {
3524+
// If the last hop was provided by route hint we assume it's not an announced channel.
3525+
// If furthermore only a single route hint is provided we refrain from probing through
3526+
// all the way to the end and instead probe up to the second-to-last channel.
3527+
if let Payee::Clear { node_id, ref route_hints, .. } = route_params.payment_params.payee {
3528+
if route_hints.len() == 1 {
3529+
if let Some(hint) = route_hints[0].0.iter().last() {
3530+
if let Some(last_path_hop) = path.hops.last() {
3531+
if last_path_hop.pubkey == node_id && last_path_hop.short_channel_id == hint.short_channel_id {
3532+
let final_value_msat = path.final_value_msat();
3533+
path.hops.pop();
3534+
if let Some(mut new_last) = path.hops.iter_mut().last() {
3535+
new_last.fee_msat += final_value_msat;
3536+
}
3537+
}
3538+
}
3539+
}
3540+
}
3541+
}
3542+
35243543
if path.hops.len() + path.blinded_tail.as_ref().map_or(0, |t| t.hops.len()) < 2 {
35253544
log_debug!(
35263545
self.logger,

0 commit comments

Comments
 (0)