Skip to content

Commit 3188095

Browse files
committed
ln/fix: return invalid payload for final hop trampoline with blinding
As is, we're returning an `invalid_onion_blinding` error with no associated data, because the calling code does not attach any data when we have a `OnionDecodeErr::Relay` error. This is arguably not the correct error code anyway, as described below, so this commit updates it to `invalid_onion_payload` which does not require additional error data. In this case, we have received a trampoline payload which we believe should contain details of the next trampoline hop. This information is missing, so we've received an invalid payload. When a blinding point point is present in the payload, we're also the introduction node. BOLT04 indicates that if this `current_path_key` is present and we are the final hop we should return a regular error (rather than using `invalid_onion_blinding` when you're the the final hop). Before this commit, this code was considering our node to be non-final and returning an error accordingly. Our role as the final hop is ambiguous here - we are the final hop in the sphinx packet, but the trampoline packet implies that there should be more hops to come. Given that the trampoline packet is invalid, we defer to our position in the sphinx packet and send back an invalid payload error instead.
1 parent b7dec5c commit 3188095

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lightning/src/ln/blinded_payment_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@ fn do_test_trampoline_single_hop_receive(success: bool) {
21602160
}
21612161
{
21622162
let payment_failed_conditions = PaymentFailedConditions::new()
2163-
.expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 0]);
2163+
.expected_htlc_error_data(0x4000 | 22, &[0; 0]);
21642164
expect_payment_failed_conditions(&nodes[0], payment_hash, true, payment_failed_conditions);
21652165
}
21662166
}

lightning/src/ln/onion_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ where
18371837
if hop_data.intro_node_blinding_point.is_some() {
18381838
return Err(OnionDecodeErr::Relay {
18391839
err_msg: "Non-final intro node Trampoline onion data provided to us as last hop",
1840-
err_code: INVALID_ONION_BLINDING,
1840+
err_code: 0x4000 | 22,
18411841
shared_secret,
18421842
trampoline_shared_secret: Some(SharedSecret::from_bytes(
18431843
trampoline_shared_secret,

0 commit comments

Comments
 (0)