Skip to content

Commit 30e81a9

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

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,17 +1373,20 @@ where
13731373
short_channel_id = route_hop.short_channel_id()
13741374
}
13751375

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.
1379-
let is_next_hop_from_trampoline =
1376+
// If next hop is from a trampoline and there is only one trampoline hop
1377+
// in the trampoline route, means that the trampoline hop is also a
1378+
// final non-blinded node.
1379+
let is_next_hop_trampoline =
13801380
matches!(next_hop, Some((_, (Some(ErrorHop::TrampolineHop(..)), _))));
1381+
if is_next_hop_trampoline {
1382+
is_from_final_non_blinded_node =
1383+
path.blinded_tail.as_ref().map_or(0, |bt| bt.trampoline_hops.len()) == 1
1384+
}
13811385

13821386
res = Some(FailureLearnings {
13831387
network_update,
13841388
short_channel_id,
1385-
payment_failed_permanently: error_code.is_permanent()
1386-
&& (is_from_final_non_blinded_node || is_next_hop_from_trampoline),
1389+
payment_failed_permanently: error_code.is_permanent() && is_from_final_non_blinded_node,
13871390
failed_within_blinded_path: false,
13881391
});
13891392

0 commit comments

Comments
 (0)