@@ -943,6 +943,7 @@ fn decrypt_onion_error_packet(packet: &mut Vec<u8>, shared_secret: SharedSecret)
943
943
#[ inline]
944
944
pub ( super ) fn process_onion_failure < T : secp256k1:: Signing , L : Deref > (
945
945
secp_ctx : & Secp256k1 < T > , logger : & L , htlc_source : & HTLCSource , mut encrypted_packet : Vec < u8 > ,
946
+ secondary_session_priv : Option < SecretKey > ,
946
947
) -> DecodedOnionFailure
947
948
where
948
949
L :: Target : Logger ,
@@ -1004,8 +1005,10 @@ where
1004
1005
1005
1006
let outer_session_priv = path. has_trampoline_hops ( ) . then ( || {
1006
1007
// if we have Trampoline hops, the outer onion session_priv is a hash of the inner one
1007
- let session_priv_hash = Sha256 :: hash ( & session_priv. secret_bytes ( ) ) . to_byte_array ( ) ;
1008
- SecretKey :: from_slice ( & session_priv_hash[ ..] ) . expect ( "You broke SHA-256!" )
1008
+ secondary_session_priv. unwrap_or_else ( || {
1009
+ let session_priv_hash = Sha256 :: hash ( & session_priv. secret_bytes ( ) ) . to_byte_array ( ) ;
1010
+ SecretKey :: from_slice ( & session_priv_hash[ ..] ) . expect ( "You broke SHA-256!" )
1011
+ } )
1009
1012
} ) ;
1010
1013
1011
1014
let mut onion_keys = Vec :: with_capacity ( path. hops . len ( ) ) ;
@@ -1465,7 +1468,7 @@ impl HTLCFailReason {
1465
1468
{
1466
1469
match self . 0 {
1467
1470
HTLCFailReasonRepr :: LightningError { ref err } => {
1468
- process_onion_failure ( secp_ctx, logger, & htlc_source, err. data . clone ( ) )
1471
+ process_onion_failure ( secp_ctx, logger, & htlc_source, err. data . clone ( ) , None )
1469
1472
} ,
1470
1473
#[ allow( unused) ]
1471
1474
HTLCFailReasonRepr :: Reason { ref failure_code, ref data, .. } => {
@@ -2405,7 +2408,7 @@ mod tests {
2405
2408
2406
2409
// Assert that the original failure can be retrieved and that all hmacs check out.
2407
2410
let decrypted_failure =
2408
- process_onion_failure ( & ctx_full, & logger, & htlc_source, onion_packet_5. data ) ;
2411
+ process_onion_failure ( & ctx_full, & logger, & htlc_source, onion_packet_5. data , None ) ;
2409
2412
2410
2413
assert_eq ! ( decrypted_failure. onion_error_code, Some ( 0x2002 ) ) ;
2411
2414
}
@@ -2491,7 +2494,7 @@ mod tests {
2491
2494
} ;
2492
2495
2493
2496
let decrypted_failure =
2494
- process_onion_failure ( & ctx_full, & logger, & htlc_source, packet. into ( ) ) ;
2497
+ process_onion_failure ( & ctx_full, & logger, & htlc_source, packet. into ( ) , None ) ;
2495
2498
2496
2499
decrypted_failure
2497
2500
}
0 commit comments