@@ -2521,12 +2521,12 @@ where
2521
2521
}
2522
2522
2523
2523
#[ cfg( test) ]
2524
- 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 > {
2524
+ 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 > {
2525
2525
let _lck = self . total_consistency_lock . read ( ) . unwrap ( ) ;
2526
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2526
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2527
2527
}
2528
2528
2529
- 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 > {
2529
+ 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 > {
2530
2530
// The top-level caller should hold the total_consistency_lock read lock.
2531
2531
debug_assert ! ( self . total_consistency_lock. try_write( ) . is_err( ) ) ;
2532
2532
@@ -2536,7 +2536,7 @@ where
2536
2536
2537
2537
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2538
2538
. map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" . to_owned ( ) } ) ?;
2539
- let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret , cur_height, keysend_preimage) ?;
2539
+ let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, recipient_onion , cur_height, keysend_preimage) ?;
2540
2540
if onion_utils:: route_size_insane ( & onion_payloads) {
2541
2541
return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" . to_owned ( ) } ) ;
2542
2542
}
@@ -2657,9 +2657,9 @@ 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_with_route ( route, payment_hash, & recipient_onion. payment_secret , payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2661
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2662
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2660
+ . send_payment_with_route ( route, payment_hash, recipient_onion, payment_id, & self . entropy_source , & self . node_signer , best_block_height,
2661
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2662
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2663
2663
}
2664
2664
2665
2665
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2668,27 +2668,27 @@ where
2668
2668
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2669
2669
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2670
2670
self . pending_outbound_payments
2671
- . send_payment ( payment_hash, & recipient_onion. payment_secret , payment_id, retry_strategy, route_params,
2671
+ . send_payment ( payment_hash, recipient_onion, payment_id, retry_strategy, route_params,
2672
2672
& self . router , self . list_usable_channels ( ) , || self . compute_inflight_htlcs ( ) ,
2673
2673
& self . entropy_source , & self . node_signer , best_block_height, & self . logger ,
2674
2674
& self . pending_events ,
2675
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2676
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2675
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2676
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2677
2677
}
2678
2678
2679
2679
#[ cfg( test) ]
2680
- 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 > {
2680
+ 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 > {
2681
2681
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2682
2682
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2683
- 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,
2684
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2685
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2683
+ 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,
2684
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2685
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2686
2686
}
2687
2687
2688
2688
#[ cfg( test) ]
2689
- 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 > {
2689
+ 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 > {
2690
2690
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2691
- self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, payment_secret , payment_id, route, None , & self . entropy_source , best_block_height)
2691
+ self . pending_outbound_payments . test_add_new_pending_payment ( payment_hash, recipient_onion , payment_id, route, None , & self . entropy_source , best_block_height)
2692
2692
}
2693
2693
2694
2694
@@ -2732,10 +2732,10 @@ where
2732
2732
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2733
2733
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2734
2734
self . pending_outbound_payments . send_spontaneous_payment_with_route (
2735
- route, payment_preimage, payment_id , & self . entropy_source , & self . node_signer ,
2736
- best_block_height,
2737
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2738
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2735
+ route, payment_preimage, recipient_onion , payment_id , & self . entropy_source ,
2736
+ & self . node_signer , best_block_height,
2737
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2738
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2739
2739
}
2740
2740
2741
2741
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2748,12 +2748,12 @@ where
2748
2748
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 > {
2749
2749
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2750
2750
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2751
- self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id ,
2752
- retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2751
+ self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, recipient_onion ,
2752
+ payment_id , retry_strategy, route_params, & self . router , self . list_usable_channels ( ) ,
2753
2753
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
2754
2754
& self . logger , & self . pending_events ,
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
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2763,8 +2763,8 @@ where
2763
2763
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2764
2764
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2765
2765
self . pending_outbound_payments . send_probe ( hops, self . probing_cookie_secret , & self . entropy_source , & self . node_signer , best_block_height,
2766
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2767
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2766
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
2767
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) )
2768
2768
}
2769
2769
2770
2770
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3488,8 +3488,8 @@ where
3488
3488
self . pending_outbound_payments . check_retry_payments ( & self . router , || self . list_usable_channels ( ) ,
3489
3489
|| self . compute_inflight_htlcs ( ) , & self . entropy_source , & self . node_signer , best_block_height,
3490
3490
& self . pending_events , & self . logger ,
3491
- |path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3492
- self . send_payment_along_path ( path, payment_hash, payment_secret , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3491
+ |path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv|
3492
+ self . send_payment_along_path ( path, payment_hash, recipient_onion , total_value, cur_height, payment_id, keysend_preimage, session_priv) ) ;
3493
3493
3494
3494
for ( htlc_source, payment_hash, failure_reason, destination) in failed_forwards. drain ( ..) {
3495
3495
self . fail_htlc_backwards_internal ( & htlc_source, & payment_hash, & failure_reason, destination) ;
@@ -8000,8 +8000,10 @@ mod tests {
8000
8000
// Use the utility function send_payment_along_path to send the payment with MPP data which
8001
8001
// indicates there are more HTLCs coming.
8002
8002
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.
8003
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash, Some ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8004
- 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 ( ) ;
8003
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( our_payment_hash,
8004
+ RecipientOnionFields :: secret_only ( payment_secret) , payment_id, & mpp_route) . unwrap ( ) ;
8005
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 0 ] , & our_payment_hash,
8006
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 0 ] ) . unwrap ( ) ;
8005
8007
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8006
8008
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8007
8009
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8032,7 +8034,8 @@ mod tests {
8032
8034
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
8033
8035
8034
8036
// Send the second half of the original MPP payment.
8035
- 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 ( ) ;
8037
+ nodes[ 0 ] . node . test_send_payment_along_path ( & mpp_route. paths [ 1 ] , & our_payment_hash,
8038
+ RecipientOnionFields :: secret_only ( payment_secret) , 200_000 , cur_height, payment_id, & None , session_privs[ 1 ] ) . unwrap ( ) ;
8036
8039
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8037
8040
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8038
8041
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8229,8 +8232,10 @@ mod tests {
8229
8232
8230
8233
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8231
8234
let mismatch_payment_hash = PaymentHash ( [ 43 ; 32 ] ) ;
8232
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash, None , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8233
- nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash, & None , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8235
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( mismatch_payment_hash,
8236
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( mismatch_payment_hash. 0 ) , & route) . unwrap ( ) ;
8237
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, mismatch_payment_hash,
8238
+ RecipientOnionFields :: spontaneous_empty ( ) , Some ( test_preimage) , PaymentId ( mismatch_payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8234
8239
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8235
8240
8236
8241
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
@@ -8272,8 +8277,11 @@ mod tests {
8272
8277
let test_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
8273
8278
let test_secret = PaymentSecret ( [ 43 ; 32 ] ) ;
8274
8279
let payment_hash = PaymentHash ( Sha256 :: hash ( & test_preimage. 0 ) . into_inner ( ) ) ;
8275
- let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash, Some ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8276
- nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash, & Some ( test_secret) , Some ( test_preimage) , PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8280
+ let session_privs = nodes[ 0 ] . node . test_add_new_pending_payment ( payment_hash,
8281
+ RecipientOnionFields :: secret_only ( test_secret) , PaymentId ( payment_hash. 0 ) , & route) . unwrap ( ) ;
8282
+ nodes[ 0 ] . node . test_send_payment_internal ( & route, payment_hash,
8283
+ RecipientOnionFields :: secret_only ( test_secret) , Some ( test_preimage) ,
8284
+ PaymentId ( payment_hash. 0 ) , None , session_privs) . unwrap ( ) ;
8277
8285
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8278
8286
8279
8287
let updates = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
0 commit comments