Skip to content

Commit da48da0

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 6b34708 commit da48da0

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
@@ -3503,7 +3503,22 @@ where
35033503
let mut used_liquidity_map = HashMap::with_capacity(first_hops.len());
35043504

35053505
let mut res = Vec::new();
3506-
for path in route.paths {
3506+
for mut path in route.paths {
3507+
// If the last hop was provided by route hint we assume it's not an announced channel.
3508+
// If furthermore only a single route hint is provided we refrain from probing through
3509+
// all the way to the end and instead probe up to the second-to-last channel.
3510+
if let Payee::Clear { node_id, ref route_hints, .. } = route_params.payment_params.payee {
3511+
if route_hints.len() == 1 {
3512+
if path.hops.last().map(|h| h.pubkey) == Some(node_id) {
3513+
let final_value_msat = path.final_value_msat();
3514+
path.hops.pop();
3515+
if let Some(mut new_last) = path.hops.iter_mut().last() {
3516+
new_last.fee_msat += final_value_msat;
3517+
}
3518+
}
3519+
}
3520+
}
3521+
35073522
if path.hops.len() + path.blinded_tail.as_ref().map_or(0, |t| t.hops.len()) < 2 {
35083523
log_debug!(
35093524
self.logger,

0 commit comments

Comments
 (0)