Skip to content

Commit f9bbcf0

Browse files
Set error code and friends when processing an error within a blinded path
We don't bother actually parsing errors from within a blinded path, since all errors should be wiped by the introduction node by the time it gets back to us (the sender).
1 parent c6b142e commit f9bbcf0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lightning/src/ln/onion_utils.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ where L::Target: Logger {
413413
let mut error_packet_ret = None;
414414
let mut is_from_final_node = false;
415415

416+
const BADONION: u16 = 0x8000;
417+
const PERM: u16 = 0x4000;
418+
const NODE: u16 = 0x2000;
419+
const UPDATE: u16 = 0x1000;
420+
416421
// Handle packed channel/node updates for passing back for the route handler
417422
construct_onion_keys_callback(secp_ctx, &path, session_priv,
418423
|shared_secret, _, _, route_hop_opt, route_hop_idx|
@@ -421,7 +426,13 @@ where L::Target: Logger {
421426

422427
let route_hop = match route_hop_opt {
423428
Some(hop) => hop,
424-
None => return,
429+
None => {
430+
// Got an error from within a blinded route.
431+
error_code_ret = Some(BADONION | PERM | 24); // invalid_onion_blinding
432+
error_packet_ret = Some(vec![0; 32]);
433+
is_from_final_node = false;
434+
return
435+
},
425436
};
426437

427438
let amt_to_forward = htlc_msat - route_hop.fee_msat;
@@ -463,10 +474,6 @@ where L::Target: Logger {
463474
return
464475
}
465476
};
466-
const BADONION: u16 = 0x8000;
467-
const PERM: u16 = 0x4000;
468-
const NODE: u16 = 0x2000;
469-
const UPDATE: u16 = 0x1000;
470477

471478
let error_code = u16::from_be_bytes(error_code_slice.try_into().expect("len is 2"));
472479
error_code_ret = Some(error_code);

0 commit comments

Comments
 (0)