@@ -485,16 +485,19 @@ where
485485 Ok ( match hop {
486486 onion_utils:: Hop :: Forward { shared_secret, .. } |
487487 onion_utils:: Hop :: BlindedForward { shared_secret, .. } => {
488- let NextPacketDetails {
489- next_packet_pubkey, outgoing_amt_msat : _, outgoing_connector : _, outgoing_cltv_value
490- } = match next_packet_details_opt {
491- Some ( next_packet_details) => next_packet_details,
488+ let ( next_packet_pubkey, outgoing_cltv_value) = match next_packet_details_opt {
489+ Some ( NextPacketDetails {
490+ next_packet_pubkey,
491+ forward_info : Some ( ForwardInfo { outgoing_cltv_value, .. } ) ,
492+ } ) => ( next_packet_pubkey, outgoing_cltv_value) ,
492493 // Forward should always include the next hop details
493- None => return Err ( InboundHTLCErr {
494- msg : "Failed to decode update add htlc onion" ,
495- reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
496- err_data : Vec :: new ( ) ,
497- } ) ,
494+ _ => {
495+ return Err ( InboundHTLCErr {
496+ msg : "Failed to decode update add htlc onion" ,
497+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
498+ err_data : Vec :: new ( ) ,
499+ } ) ;
500+ }
498501 } ;
499502
500503 if let Err ( reason) = check_incoming_htlc_cltv (
@@ -532,6 +535,10 @@ pub(super) enum HopConnector {
532535
533536pub ( super ) struct NextPacketDetails {
534537 pub ( super ) next_packet_pubkey : Result < PublicKey , secp256k1:: Error > ,
538+ pub ( super ) forward_info : Option < ForwardInfo > ,
539+ }
540+
541+ pub ( super ) struct ForwardInfo {
535542 pub ( super ) outgoing_connector : HopConnector ,
536543 pub ( super ) outgoing_amt_msat : u64 ,
537544 pub ( super ) outgoing_cltv_value : u32 ,
@@ -608,8 +615,12 @@ where
608615 let next_packet_pubkey = onion_utils:: next_hop_pubkey ( secp_ctx,
609616 msg. onion_routing_packet . public_key . unwrap ( ) , & shared_secret. secret_bytes ( ) ) ;
610617 Some ( NextPacketDetails {
611- next_packet_pubkey, outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) ,
612- outgoing_amt_msat : amt_to_forward, outgoing_cltv_value
618+ next_packet_pubkey,
619+ forward_info : Some ( ForwardInfo {
620+ outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) ,
621+ outgoing_amt_msat : amt_to_forward,
622+ outgoing_cltv_value,
623+ } ) ,
613624 } )
614625 }
615626 onion_utils:: Hop :: BlindedForward { next_hop_data : msgs:: InboundOnionBlindedForwardPayload { short_channel_id, ref payment_relay, ref payment_constraints, ref features, .. } , shared_secret, .. } => {
@@ -625,19 +636,31 @@ where
625636 let next_packet_pubkey = onion_utils:: next_hop_pubkey ( & secp_ctx,
626637 msg. onion_routing_packet . public_key . unwrap ( ) , & shared_secret. secret_bytes ( ) ) ;
627638 Some ( NextPacketDetails {
628- next_packet_pubkey, outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) , outgoing_amt_msat : amt_to_forward,
629- outgoing_cltv_value
639+ next_packet_pubkey,
640+ forward_info : Some ( ForwardInfo {
641+ outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) ,
642+ outgoing_amt_msat : amt_to_forward,
643+ outgoing_cltv_value,
644+ } ) ,
630645 } )
631646 }
632647 onion_utils:: Hop :: TrampolineForward { next_trampoline_hop_data : msgs:: InboundTrampolineForwardPayload { amt_to_forward, outgoing_cltv_value, next_trampoline } , trampoline_shared_secret, incoming_trampoline_public_key, .. } => {
633648 let next_trampoline_packet_pubkey = onion_utils:: next_hop_pubkey ( secp_ctx,
634649 incoming_trampoline_public_key, & trampoline_shared_secret. secret_bytes ( ) ) ;
635650 Some ( NextPacketDetails {
636651 next_packet_pubkey : next_trampoline_packet_pubkey,
637- outgoing_connector : HopConnector :: Trampoline ( next_trampoline) ,
638- outgoing_amt_msat : amt_to_forward,
639- outgoing_cltv_value,
652+ forward_info : Some ( ForwardInfo {
653+ outgoing_connector : HopConnector :: Trampoline ( next_trampoline) ,
654+ outgoing_amt_msat : amt_to_forward,
655+ outgoing_cltv_value,
656+ } ) ,
640657 } )
658+ } ,
659+ onion_utils:: Hop :: Dummy { shared_secret, .. } => {
660+ let next_packet_pubkey = onion_utils:: next_hop_pubkey ( secp_ctx,
661+ msg. onion_routing_packet . public_key . unwrap ( ) , & shared_secret. secret_bytes ( ) ) ;
662+
663+ Some ( NextPacketDetails { next_packet_pubkey, forward_info : None } )
641664 }
642665 _ => None
643666 } ;
0 commit comments