@@ -469,16 +469,19 @@ where
469469 Ok ( match hop {
470470 onion_utils:: Hop :: Forward { shared_secret, .. } |
471471 onion_utils:: Hop :: BlindedForward { shared_secret, .. } => {
472- let NextPacketDetails {
473- next_packet_pubkey, outgoing_amt_msat : _, outgoing_connector : _, outgoing_cltv_value
474- } = match next_packet_details_opt {
475- Some ( next_packet_details) => next_packet_details,
472+ let ( next_packet_pubkey, outgoing_cltv_value) = match next_packet_details_opt {
473+ Some ( NextPacketDetails {
474+ next_packet_pubkey,
475+ forward_info : Some ( ForwardInfo { outgoing_cltv_value, .. } ) ,
476+ } ) => ( next_packet_pubkey, outgoing_cltv_value) ,
476477 // Forward should always include the next hop details
477- None => return Err ( InboundHTLCErr {
478- msg : "Failed to decode update add htlc onion" ,
479- reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
480- err_data : Vec :: new ( ) ,
481- } ) ,
478+ _ => {
479+ return Err ( InboundHTLCErr {
480+ msg : "Failed to decode update add htlc onion" ,
481+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
482+ err_data : Vec :: new ( ) ,
483+ } ) ;
484+ }
482485 } ;
483486
484487 if let Err ( reason) = check_incoming_htlc_cltv (
@@ -515,6 +518,10 @@ pub(super) enum HopConnector {
515518
516519pub ( super ) struct NextPacketDetails {
517520 pub ( super ) next_packet_pubkey : Result < PublicKey , secp256k1:: Error > ,
521+ pub ( super ) forward_info : Option < ForwardInfo > ,
522+ }
523+
524+ pub ( super ) struct ForwardInfo {
518525 pub ( super ) outgoing_connector : HopConnector ,
519526 pub ( super ) outgoing_amt_msat : u64 ,
520527 pub ( super ) outgoing_cltv_value : u32 ,
@@ -591,8 +598,12 @@ where
591598 let next_packet_pubkey = onion_utils:: next_hop_pubkey ( secp_ctx,
592599 msg. onion_routing_packet . public_key . unwrap ( ) , & shared_secret. secret_bytes ( ) ) ;
593600 Some ( NextPacketDetails {
594- next_packet_pubkey, outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) ,
595- outgoing_amt_msat : amt_to_forward, outgoing_cltv_value
601+ next_packet_pubkey,
602+ forward_info : Some ( ForwardInfo {
603+ outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) ,
604+ outgoing_amt_msat : amt_to_forward,
605+ outgoing_cltv_value,
606+ } ) ,
596607 } )
597608 }
598609 onion_utils:: Hop :: BlindedForward { next_hop_data : msgs:: InboundOnionBlindedForwardPayload { short_channel_id, ref payment_relay, ref payment_constraints, ref features, .. } , shared_secret, .. } => {
@@ -608,19 +619,31 @@ where
608619 let next_packet_pubkey = onion_utils:: next_hop_pubkey ( & secp_ctx,
609620 msg. onion_routing_packet . public_key . unwrap ( ) , & shared_secret. secret_bytes ( ) ) ;
610621 Some ( NextPacketDetails {
611- next_packet_pubkey, outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) , outgoing_amt_msat : amt_to_forward,
612- outgoing_cltv_value
622+ next_packet_pubkey,
623+ forward_info : Some ( ForwardInfo {
624+ outgoing_connector : HopConnector :: ShortChannelId ( short_channel_id) ,
625+ outgoing_amt_msat : amt_to_forward,
626+ outgoing_cltv_value,
627+ } ) ,
613628 } )
614629 }
615630 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, .. } => {
616631 let next_trampoline_packet_pubkey = onion_utils:: next_hop_pubkey ( secp_ctx,
617632 incoming_trampoline_public_key, & trampoline_shared_secret. secret_bytes ( ) ) ;
618633 Some ( NextPacketDetails {
619634 next_packet_pubkey : next_trampoline_packet_pubkey,
620- outgoing_connector : HopConnector :: Trampoline ( next_trampoline) ,
621- outgoing_amt_msat : amt_to_forward,
622- outgoing_cltv_value,
635+ forward_info : Some ( ForwardInfo {
636+ outgoing_connector : HopConnector :: Trampoline ( next_trampoline) ,
637+ outgoing_amt_msat : amt_to_forward,
638+ outgoing_cltv_value,
639+ } ) ,
623640 } )
641+ } ,
642+ onion_utils:: Hop :: Dummy { shared_secret, .. } => {
643+ let next_packet_pubkey = onion_utils:: next_hop_pubkey ( secp_ctx,
644+ msg. onion_routing_packet . public_key . unwrap ( ) , & shared_secret. secret_bytes ( ) ) ;
645+
646+ Some ( NextPacketDetails { next_packet_pubkey, forward_info : None } )
624647 }
625648 _ => None
626649 } ;
0 commit comments