@@ -2510,12 +2510,12 @@ where
25102510 }
25112511
25122512 #[ cfg( test) ]
2513- pub ( crate ) fn test_send_payment_along_path ( & self , path : & Vec < RouteHop > , payment_hash : & PaymentHash , payment_secret : & Option < PaymentSecret > , total_value : u64 , cur_height : u32 , payment_id : PaymentId , keysend_preimage : & Option < PaymentPreimage > , session_priv_bytes : [ u8 ; 32 ] ) -> Result < ( ) , APIError > {
2513+ pub ( crate ) fn test_send_payment_along_path ( & self , path : & Vec < RouteHop > , payment_hash : & PaymentHash , recipient_onion : RecipientOnionFields , total_value : u64 , cur_height : u32 , payment_id : PaymentId , keysend_preimage : & Option < PaymentPreimage > , session_priv_bytes : [ u8 ; 32 ] ) -> Result < ( ) , APIError > {
25142514 let _lck = self . total_consistency_lock . read ( ) . unwrap ( ) ;
2515- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2515+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
25162516 }
25172517
2518- fn send_payment_along_path ( & self , path : & Vec < RouteHop > , payment_hash : & PaymentHash , payment_secret : & Option < PaymentSecret > , total_value : u64 , cur_height : u32 , payment_id : PaymentId , keysend_preimage : & Option < PaymentPreimage > , session_priv_bytes : [ u8 ; 32 ] ) -> Result < ( ) , APIError > {
2518+ fn send_payment_along_path ( & self , path : & Vec < RouteHop > , payment_hash : & PaymentHash , recipient_onion : RecipientOnionFields , total_value : u64 , cur_height : u32 , payment_id : PaymentId , keysend_preimage : & Option < PaymentPreimage > , session_priv_bytes : [ u8 ; 32 ] ) -> Result < ( ) , APIError > {
25192519 // The top-level caller should hold the total_consistency_lock read lock.
25202520 debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
25212521
@@ -2525,7 +2525,7 @@ where
25252525
25262526 let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
25272527 . map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" . to_owned ( ) } ) ?;
2528- let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret , cur_height, keysend_preimage) ?;
2528+ let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, recipient_onion , cur_height, keysend_preimage) ?;
25292529 if onion_utils:: route_size_insane ( & onion_payloads) {
25302530 return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
25312531 }
@@ -2646,9 +2646,9 @@ where
26462646 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
26472647 let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
26482648 self . pending_outbound_payments
2649- . send_payment_with_route ( route, payment_hash, & recipient_onion. payment_secret , payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2650- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2651- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2649+ . send_payment_with_route ( route, payment_hash, recipient_onion, payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2650+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2651+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
26522652 }
26532653
26542654 /// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2657,27 +2657,27 @@ where
26572657 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
26582658 let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
26592659 self . pending_outbound_payments
2660- . send_payment ( payment_hash, & recipient_onion. payment_secret , payment_id, retry_strategy, route_params,
2660+ . send_payment ( payment_hash, recipient_onion, payment_id, retry_strategy, route_params,
26612661 & self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
26622662 & self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
26632663 & self . pending_events ,
2664- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2665- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2664+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2665+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
26662666 }
26672667
26682668 #[ cfg( test) ]
2669- pub ( super ) fn test_send_payment_internal ( & self , route : & Route , payment_hash : PaymentHash , payment_secret : & Option < PaymentSecret > , keysend_preimage : Option < PaymentPreimage > , payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : Vec < [ u8 ; 32 ] > ) -> Result < ( ) , PaymentSendFailure > {
2669+ pub ( super ) fn test_send_payment_internal ( & self , route : & Route , payment_hash : PaymentHash , recipient_onion : RecipientOnionFields , keysend_preimage : Option < PaymentPreimage > , payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : Vec < [ u8 ; 32 ] > ) -> Result < ( ) , PaymentSendFailure > {
26702670 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
26712671 let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2672- self . pending_outbound_payments . test_send_payment_internal ( route, payment_hash, payment_secret , keysend_preimage, payment_id, recv_value_msat, onion_session_privs, & self . node_signer , best_block_height,
2673- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2674- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2672+ self . pending_outbound_payments . test_send_payment_internal ( route, payment_hash, recipient_onion , keysend_preimage, payment_id, recv_value_msat, onion_session_privs, & self . node_signer , best_block_height,
2673+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2674+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
26752675 }
26762676
26772677 #[ cfg( test) ]
2678- pub ( crate ) fn test_add_new_pending_payment ( & self , payment_hash : PaymentHash , payment_secret : Option < PaymentSecret > , payment_id : PaymentId , route : & Route ) -> Result < Vec < [ u8 ; 32 ] > , PaymentSendFailure > {
2678+ pub ( crate ) fn test_add_new_pending_payment ( & self , payment_hash : PaymentHash , recipient_onion : RecipientOnionFields , payment_id : PaymentId , route : & Route ) -> Result < Vec < [ u8 ; 32 ] > , PaymentSendFailure > {
26792679 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2680- self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, payment_secret , payment_id, route, None , & self . entropy_source , best_block_height)
2680+ self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, recipient_onion , payment_id, route, None , & self . entropy_source , best_block_height)
26812681 }
26822682
26832683
@@ -2721,10 +2721,10 @@ where
27212721 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
27222722 let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
27232723 self . pending_outbound_payments . send_spontaneous_payment_with_route (
2724- route, payment_preimage, payment_id , & self . entropy_source , & self . node_signer ,
2725- best_block_height,
2726- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2727- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2724+ route, payment_preimage, recipient_onion , payment_id , & self . entropy_source ,
2725+ & self . node_signer , best_block_height,
2726+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2727+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
27282728 }
27292729
27302730 /// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2737,12 +2737,12 @@ where
27372737 pub fn send_spontaneous_payment_with_retry ( & self , payment_preimage : Option < PaymentPreimage > , recipient_onion : RecipientOnionFields , payment_id : PaymentId , route_params : RouteParameters , retry_strategy : Retry ) -> Result < PaymentHash , RetryableSendFailure > {
27382738 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
27392739 let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2740- self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id ,
2741- retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2740+ self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, recipient_onion ,
2741+ payment_id , retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
27422742 || self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
27432743 & self . logger , & self . pending_events ,
2744- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2745- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2744+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2745+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
27462746 }
27472747
27482748 /// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2752,8 +2752,8 @@ where
27522752 let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
27532753 let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
27542754 self . pending_outbound_payments . send_probe ( hops, self . probing_cookie_secret , & self . entropy_source , & self . node_signer , best_block_height,
2755- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2756- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2755+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2756+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
27572757 }
27582758
27592759 /// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3490,8 +3490,8 @@ where
34903490 self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
34913491 || self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
34923492 & self . pending_events , & self . logger ,
3493- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3494- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3493+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3494+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
34953495
34963496 for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
34973497 self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8024,8 +8024,10 @@ mod tests {
80248024 // Use the utility function send_payment_along_path to send the payment with MPP data which
80258025 // indicates there are more HTLCs coming.
80268026 let cur_height = CHAN_CONFIRM_DEPTH + 1 ; // route_payment calls send_payment, which adds 1 to the current height. So we do the same here to match.
8027- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash, Some ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8028- nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash, & Some ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
8027+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash,
8028+ RecipientOnionFields :: secret_only ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8029+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash,
8030+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
80298031 check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
80308032 let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
80318033 assert_eq ! ( events. len( ) , 1 ) ;
@@ -8056,7 +8058,8 @@ mod tests {
80568058 expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
80578059
80588060 // Send the second half of the original MPP payment.
8059- nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash, & Some ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
8061+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash,
8062+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
80608063 check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
80618064 let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
80628065 assert_eq ! ( events. len( ) , 1 ) ;
@@ -8253,8 +8256,10 @@ mod tests {
82538256
82548257 let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
82558258 let mismatch_payment_hash = PaymentHash ( [ 43 ; 32 ] ) ;
8256- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash, None , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8257- nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash, & None , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8259+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash,
8260+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8261+ nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash,
8262+ RecipientOnionFields :: spontaneous_empty ( ) , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
82588263 check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
82598264
82608265 let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8296,8 +8301,11 @@ mod tests {
82968301 let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
82978302 let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
82988303 let payment_hash = PaymentHash ( Sha256 :: hash ( & test_preimage. 0 ) . into_inner ( ) ) ;
8299- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash, Some ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8300- nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash, & Some ( test_secret) , Some ( test_preimage) , PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8304+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash,
8305+ RecipientOnionFields :: secret_only ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8306+ nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash,
8307+ RecipientOnionFields :: secret_only ( test_secret) , Some ( test_preimage) ,
8308+ PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
83018309 check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
83028310
83038311 let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments