@@ -2510,12 +2510,12 @@ where
2510
2510
}
2511
2511
2512
2512
#[ 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 > {
2514
2514
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)
2516
2516
}
2517
2517
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 > {
2519
2519
// The top-level caller should hold the total_consistency_lock read lock.
2520
2520
debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
2521
2521
@@ -2525,7 +2525,7 @@ where
2525
2525
2526
2526
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2527
2527
. 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) ?;
2529
2529
if onion_utils:: route_size_insane ( & onion_payloads) {
2530
2530
return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
2531
2531
}
@@ -2646,9 +2646,9 @@ where
2646
2646
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2647
2647
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2648
2648
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) )
2652
2652
}
2653
2653
2654
2654
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2657,27 +2657,27 @@ where
2657
2657
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2658
2658
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2659
2659
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,
2661
2661
& self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
2662
2662
& self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
2663
2663
& 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) )
2666
2666
}
2667
2667
2668
2668
#[ 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 > {
2670
2670
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2671
2671
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) )
2675
2675
}
2676
2676
2677
2677
#[ 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 > {
2679
2679
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)
2681
2681
}
2682
2682
2683
2683
@@ -2721,10 +2721,10 @@ where
2721
2721
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2722
2722
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2723
2723
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) )
2728
2728
}
2729
2729
2730
2730
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2737,12 +2737,12 @@ where
2737
2737
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 > {
2738
2738
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2739
2739
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 ( ) ,
2742
2742
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
2743
2743
& 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) )
2746
2746
}
2747
2747
2748
2748
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2752,8 +2752,8 @@ where
2752
2752
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2753
2753
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2754
2754
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) )
2757
2757
}
2758
2758
2759
2759
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3490,8 +3490,8 @@ where
3490
3490
self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
3491
3491
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
3492
3492
& 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) ) ;
3495
3495
3496
3496
for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
3497
3497
self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8024,8 +8024,10 @@ mod tests {
8024
8024
// Use the utility function send_payment_along_path to send the payment with MPP data which
8025
8025
// indicates there are more HTLCs coming.
8026
8026
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 ( ) ;
8029
8031
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8030
8032
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8031
8033
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8056,7 +8058,8 @@ mod tests {
8056
8058
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
8057
8059
8058
8060
// 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 ( ) ;
8060
8063
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8061
8064
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8062
8065
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8253,8 +8256,10 @@ mod tests {
8253
8256
8254
8257
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8255
8258
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 ( ) ;
8258
8263
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8259
8264
8260
8265
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8296,8 +8301,11 @@ mod tests {
8296
8301
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8297
8302
let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
8298
8303
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 ( ) ;
8301
8309
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8302
8310
8303
8311
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments