@@ -230,6 +230,10 @@ pub struct RecipientOnionFields {
230
230
///
231
231
/// If you do not have one, the [`Route`] you pay over must not contain multiple paths as
232
232
/// multi-path payments require a recipient-provided secret.
233
+ ///
234
+ /// Note that for spontaneous payments most lightning nodes do not currently support MPP
235
+ /// receives, thus you should generally never be providing a secret here for spontaneous
236
+ /// payments.
233
237
pub payment_secret : Option < PaymentSecret > ,
234
238
}
235
239
@@ -2727,7 +2731,7 @@ where
2727
2731
/// Note that `route` must have exactly one path.
2728
2732
///
2729
2733
/// [`send_payment`]: Self::send_payment
2730
- pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > , payment_id : PaymentId ) -> Result < PaymentHash , PaymentSendFailure > {
2734
+ pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > , recipient_onion : RecipientOnionFields , payment_id : PaymentId ) -> Result < PaymentHash , PaymentSendFailure > {
2731
2735
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2732
2736
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2733
2737
self . pending_outbound_payments . send_spontaneous_payment_with_route (
@@ -2744,7 +2748,7 @@ where
2744
2748
/// payments.
2745
2749
///
2746
2750
/// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
2747
- pub fn send_spontaneous_payment_with_retry ( & self , payment_preimage : Option < PaymentPreimage > , payment_id : PaymentId , route_params : RouteParameters , retry_strategy : Retry ) -> Result < PaymentHash , RetryableSendFailure > {
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 > {
2748
2752
let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
2749
2753
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
2750
2754
self . pending_outbound_payments . send_spontaneous_payment ( payment_preimage, payment_id,
@@ -8008,7 +8012,8 @@ mod tests {
8008
8012
pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 200_000 , our_payment_hash, Some ( payment_secret) , events. drain ( ..) . next ( ) . unwrap ( ) , false , None ) ;
8009
8013
8010
8014
// Next, send a keysend payment with the same payment_hash and make sure it fails.
8011
- nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8015
+ nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8016
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8012
8017
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8013
8018
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8014
8019
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8128,7 +8133,8 @@ mod tests {
8128
8133
& nodes[ 0 ] . node . get_our_node_id ( ) , & route_params, & nodes[ 0 ] . network_graph ,
8129
8134
None , nodes[ 0 ] . logger , & scorer, & random_seed_bytes
8130
8135
) . unwrap ( ) ;
8131
- nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8136
+ nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8137
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8132
8138
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8133
8139
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8134
8140
assert_eq ! ( events. len( ) , 1 ) ;
@@ -8161,7 +8167,8 @@ mod tests {
8161
8167
& nodes[ 0 ] . node . get_our_node_id ( ) , & route_params, & nodes[ 0 ] . network_graph ,
8162
8168
None , nodes[ 0 ] . logger , & scorer, & random_seed_bytes
8163
8169
) . unwrap ( ) ;
8164
- let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8170
+ let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ,
8171
+ RecipientOnionFields :: spontaneous_empty ( ) , PaymentId ( payment_preimage. 0 ) ) . unwrap ( ) ;
8165
8172
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
8166
8173
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8167
8174
assert_eq ! ( events. len( ) , 1 ) ;
0 commit comments