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