Skip to content

Commit e11a513

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 e11a513

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3520,7 +3520,22 @@ 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 path.hops.last().map(|h| h.pubkey) == Some(node_id) {
3530+
let final_value_msat = path.final_value_msat();
3531+
path.hops.pop();
3532+
if let Some(mut new_last) = path.hops.iter_mut().last() {
3533+
new_last.fee_msat += final_value_msat;
3534+
}
3535+
}
3536+
}
3537+
}
3538+
35243539
if path.hops.len() + path.blinded_tail.as_ref().map_or(0, |t| t.hops.len()) < 2 {
35253540
log_debug!(
35263541
self.logger,

0 commit comments

Comments
 (0)