Skip to content

Commit 30e47ca

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 cdb8772 commit 30e47ca

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3539,7 +3539,29 @@ where
35393539
let mut used_liquidity_map = HashMap::with_capacity(first_hops.len());
35403540

35413541
let mut res = Vec::new();
3542-
for path in route.paths {
3542+
3543+
for mut path in route.paths {
3544+
// If the last hop is probably an unannounced channel we refrain from probing all the
3545+
// way through to the end and instead probe up to the second-to-last channel.
3546+
while let Some(last_path_hop) = path.hops.last() {
3547+
if last_path_hop.maybe_announced_channel {
3548+
// We found a potentially announced last hop.
3549+
break;
3550+
} else {
3551+
// Drop the last hop, as it's likely unannounced.
3552+
log_debug!(
3553+
self.logger,
3554+
"Avoided sending payment probe all the way to last hop {} as it is likely unannounced.",
3555+
last_path_hop.short_channel_id
3556+
);
3557+
let final_value_msat = path.final_value_msat();
3558+
path.hops.pop();
3559+
if let Some(new_last) = path.hops.last_mut() {
3560+
new_last.fee_msat += final_value_msat;
3561+
}
3562+
}
3563+
}
3564+
35433565
if path.hops.len() < 2 {
35443566
log_debug!(
35453567
self.logger,

0 commit comments

Comments
 (0)