@@ -2529,12 +2529,12 @@ where
2529
2529
}
2530
2530
2531
2531
#[ cfg( test) ]
2532
- 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 > {
2532
+ 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 > {
2533
2533
let _lck = self . total_consistency_lock . read ( ) . unwrap ( ) ;
2534
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2534
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2535
2535
}
2536
2536
2537
- 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 > {
2537
+ 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 > {
2538
2538
// The top-level caller should hold the total_consistency_lock read lock.
2539
2539
debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
2540
2540
@@ -2544,7 +2544,7 @@ where
2544
2544
2545
2545
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2546
2546
. map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" . to_owned ( ) } ) ?;
2547
- let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret , cur_height, keysend_preimage) ?;
2547
+ let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, recipient_onion , cur_height, keysend_preimage) ?;
2548
2548
if onion_utils:: route_size_insane ( & onion_payloads) {
2549
2549
return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
2550
2550
}
@@ -2665,9 +2665,9 @@ where
2665
2665
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2666
2666
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2667
2667
self . pending_outbound_payments
2668
- . send_payment_with_route ( route, payment_hash, & recipient_onion. payment_secret , payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2669
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2670
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2668
+ . send_payment_with_route ( route, payment_hash, recipient_onion, payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2669
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2670
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2671
2671
}
2672
2672
2673
2673
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2676,27 +2676,27 @@ where
2676
2676
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2677
2677
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2678
2678
self . pending_outbound_payments
2679
- . send_payment ( payment_hash, & recipient_onion. payment_secret , payment_id, retry_strategy, route_params,
2679
+ . send_payment ( payment_hash, recipient_onion, payment_id, retry_strategy, route_params,
2680
2680
& self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
2681
2681
& self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
2682
2682
& self . pending_events ,
2683
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2684
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2683
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2684
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2685
2685
}
2686
2686
2687
2687
#[ cfg( test) ]
2688
- 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 > {
2688
+ 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 > {
2689
2689
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2690
2690
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2691
- 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,
2692
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2693
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2691
+ 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,
2692
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2693
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2694
2694
}
2695
2695
2696
2696
#[ cfg( test) ]
2697
- 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 > {
2697
+ 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 > {
2698
2698
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2699
- self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, payment_secret , payment_id, route, None , & self . entropy_source , best_block_height)
2699
+ self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, recipient_onion , payment_id, route, None , & self . entropy_source , best_block_height)
2700
2700
}
2701
2701
2702
2702
@@ -2740,10 +2740,10 @@ where
2740
2740
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2741
2741
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2742
2742
self . pending_outbound_payments . send_spontaneous_payment_with_route (
2743
- route, payment_preimage, payment_id , & self . entropy_source , & self . node_signer ,
2744
- best_block_height,
2745
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2746
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2743
+ route, payment_preimage, recipient_onion , payment_id , & self . entropy_source ,
2744
+ & self . node_signer , best_block_height,
2745
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2746
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2747
2747
}
2748
2748
2749
2749
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2756,12 +2756,12 @@ where
2756
2756
pub fn send_spontaneous_payment_with_retry ( & self , payment_preimage : Option < PaymentPreimage > , payment_id : PaymentId , route_params : RouteParameters , retry_strategy : Retry ) -> Result < PaymentHash , RetryableSendFailure > {
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
- self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id ,
2760
- retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2759
+ self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, recipient_onion ,
2760
+ payment_id , retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2761
2761
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
2762
2762
& self . logger , & self . pending_events ,
2763
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2764
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2763
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2764
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2765
2765
}
2766
2766
2767
2767
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2771,8 +2771,8 @@ where
2771
2771
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2772
2772
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2773
2773
self . pending_outbound_payments . send_probe ( hops, self . probing_cookie_secret , & self . entropy_source , & self . node_signer , best_block_height,
2774
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2775
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2774
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2775
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2776
2776
}
2777
2777
2778
2778
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3509,8 +3509,8 @@ where
3509
3509
self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
3510
3510
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
3511
3511
& self . pending_events , & self . logger ,
3512
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3513
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3512
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3513
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3514
3514
3515
3515
for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
3516
3516
self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8054,8 +8054,10 @@ mod tests {
8054
8054
// Use the utility function send_payment_along_path to send the payment with MPP data which
8055
8055
// indicates there are more HTLCs coming.
8056
8056
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.
8057
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash, Some ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8058
- 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 ( ) ;
8057
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash,
8058
+ RecipientOnionFields :: secret_only ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8059
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash,
8060
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
8059
8061
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8060
8062
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8061
8063
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8085,7 +8087,8 @@ mod tests {
8085
8087
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
8086
8088
8087
8089
// Send the second half of the original MPP payment.
8088
- 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 ( ) ;
8090
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash,
8091
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
8089
8092
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8090
8093
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8091
8094
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8280,8 +8283,10 @@ mod tests {
8280
8283
8281
8284
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8282
8285
let mismatch_payment_hash = PaymentHash ( [ 43 ; 32 ] ) ;
8283
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash, None , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8284
- nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash, & None , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8286
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash,
8287
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8288
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash,
8289
+ RecipientOnionFields :: spontaneous_empty ( ) , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8285
8290
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8286
8291
8287
8292
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8323,8 +8328,11 @@ mod tests {
8323
8328
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8324
8329
let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
8325
8330
let payment_hash = PaymentHash ( Sha256 :: hash ( & test_preimage. 0 ) . into_inner ( ) ) ;
8326
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash, Some ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8327
- nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash, & Some ( test_secret) , Some ( test_preimage) , PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8331
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash,
8332
+ RecipientOnionFields :: secret_only ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8333
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash,
8334
+ RecipientOnionFields :: secret_only ( test_secret) , Some ( test_preimage) ,
8335
+ PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8328
8336
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8329
8337
8330
8338
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments