Skip to content

Commit 59dc83f

Browse files
committed
f: fix edge case only when trampoline is also receiver
1 parent cfbade2 commit 59dc83f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,6 @@ fn test_trampoline_forward_rejection() {
29582958
// Expect UnknownNextPeer error while we are unable to route forwarding Trampoline payments.
29592959
let payment_failed_conditions = PaymentFailedConditions::new()
29602960
.expected_htlc_error_data(LocalHTLCFailureReason::UnknownNextPeer, &[0; 0]);
2961-
expect_payment_failed_conditions(&nodes[0], payment_hash, true, payment_failed_conditions);
2961+
expect_payment_failed_conditions(&nodes[0], payment_hash, false, payment_failed_conditions);
29622962
}
29632963
}

lightning/src/ln/onion_utils.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,8 @@ where
11071107
// Keep track of the first hop for which the attribution data failed to check out.
11081108
let mut attribution_failed_channel = None;
11091109

1110+
let trampoline_hop_count = path.blinded_tail.as_ref().map_or(0, |bt| bt.trampoline_hops.len());
1111+
11101112
// Handle packed channel/node updates for passing back for the route handler
11111113
let mut iter = nontrampolines.chain(trampolines.into_iter().flatten()).enumerate().peekable();
11121114
while let Some((route_hop_idx, (route_hop_option, shared_secret))) = iter.next() {
@@ -1373,17 +1375,19 @@ where
13731375
short_channel_id = route_hop.short_channel_id()
13741376
}
13751377

1376-
// If next hop is from a trampoline we are already inside the trampoline
1377-
// route. If we found a permanent failure inside the trampoline route, we
1378-
// fail the payment permanently.
1378+
// If next hop is from a trampoline and there is only one trampoline hop
1379+
// in the trampoline route, means that the trampoline hop is also a
1380+
// final non-blinded node.
13791381
let is_next_hop_from_trampoline =
13801382
matches!(next_hop, Some((_, (Some(ErrorHop::TrampolineHop(..)), _))));
1383+
if is_next_hop_from_trampoline && trampoline_hop_count == 1 {
1384+
is_from_final_non_blinded_node = true;
1385+
}
13811386

13821387
res = Some(FailureLearnings {
13831388
network_update,
13841389
short_channel_id,
1385-
payment_failed_permanently: error_code.is_permanent()
1386-
&& (is_from_final_non_blinded_node || is_next_hop_from_trampoline),
1390+
payment_failed_permanently: error_code.is_permanent() && is_from_final_non_blinded_node,
13871391
failed_within_blinded_path: false,
13881392
});
13891393

0 commit comments

Comments
 (0)