Skip to content

Commit

Permalink
Probe up to second-to-last hop if last was provided by route hint
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
tnull committed Sep 12, 2023
1 parent e841fc4 commit a86fab5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3535,7 +3535,27 @@ where
let mut used_liquidity_map = HashMap::with_capacity(first_hops.len());

let mut res = Vec::new();
for path in route.paths {

for mut path in route.paths {
// 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.
if let Payee::Clear { node_id, ref route_hints, .. } = route_params.payment_params.payee {
if route_hints.len() == 1 {
if let Some(hint) = route_hints[0].0.iter().last() {
if let Some(last_path_hop) = path.hops.last() {
if last_path_hop.pubkey == node_id && last_path_hop.short_channel_id == hint.short_channel_id {
let final_value_msat = path.final_value_msat();
path.hops.pop();
if let Some(mut new_last) = path.hops.iter_mut().last() {
new_last.fee_msat += final_value_msat;
}
}
}
}
}
}

if path.hops.len() < 2 {
log_debug!(
self.logger,
Expand Down

0 comments on commit a86fab5

Please sign in to comment.