@@ -1204,24 +1204,40 @@ impl ChannelDetails {
1204
1204
#[ derive( Clone , Debug ) ]
1205
1205
pub enum PaymentSendFailure {
1206
1206
/// A parameter which was passed to send_payment was invalid, preventing us from attempting to
1207
- /// send the payment at all. No channel state has been changed or messages sent to peers, and
1208
- /// once you've changed the parameter at error, you can freely retry the payment in full.
1207
+ /// send the payment at all.
1208
+ ///
1209
+ /// You can freely resend the payment in full (with the parameter error fixed).
1210
+ ///
1211
+ /// Because the payment failed outright, no payment tracking is done, you do not need to call
1212
+ /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1213
+ /// for this payment.
1209
1214
ParameterError ( APIError ) ,
1210
1215
/// A parameter in a single path which was passed to send_payment was invalid, preventing us
1211
- /// from attempting to send the payment at all. No channel state has been changed or messages
1212
- /// sent to peers, and once you've changed the parameter at error, you can freely retry the
1213
- /// payment in full.
1216
+ /// from attempting to send the payment at all.
1217
+ ///
1218
+ /// You can freely resend the payment in full (with the parameter error fixed) .
1214
1219
///
1215
1220
/// The results here are ordered the same as the paths in the route object which was passed to
1216
1221
/// send_payment.
1222
+ ///
1223
+ /// Because the payment failed outright, no payment tracking is done, you do not need to call
1224
+ /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1225
+ /// for this payment.
1217
1226
PathParameterError ( Vec < Result < ( ) , APIError > > ) ,
1218
1227
/// All paths which were attempted failed to send, with no channel state change taking place.
1219
- /// You can freely retry the payment in full (though you probably want to do so over different
1228
+ /// You can freely resend the payment in full (though you probably want to do so over different
1220
1229
/// paths than the ones selected).
1221
1230
///
1222
- /// [`ChannelManager::abandon_payment`] does *not* need to be called for this payment and
1223
- /// [`ChannelManager::retry_payment`] will *not* work for this payment.
1224
- AllFailedRetrySafe ( Vec < APIError > ) ,
1231
+ /// Because the payment failed outright, no payment tracking is done, you do not need to call
1232
+ /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1233
+ /// for this payment.
1234
+ AllFailedResendSafe ( Vec < APIError > ) ,
1235
+ /// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
1236
+ /// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via
1237
+ /// [`ChannelManager::abandon_payment`]).
1238
+ ///
1239
+ /// [`Event::PaymentSent`]: events::Event::PaymentSent
1240
+ DuplicatePayment ,
1225
1241
/// Some paths which were attempted failed to send, though possibly not all. At least some
1226
1242
/// paths have irrevocably committed to the HTLC and retrying the payment in full would result
1227
1243
/// in over-/re-payment.
@@ -2632,9 +2648,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2632
2648
2633
2649
let mut pending_outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
2634
2650
match pending_outbounds. entry ( payment_id) {
2635
- hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: ParameterError ( APIError :: RouteError {
2636
- err : "Payment already in progress"
2637
- } ) ) ,
2651
+ hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: DuplicatePayment ) ,
2638
2652
hash_map:: Entry :: Vacant ( entry) => {
2639
2653
let payment = entry. insert ( PendingOutboundPayment :: Retryable {
2640
2654
session_privs : HashSet :: new ( ) ,
@@ -2748,7 +2762,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2748
2762
// `pending_outbound_payments` map, as the user isn't expected to `abandon_payment`.
2749
2763
let removed = self . pending_outbound_payments . lock ( ) . unwrap ( ) . remove ( & payment_id) . is_some ( ) ;
2750
2764
debug_assert ! ( removed, "We should always have a pending payment to remove here" ) ;
2751
- Err ( PaymentSendFailure :: AllFailedRetrySafe ( results. drain ( ..) . map ( |r| r. unwrap_err ( ) ) . collect ( ) ) )
2765
+ Err ( PaymentSendFailure :: AllFailedResendSafe ( results. drain ( ..) . map ( |r| r. unwrap_err ( ) ) . collect ( ) ) )
2752
2766
} else {
2753
2767
Ok ( ( ) )
2754
2768
}
0 commit comments