Skip to content

(1/3) Minor error code fixes #3699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lightning/src/ln/blinded_payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ fn do_test_trampoline_single_hop_receive(success: bool) {
}
{
let payment_failed_conditions = PaymentFailedConditions::new()
.expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 0]);
.expected_htlc_error_data(0x4000 | 22, &[0; 0]);
expect_payment_failed_conditions(&nodes[0], payment_hash, true, payment_failed_conditions);
}
}
Expand Down
10 changes: 5 additions & 5 deletions lightning/src/ln/onion_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,8 +1431,7 @@ impl HTLCFailReason {
const NODE: u16 = 0x2000;
const UPDATE: u16 = 0x1000;

if failure_code == 1 | PERM { debug_assert!(data.is_empty()) }
else if failure_code == 2 | NODE { debug_assert!(data.is_empty()) }
if failure_code == 2 | NODE { debug_assert!(data.is_empty()) }
else if failure_code == 2 | PERM | NODE { debug_assert!(data.is_empty()) }
else if failure_code == 3 | PERM | NODE { debug_assert!(data.is_empty()) }
else if failure_code == 4 | BADONION | PERM { debug_assert_eq!(data.len(), 32) }
Expand All @@ -1459,6 +1458,7 @@ impl HTLCFailReason {
else if failure_code == 21 { debug_assert!(data.is_empty()) }
else if failure_code == 22 | PERM { debug_assert!(data.len() <= 11) }
else if failure_code == 23 { debug_assert!(data.is_empty()) }
else if failure_code == INVALID_ONION_BLINDING { debug_assert_eq!(data.len(), 32) }
else if failure_code & BADONION != 0 {
// We set some bogus BADONION failure codes in test, so ignore unknown ones.
}
Expand Down Expand Up @@ -1838,7 +1838,7 @@ where
if hop_data.intro_node_blinding_point.is_some() {
return Err(OnionDecodeErr::Relay {
err_msg: "Non-final intro node Trampoline onion data provided to us as last hop",
err_code: INVALID_ONION_BLINDING,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch here!

err_code: 0x4000 | 22,
shared_secret,
trampoline_shared_secret: Some(SharedSecret::from_bytes(
trampoline_shared_secret,
Expand Down Expand Up @@ -2038,8 +2038,8 @@ fn decode_next_hop<T, R: ReadableArgs<T>, N: NextPacketBytes>(
match R::read(&mut chacha_stream, read_args) {
Err(err) => {
let error_code = match err {
// Unknown realm byte
msgs::DecodeError::UnknownVersion => 0x4000 | 1,
// Unknown version
msgs::DecodeError::UnknownVersion => 0x8000 | 0x4000 | 4,
// invalid_onion_payload
msgs::DecodeError::UnknownRequiredFeature
| msgs::DecodeError::InvalidValue
Expand Down
Loading