@@ -1469,12 +1469,12 @@ impl Hop {
14691469 }
14701470 }
14711471
1472- pub ( crate ) fn shared_secret ( & self ) -> SharedSecret {
1472+ pub ( crate ) fn shared_secret ( & self ) -> & SharedSecret {
14731473 match self {
1474- Hop :: Forward { shared_secret, .. } => shared_secret. clone ( ) ,
1475- Hop :: BlindedForward { shared_secret, .. } => shared_secret. clone ( ) ,
1476- Hop :: Receive { shared_secret, .. } => shared_secret. clone ( ) ,
1477- Hop :: BlindedReceive { shared_secret, .. } => shared_secret. clone ( ) ,
1474+ Hop :: Forward { shared_secret, .. } => shared_secret,
1475+ Hop :: BlindedForward { shared_secret, .. } => shared_secret,
1476+ Hop :: Receive { shared_secret, .. } => shared_secret,
1477+ Hop :: BlindedReceive { shared_secret, .. } => shared_secret,
14781478 }
14791479 }
14801480}
@@ -1503,11 +1503,10 @@ where
15031503 } ) ;
15041504 let shared_secret = node_signer
15051505 . ecdh ( recipient, hop_pubkey, blinded_node_id_tweak. as_ref ( ) )
1506- . unwrap ( )
1507- . secret_bytes ( ) ;
1506+ . unwrap ( ) ;
15081507
15091508 let decoded_hop: Result < ( msgs:: InboundOnionPayload , Option < _ > ) , _ > = decode_next_hop (
1510- shared_secret,
1509+ shared_secret. secret_bytes ( ) ,
15111510 hop_data,
15121511 hmac_bytes,
15131512 Some ( payment_hash) ,
@@ -1517,14 +1516,14 @@ where
15171516 Ok ( ( next_hop_data, Some ( ( next_hop_hmac, FixedSizeOnionPacket ( new_packet_bytes) ) ) ) ) => {
15181517 match next_hop_data {
15191518 msgs:: InboundOnionPayload :: Forward ( next_hop_data) => Ok ( Hop :: Forward {
1520- shared_secret : SharedSecret :: from_bytes ( shared_secret ) ,
1519+ shared_secret,
15211520 next_hop_data,
15221521 next_hop_hmac,
15231522 new_packet_bytes,
15241523 } ) ,
15251524 msgs:: InboundOnionPayload :: BlindedForward ( next_hop_data) => {
15261525 Ok ( Hop :: BlindedForward {
1527- shared_secret : SharedSecret :: from_bytes ( shared_secret ) ,
1526+ shared_secret,
15281527 next_hop_data,
15291528 next_hop_hmac,
15301529 new_packet_bytes,
@@ -1541,18 +1540,18 @@ where
15411540 Err ( OnionDecodeErr :: Relay {
15421541 err_msg : "Final Node OnionHopData provided for us as an intermediary node" ,
15431542 err_code : 0x4000 | 22 ,
1544- shared_secret : SharedSecret :: from_bytes ( shared_secret ) ,
1543+ shared_secret,
15451544 } )
15461545 } ,
15471546 }
15481547 } ,
15491548 Ok ( ( next_hop_data, None ) ) => match next_hop_data {
15501549 msgs:: InboundOnionPayload :: Receive ( hop_data) => Ok ( Hop :: Receive {
1551- shared_secret : SharedSecret :: from_bytes ( shared_secret ) ,
1550+ shared_secret,
15521551 hop_data,
15531552 } ) ,
15541553 msgs:: InboundOnionPayload :: BlindedReceive ( hop_data) => Ok ( Hop :: BlindedReceive {
1555- shared_secret : SharedSecret :: from_bytes ( shared_secret ) ,
1554+ shared_secret,
15561555 hop_data,
15571556 } ) ,
15581557 _ => {
@@ -1565,7 +1564,7 @@ where
15651564 Err ( OnionDecodeErr :: Relay {
15661565 err_msg : "Intermediate Node OnionHopData provided for us as a final node" ,
15671566 err_code : 0x4000 | 22 ,
1568- shared_secret : SharedSecret :: from_bytes ( shared_secret ) ,
1567+ shared_secret,
15691568 } )
15701569 } ,
15711570 } ,
0 commit comments