Skip to content

Commit 7934c44

Browse files
committed
f Consider RouteHop::announced to avoid probing all the way
1 parent 4555f8c commit 7934c44

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,18 +3541,20 @@ where
35413541
let mut res = Vec::new();
35423542

35433543
for mut path in route.paths {
3544-
// If the last hop was provided by route hint we assume it's not an announced channel.
3545-
// If furthermore only a single route hint is provided we refrain from probing through
3546-
// all the way to the end and instead probe up to the second-to-last channel.
3547-
if let Payee::Clear { node_id, ref route_hints, .. } = route_params.payment_params.payee {
3548-
if route_hints.len() == 1 {
3549-
if let Some(hint) = route_hints[0].0.iter().last() {
3550-
if let Some(last_path_hop) = path.hops.last() {
3551-
if last_path_hop.pubkey == node_id && last_path_hop.short_channel_id == hint.short_channel_id {
3552-
let final_value_msat = path.final_value_msat();
3553-
path.hops.pop();
3554-
if let Some(mut new_last) = path.hops.iter_mut().last() {
3555-
new_last.fee_msat += final_value_msat;
3544+
// If the last hop is not an announced channel, and only a single route hint was
3545+
// provided, we refrain from probing all the way through to the end and instead probe
3546+
// up to the second-to-last channel.
3547+
if let Some(last_path_hop) = path.hops.last() {
3548+
if !last_path_hop.announced {
3549+
if let Payee::Clear { node_id, ref route_hints, .. } = route_params.payment_params.payee {
3550+
if route_hints.len() == 1 {
3551+
if let Some(hint) = route_hints[0].0.iter().last() {
3552+
if last_path_hop.pubkey == node_id && last_path_hop.short_channel_id == hint.short_channel_id {
3553+
let final_value_msat = path.final_value_msat();
3554+
path.hops.pop();
3555+
if let Some(new_last) = path.hops.iter_mut().last() {
3556+
new_last.fee_msat += final_value_msat;
3557+
}
35563558
}
35573559
}
35583560
}

0 commit comments

Comments
 (0)