Skip to content

Commit e88c721

Browse files
committed
Add mpp_timeout and invalid_onion_payload descriptions & handling
1 parent 09714e6 commit e88c721

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

lightning/src/ln/onion_route_tests.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,4 +563,13 @@ fn test_onion_failure() {
563563
msg.cltv_expiry = htlc_cltv;
564564
msg.onion_routing_packet = onion_packet;
565565
}, ||{}, true, Some(21), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: true}), Some(route.paths[0][0].short_channel_id));
566+
567+
run_onion_failure_test_with_fail_intercept("mpp_timeout", 200, &nodes, &route, &payment_hash, &payment_secret, |_msg| {}, |msg| {
568+
// Tamper returning error message
569+
let session_priv = SecretKey::from_slice(&[3; 32]).unwrap();
570+
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
571+
msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], 23, &[0;0]);
572+
}, ||{
573+
nodes[2].node.fail_htlc_backwards(&payment_hash);
574+
}, true, Some(23), None, None);
566575
}

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
380380
// indicate that payment parameter has failed and no need to
381381
// update Route object
382382
let payment_failed = match error_code & 0xff {
383-
15|16|17|18|19 => true,
383+
15|16|17|18|19|23 => true,
384384
_ => false,
385385
} && is_from_final_node; // PERM bit observed below even if this error is from the intermediate nodes
386386

lightning/src/util/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ pub(crate) fn get_onion_error_description(error_code: u16) -> (&'static str, &'s
119119
_c if _c == 19 => ("The final node indicated the amount in the HTLC does not match the value in the onion", "final_incorrect_htlc_amount"),
120120
_c if _c == UPDATE|20 => ("Node indicated the outbound channel has been disabled", "channel_disabled"),
121121
_c if _c == 21 => ("Node indicated the CLTV expiry in the HTLC is too far in the future", "expiry_too_far"),
122+
_c if _c == PERM|22 => ("Node indicated that the decrypted onion per-hop payload was not understood by it or is incomplete", "invalid_onion_payload"),
123+
_c if _c == 23 => ("The final node indicated the complete amount of the multi-part payment was not received within a reasonable time", "mpp_timeout"),
122124
_ => ("Unknown", ""),
123125
}
124126
}

0 commit comments

Comments
 (0)