@@ -2524,12 +2524,12 @@ where
2524
2524
}
2525
2525
2526
2526
#[ cfg( test) ]
2527
- 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 > {
2527
+ 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 > {
2528
2528
let _lck = self . total_consistency_lock . read ( ) . unwrap ( ) ;
2529
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2529
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2530
2530
}
2531
2531
2532
- 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 > {
2532
+ 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 > {
2533
2533
// The top-level caller should hold the total_consistency_lock read lock.
2534
2534
debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
2535
2535
@@ -2539,7 +2539,7 @@ where
2539
2539
2540
2540
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2541
2541
. map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" . to_owned ( ) } ) ?;
2542
- let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret , cur_height, keysend_preimage) ?;
2542
+ let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, recipient_onion , cur_height, keysend_preimage) ?;
2543
2543
if onion_utils:: route_size_insane ( & onion_payloads) {
2544
2544
return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
2545
2545
}
@@ -2660,9 +2660,9 @@ where
2660
2660
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2661
2661
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2662
2662
self . pending_outbound_payments
2663
- . send_payment_with_route ( route, payment_hash, & recipient_onion. payment_secret , payment_id, & self . entropy_source , & self . node_signer , best_block_height,
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) )
2663
+ . send_payment_with_route ( route, payment_hash, recipient_onion, payment_id, & self . entropy_source , & self . node_signer , best_block_height,
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
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2671,27 +2671,27 @@ where
2671
2671
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2672
2672
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2673
2673
self . pending_outbound_payments
2674
- . send_payment ( payment_hash, & recipient_onion. payment_secret , payment_id, retry_strategy, route_params,
2674
+ . send_payment ( payment_hash, recipient_onion, payment_id, retry_strategy, route_params,
2675
2675
& self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
2676
2676
& self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
2677
2677
& self . pending_events ,
2678
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2679
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2678
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2679
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2680
2680
}
2681
2681
2682
2682
#[ cfg( test) ]
2683
- 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 > {
2683
+ 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 > {
2684
2684
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2685
2685
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2686
- 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,
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) )
2686
+ 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,
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 ( 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 > {
2692
+ 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 > {
2693
2693
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2694
- self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, payment_secret , payment_id, route, None , & self . entropy_source , best_block_height)
2694
+ self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, recipient_onion , payment_id, route, None , & self . entropy_source , best_block_height)
2695
2695
}
2696
2696
2697
2697
@@ -2735,10 +2735,10 @@ where
2735
2735
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2736
2736
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2737
2737
self . pending_outbound_payments . send_spontaneous_payment_with_route (
2738
- route, payment_preimage, payment_id , & self . entropy_source , & self . node_signer ,
2739
- best_block_height,
2740
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2741
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2738
+ route, payment_preimage, recipient_onion , payment_id , & self . entropy_source ,
2739
+ & self . node_signer , best_block_height,
2740
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2741
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2742
2742
}
2743
2743
2744
2744
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2751,12 +2751,12 @@ where
2751
2751
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 > {
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
- self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id ,
2755
- retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2754
+ self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, recipient_onion ,
2755
+ payment_id , retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2756
2756
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
2757
2757
& self . logger , & self . pending_events ,
2758
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2759
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2758
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2759
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2760
2760
}
2761
2761
2762
2762
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2766,8 +2766,8 @@ where
2766
2766
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2767
2767
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2768
2768
self . pending_outbound_payments . send_probe ( hops, self . probing_cookie_secret , & self . entropy_source , & self . node_signer , best_block_height,
2769
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2770
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2769
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2770
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2771
2771
}
2772
2772
2773
2773
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3491,8 +3491,8 @@ where
3491
3491
self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
3492
3492
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
3493
3493
& self . pending_events , & self . logger ,
3494
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3495
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3494
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3495
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3496
3496
3497
3497
for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
3498
3498
self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8004,8 +8004,10 @@ mod tests {
8004
8004
// Use the utility function send_payment_along_path to send the payment with MPP data which
8005
8005
// indicates there are more HTLCs coming.
8006
8006
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.
8007
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash, Some ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8008
- 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 ( ) ;
8007
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash,
8008
+ RecipientOnionFields :: secret_only ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8009
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash,
8010
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
8009
8011
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8010
8012
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8011
8013
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8036,7 +8038,8 @@ mod tests {
8036
8038
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
8037
8039
8038
8040
// Send the second half of the original MPP payment.
8039
- 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 ( ) ;
8041
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash,
8042
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
8040
8043
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8041
8044
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8042
8045
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8233,8 +8236,10 @@ mod tests {
8233
8236
8234
8237
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8235
8238
let mismatch_payment_hash = PaymentHash ( [ 43 ; 32 ] ) ;
8236
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash, None , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8237
- nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash, & None , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8239
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash,
8240
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8241
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash,
8242
+ RecipientOnionFields :: spontaneous_empty ( ) , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8238
8243
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8239
8244
8240
8245
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8276,8 +8281,11 @@ mod tests {
8276
8281
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8277
8282
let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
8278
8283
let payment_hash = PaymentHash ( Sha256 :: hash ( & test_preimage. 0 ) . into_inner ( ) ) ;
8279
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash, Some ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8280
- nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash, & Some ( test_secret) , Some ( test_preimage) , PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8284
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash,
8285
+ RecipientOnionFields :: secret_only ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8286
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash,
8287
+ RecipientOnionFields :: secret_only ( test_secret) , Some ( test_preimage) ,
8288
+ PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8281
8289
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8282
8290
8283
8291
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments