@@ -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
@@ -2749,7 +2753,7 @@ where
2749
2753
/// Note that `route` must have exactly one path.
2750
2754
///
2751
2755
/// [`send_payment`]: Self::send_payment
2752
- pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > , payment_id : PaymentId ) -> Result < PaymentHash , PaymentSendFailure > {
2756
+ pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > , recipient_onion : RecipientOnionFields , payment_id : PaymentId ) -> Result < PaymentHash , PaymentSendFailure > {
2753
2757
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2754
2758
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2755
2759
self . pending_outbound_payments . send_spontaneous_payment_with_route (
@@ -2766,7 +2770,7 @@ where
2766
2770
/// payments.
2767
2771
///
2768
2772
/// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
2769
- pub fn send_spontaneous_payment_with_retry ( & self , payment_preimage : Option < PaymentPreimage > , payment_id : PaymentId , route_params : RouteParameters , retry_strategy : Retry ) -> Result < PaymentHash , RetryableSendFailure > {
2773
+ 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 > {
2770
2774
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2771
2775
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2772
2776
self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id,
@@ -8064,7 +8068,8 @@ mod tests {
8064
8068
pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 200_000 , our_payment_hash, Some ( payment_secret) , events. drain ( ..) . next ( ) . unwrap ( ) , false , None ) ;
8065
8069
8066
8070
// Next, send a keysend payment with the same payment_hash and make sure it fails.
8067
- nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8071
+ nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8072
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8068
8073
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8069
8074
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8070
8075
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8184,7 +8189,8 @@ mod tests {
8184
8189
& nodes[ 0 ] . node . get_our_node_id ( ) , & route_params, & nodes[ 0 ] . network_graph ,
8185
8190
None , nodes[ 0 ] . logger , & scorer, & random_seed_bytes
8186
8191
) . unwrap ( ) ;
8187
- nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8192
+ nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8193
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8188
8194
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8189
8195
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8190
8196
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8217,7 +8223,8 @@ mod tests {
8217
8223
& nodes[ 0 ] . node . get_our_node_id ( ) , & route_params, & nodes[ 0 ] . network_graph ,
8218
8224
None , nodes[ 0 ] . logger , & scorer, & random_seed_bytes
8219
8225
) . unwrap ( ) ;
8220
- let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8226
+ let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8227
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8221
8228
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8222
8229
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8223
8230
assert_eq ! ( events. len( ) , 1 ) ;
0 commit comments