@@ -474,10 +474,10 @@ where
474474 L :: Target : Logger ,
475475{
476476 macro_rules! return_malformed_err {
477- ( $msg: expr, $err_code: expr) => {
477+ ( $msg: expr, $err_code: expr, $force_blinding_error : expr ) => {
478478 {
479479 log_info!( logger, "Failed to accept/forward incoming HTLC: {}" , $msg) ;
480- let ( sha256_of_onion, failure_code) = if msg. blinding_point. is_some( ) {
480+ let ( sha256_of_onion, failure_code) = if $force_blinding_error || msg. blinding_point. is_some( ) {
481481 ( [ 0 ; 32 ] , INVALID_ONION_BLINDING )
482482 } else {
483483 ( Sha256 :: hash( & msg. onion_routing_packet. hop_data) . to_byte_array( ) , $err_code)
@@ -493,7 +493,7 @@ where
493493 }
494494
495495 if let Err ( _) = msg. onion_routing_packet . public_key {
496- return_malformed_err ! ( "invalid ephemeral pubkey" , 0x8000 | 0x4000 | 6 ) ;
496+ return_malformed_err ! ( "invalid ephemeral pubkey" , 0x8000 | 0x4000 | 6 , false ) ;
497497 }
498498
499499 if msg. onion_routing_packet . version != 0 {
@@ -503,12 +503,12 @@ where
503503 //receiving node would have to brute force to figure out which version was put in the
504504 //packet by the node that send us the message, in the case of hashing the hop_data, the
505505 //node knows the HMAC matched, so they already know what is there...
506- return_malformed_err ! ( "Unknown onion packet version" , 0x8000 | 0x4000 | 4 ) ;
506+ return_malformed_err ! ( "Unknown onion packet version" , 0x8000 | 0x4000 | 4 , false ) ;
507507 }
508508
509509 let encode_relay_error = |message : & str , err_code : u16 , shared_secret : [ u8 ; 32 ] , trampoline_shared_secret : Option < [ u8 ; 32 ] > , data : & [ u8 ] | {
510510 if msg. blinding_point . is_some ( ) {
511- return_malformed_err ! ( message, INVALID_ONION_BLINDING )
511+ return_malformed_err ! ( message, INVALID_ONION_BLINDING , false )
512512 }
513513
514514 log_info ! ( logger, "Failed to accept/forward incoming HTLC: {}" , message) ;
@@ -526,8 +526,8 @@ where
526526 msg. payment_hash , msg. blinding_point , node_signer
527527 ) {
528528 Ok ( res) => res,
529- Err ( onion_utils:: OnionDecodeErr :: Malformed { err_msg, err_code } ) => {
530- return_malformed_err ! ( err_msg, err_code) ;
529+ Err ( onion_utils:: OnionDecodeErr :: Malformed { err_msg, err_code, trampoline_onion_blinding } ) => {
530+ return_malformed_err ! ( err_msg, err_code, trampoline_onion_blinding ) ;
531531 } ,
532532 Err ( onion_utils:: OnionDecodeErr :: Relay { err_msg, err_code, shared_secret, trampoline_shared_secret } ) => {
533533 return encode_relay_error ( err_msg, err_code, shared_secret. secret_bytes ( ) , trampoline_shared_secret. map ( |tss| tss. secret_bytes ( ) ) , & [ 0 ; 0 ] ) ;
0 commit comments