@@ -2546,12 +2546,12 @@ where
2546
2546
}
2547
2547
2548
2548
#[ cfg( test) ]
2549
- 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 > {
2549
+ 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 > {
2550
2550
let _lck = self . total_consistency_lock . read ( ) . unwrap ( ) ;
2551
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2551
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2552
2552
}
2553
2553
2554
- 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 > {
2554
+ 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 > {
2555
2555
// The top-level caller should hold the total_consistency_lock read lock.
2556
2556
debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
2557
2557
@@ -2561,7 +2561,7 @@ where
2561
2561
2562
2562
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2563
2563
. map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" . to_owned ( ) } ) ?;
2564
- let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret , cur_height, keysend_preimage) ?;
2564
+ let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, recipient_onion , cur_height, keysend_preimage) ?;
2565
2565
if onion_utils:: route_size_insane ( & onion_payloads) {
2566
2566
return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
2567
2567
}
@@ -2682,9 +2682,9 @@ where
2682
2682
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2683
2683
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2684
2684
self . pending_outbound_payments
2685
- . send_payment_with_route ( route, payment_hash, & recipient_onion. payment_secret , payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2686
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2687
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2685
+ . send_payment_with_route ( route, payment_hash, recipient_onion, payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2686
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2687
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2688
2688
}
2689
2689
2690
2690
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2693,27 +2693,27 @@ where
2693
2693
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2694
2694
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2695
2695
self . pending_outbound_payments
2696
- . send_payment ( payment_hash, & recipient_onion. payment_secret , payment_id, retry_strategy, route_params,
2696
+ . send_payment ( payment_hash, recipient_onion, payment_id, retry_strategy, route_params,
2697
2697
& self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
2698
2698
& self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
2699
2699
& self . pending_events ,
2700
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2701
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2700
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2701
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2702
2702
}
2703
2703
2704
2704
#[ cfg( test) ]
2705
- 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 > {
2705
+ 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 > {
2706
2706
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2707
2707
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2708
- 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,
2709
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2710
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2708
+ 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,
2709
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2710
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2711
2711
}
2712
2712
2713
2713
#[ cfg( test) ]
2714
- 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 > {
2714
+ 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 > {
2715
2715
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2716
- self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, payment_secret , payment_id, route, None , & self . entropy_source , best_block_height)
2716
+ self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, recipient_onion , payment_id, route, None , & self . entropy_source , best_block_height)
2717
2717
}
2718
2718
2719
2719
@@ -2757,10 +2757,10 @@ where
2757
2757
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2758
2758
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2759
2759
self . pending_outbound_payments . send_spontaneous_payment_with_route (
2760
- route, payment_preimage, payment_id , & self . entropy_source , & self . node_signer ,
2761
- best_block_height,
2762
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2763
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2760
+ route, payment_preimage, recipient_onion , payment_id , & self . entropy_source ,
2761
+ & self . node_signer , best_block_height,
2762
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2763
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2764
2764
}
2765
2765
2766
2766
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2773,12 +2773,12 @@ where
2773
2773
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 > {
2774
2774
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2775
2775
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2776
- self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id ,
2777
- retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2776
+ self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, recipient_onion ,
2777
+ payment_id , retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2778
2778
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
2779
2779
& self . logger , & self . pending_events ,
2780
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2781
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2780
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2781
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2782
2782
}
2783
2783
2784
2784
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2788,8 +2788,8 @@ where
2788
2788
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2789
2789
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2790
2790
self . pending_outbound_payments . send_probe ( hops, self . probing_cookie_secret , & self . entropy_source , & self . node_signer , best_block_height,
2791
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2792
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2791
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2792
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2793
2793
}
2794
2794
2795
2795
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3526,8 +3526,8 @@ where
3526
3526
self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
3527
3527
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
3528
3528
& self . pending_events , & self . logger ,
3529
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3530
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3529
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3530
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3531
3531
3532
3532
for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
3533
3533
self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8060,8 +8060,10 @@ mod tests {
8060
8060
// Use the utility function send_payment_along_path to send the payment with MPP data which
8061
8061
// indicates there are more HTLCs coming.
8062
8062
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.
8063
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash, Some ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8064
- 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 ( ) ;
8063
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash,
8064
+ RecipientOnionFields :: secret_only ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8065
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash,
8066
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
8065
8067
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8066
8068
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8067
8069
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8092,7 +8094,8 @@ mod tests {
8092
8094
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
8093
8095
8094
8096
// Send the second half of the original MPP payment.
8095
- 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 ( ) ;
8097
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash,
8098
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
8096
8099
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8097
8100
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8098
8101
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8289,8 +8292,10 @@ mod tests {
8289
8292
8290
8293
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8291
8294
let mismatch_payment_hash = PaymentHash ( [ 43 ; 32 ] ) ;
8292
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash, None , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8293
- nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash, & None , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8295
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash,
8296
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8297
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash,
8298
+ RecipientOnionFields :: spontaneous_empty ( ) , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8294
8299
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8295
8300
8296
8301
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8332,8 +8337,11 @@ mod tests {
8332
8337
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8333
8338
let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
8334
8339
let payment_hash = PaymentHash ( Sha256 :: hash ( & test_preimage. 0 ) . into_inner ( ) ) ;
8335
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash, Some ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8336
- nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash, & Some ( test_secret) , Some ( test_preimage) , PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8340
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash,
8341
+ RecipientOnionFields :: secret_only ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8342
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash,
8343
+ RecipientOnionFields :: secret_only ( test_secret) , Some ( test_preimage) ,
8344
+ PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8337
8345
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8338
8346
8339
8347
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments