@@ -239,6 +239,10 @@ pub struct RecipientOnionFields {
239
239
///
240
240
/// If you do not have one, the [`Route`] you pay over must not contain multiple paths as
241
241
/// multi-path payments require a recipient-provided secret.
242
+ ///
243
+ /// Note that for spontaneous payments most lightning nodes do not currently support MPP
244
+ /// receives, thus you should generally never be providing a secret here for spontaneous
245
+ /// payments.
242
246
pub payment_secret : Option < PaymentSecret > ,
243
247
}
244
248
@@ -2736,7 +2740,7 @@ where
2736
2740
/// Note that `route` must have exactly one path.
2737
2741
///
2738
2742
/// [`send_payment`]: Self::send_payment
2739
- pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > , payment_id : PaymentId ) -> Result < PaymentHash , PaymentSendFailure > {
2743
+ pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > , recipient_onion : RecipientOnionFields , payment_id : PaymentId ) -> Result < PaymentHash , PaymentSendFailure > {
2740
2744
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2741
2745
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2742
2746
self . pending_outbound_payments . send_spontaneous_payment_with_route (
@@ -2753,7 +2757,7 @@ where
2753
2757
/// payments.
2754
2758
///
2755
2759
/// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
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 > {
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 > {
2757
2761
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2758
2762
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2759
2763
self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id,
@@ -8062,7 +8066,8 @@ mod tests {
8062
8066
pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 200_000 , our_payment_hash, Some ( payment_secret) , events. drain ( ..) . next ( ) . unwrap ( ) , false , None ) ;
8063
8067
8064
8068
// Next, send a keysend payment with the same payment_hash and make sure it fails.
8065
- nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8069
+ nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8070
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8066
8071
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8067
8072
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8068
8073
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8182,7 +8187,8 @@ mod tests {
8182
8187
& nodes[ 0 ] . node . get_our_node_id ( ) , & route_params, & nodes[ 0 ] . network_graph ,
8183
8188
None , nodes[ 0 ] . logger , & scorer, & random_seed_bytes
8184
8189
) . unwrap ( ) ;
8185
- nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8190
+ nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8191
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8186
8192
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8187
8193
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8188
8194
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8215,7 +8221,8 @@ mod tests {
8215
8221
& nodes[ 0 ] . node . get_our_node_id ( ) , & route_params, & nodes[ 0 ] . network_graph ,
8216
8222
None , nodes[ 0 ] . logger , & scorer, & random_seed_bytes
8217
8223
) . unwrap ( ) ;
8218
- let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8224
+ let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8225
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8219
8226
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8220
8227
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8221
8228
assert_eq ! ( events. len( ) , 1 ) ;
0 commit comments