@@ -1204,24 +1204,40 @@ impl ChannelDetails {
12041204#[ derive( Clone , Debug ) ]
12051205pub enum PaymentSendFailure {
12061206 /// 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.
12091214 ParameterError ( APIError ) ,
12101215 /// 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) .
12141219 ///
12151220 /// The results here are ordered the same as the paths in the route object which was passed to
12161221 /// 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.
12171226 PathParameterError ( Vec < Result < ( ) , APIError > > ) ,
12181227 /// 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
12201229 /// paths than the ones selected).
12211230 ///
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 ,
12251241 /// Some paths which were attempted failed to send, though possibly not all. At least some
12261242 /// paths have irrevocably committed to the HTLC and retrying the payment in full would result
12271243 /// in over-/re-payment.
@@ -2632,9 +2648,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
26322648
26332649 let mut pending_outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
26342650 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 ) ,
26382652 hash_map:: Entry :: Vacant ( entry) => {
26392653 let payment = entry. insert ( PendingOutboundPayment :: Retryable {
26402654 session_privs : HashSet :: new ( ) ,
@@ -2748,7 +2762,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
27482762 // `pending_outbound_payments` map, as the user isn't expected to `abandon_payment`.
27492763 let removed = self . pending_outbound_payments . lock ( ) . unwrap ( ) . remove ( & payment_id) . is_some ( ) ;
27502764 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 ( ) ) )
27522766 } else {
27532767 Ok ( ( ) )
27542768 }
0 commit comments