@@ -2533,12 +2533,12 @@ where
2533
2533
}
2534
2534
2535
2535
#[ cfg( test) ]
2536
- 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 > {
2536
+ 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 > {
2537
2537
let _lck = self . total_consistency_lock . read ( ) . unwrap ( ) ;
2538
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2538
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2539
2539
}
2540
2540
2541
- 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 > {
2541
+ 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 > {
2542
2542
// The top-level caller should hold the total_consistency_lock read lock.
2543
2543
debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
2544
2544
@@ -2548,7 +2548,7 @@ where
2548
2548
2549
2549
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2550
2550
. map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" . to_owned ( ) } ) ?;
2551
- let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret , cur_height, keysend_preimage) ?;
2551
+ let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, recipient_onion , cur_height, keysend_preimage) ?;
2552
2552
if onion_utils:: route_size_insane ( & onion_payloads) {
2553
2553
return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
2554
2554
}
@@ -2669,9 +2669,9 @@ where
2669
2669
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2670
2670
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2671
2671
self . pending_outbound_payments
2672
- . send_payment_with_route ( route, payment_hash, & recipient_onion. payment_secret , payment_id, & self . entropy_source , & 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
+ . send_payment_with_route ( route, payment_hash, recipient_onion, payment_id, & self . entropy_source , & 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) )
2675
2675
}
2676
2676
2677
2677
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2680,27 +2680,27 @@ where
2680
2680
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2681
2681
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2682
2682
self . pending_outbound_payments
2683
- . send_payment ( payment_hash, & recipient_onion. payment_secret , payment_id, retry_strategy, route_params,
2683
+ . send_payment ( payment_hash, recipient_onion, payment_id, retry_strategy, route_params,
2684
2684
& self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
2685
2685
& self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
2686
2686
& self . pending_events ,
2687
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2688
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2687
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2688
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2689
2689
}
2690
2690
2691
2691
#[ cfg( test) ]
2692
- 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 > {
2692
+ 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 > {
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
- 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,
2696
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2697
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2695
+ 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,
2696
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2697
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2698
2698
}
2699
2699
2700
2700
#[ cfg( test) ]
2701
- 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 > {
2701
+ 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 > {
2702
2702
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2703
- self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, payment_secret , payment_id, route, None , & self . entropy_source , best_block_height)
2703
+ self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, recipient_onion , payment_id, route, None , & self . entropy_source , best_block_height)
2704
2704
}
2705
2705
2706
2706
@@ -2744,10 +2744,10 @@ where
2744
2744
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2745
2745
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2746
2746
self . pending_outbound_payments . send_spontaneous_payment_with_route (
2747
- route, payment_preimage, payment_id , & self . entropy_source , & self . node_signer ,
2748
- best_block_height,
2749
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2750
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2747
+ route, payment_preimage, recipient_onion , payment_id , & self . entropy_source ,
2748
+ & self . node_signer , best_block_height,
2749
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2750
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2751
2751
}
2752
2752
2753
2753
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2760,12 +2760,12 @@ where
2760
2760
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 > {
2761
2761
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2762
2762
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2763
- self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id ,
2764
- retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2763
+ self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, recipient_onion ,
2764
+ payment_id , retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2765
2765
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
2766
2766
& self . logger , & self . pending_events ,
2767
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2768
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2767
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2768
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2769
2769
}
2770
2770
2771
2771
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2775,8 +2775,8 @@ where
2775
2775
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2776
2776
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2777
2777
self . pending_outbound_payments . send_probe ( hops, self . probing_cookie_secret , & self . entropy_source , & self . node_signer , best_block_height,
2778
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2779
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2778
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2779
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2780
2780
}
2781
2781
2782
2782
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3513,8 +3513,8 @@ where
3513
3513
self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
3514
3514
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
3515
3515
& self . pending_events , & self . logger ,
3516
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3517
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3516
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3517
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3518
3518
3519
3519
for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
3520
3520
self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8058,8 +8058,10 @@ mod tests {
8058
8058
// Use the utility function send_payment_along_path to send the payment with MPP data which
8059
8059
// indicates there are more HTLCs coming.
8060
8060
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.
8061
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash, Some ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8062
- 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 ( ) ;
8061
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash,
8062
+ RecipientOnionFields :: secret_only ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8063
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash,
8064
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
8063
8065
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8064
8066
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8065
8067
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8090,7 +8092,8 @@ mod tests {
8090
8092
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
8091
8093
8092
8094
// Send the second half of the original MPP payment.
8093
- 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 ( ) ;
8095
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash,
8096
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
8094
8097
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8095
8098
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8096
8099
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8287,8 +8290,10 @@ mod tests {
8287
8290
8288
8291
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8289
8292
let mismatch_payment_hash = PaymentHash ( [ 43 ; 32 ] ) ;
8290
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash, None , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8291
- nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash, & None , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8293
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash,
8294
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8295
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash,
8296
+ RecipientOnionFields :: spontaneous_empty ( ) , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8292
8297
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8293
8298
8294
8299
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8330,8 +8335,11 @@ mod tests {
8330
8335
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8331
8336
let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
8332
8337
let payment_hash = PaymentHash ( Sha256 :: hash ( & test_preimage. 0 ) . into_inner ( ) ) ;
8333
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash, Some ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8334
- nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash, & Some ( test_secret) , Some ( test_preimage) , PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8338
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash,
8339
+ RecipientOnionFields :: secret_only ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8340
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash,
8341
+ RecipientOnionFields :: secret_only ( test_secret) , Some ( test_preimage) ,
8342
+ PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8335
8343
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8336
8344
8337
8345
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments