-
Notifications
You must be signed in to change notification settings - Fork 411
Add a separate PaymentSendFailure for idempotency violation #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1188,24 +1188,40 @@ impl ChannelDetails { | |||||
#[derive(Clone, Debug)] | ||||||
pub enum PaymentSendFailure { | ||||||
/// A parameter which was passed to send_payment was invalid, preventing us from attempting to | ||||||
/// send the payment at all. No channel state has been changed or messages sent to peers, and | ||||||
/// once you've changed the parameter at error, you can freely retry the payment in full. | ||||||
/// send the payment at all. | ||||||
/// | ||||||
/// You can freely resend the payment in full (with the parameter error fixed). | ||||||
/// | ||||||
/// Because the payment failed outright, no payment tracking is done, you do not need to call | ||||||
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work | ||||||
/// for this payment. | ||||||
ParameterError(APIError), | ||||||
/// A parameter in a single path which was passed to send_payment was invalid, preventing us | ||||||
/// from attempting to send the payment at all. No channel state has been changed or messages | ||||||
/// sent to peers, and once you've changed the parameter at error, you can freely retry the | ||||||
/// payment in full. | ||||||
/// from attempting to send the payment at all. | ||||||
/// | ||||||
/// You can freely resend the payment in full (with the parameter error fixed). | ||||||
/// | ||||||
/// The results here are ordered the same as the paths in the route object which was passed to | ||||||
/// send_payment. | ||||||
/// | ||||||
/// Because the payment failed outright, no payment tracking is done, you do not need to call | ||||||
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work | ||||||
/// for this payment. | ||||||
PathParameterError(Vec<Result<(), APIError>>), | ||||||
/// All paths which were attempted failed to send, with no channel state change taking place. | ||||||
/// You can freely retry the payment in full (though you probably want to do so over different | ||||||
/// You can freely resend the payment in full (though you probably want to do so over different | ||||||
/// paths than the ones selected). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would rather replace |
||||||
/// | ||||||
/// [`ChannelManager::abandon_payment`] does *not* need to be called for this payment and | ||||||
/// [`ChannelManager::retry_payment`] will *not* work for this payment. | ||||||
AllFailedRetrySafe(Vec<APIError>), | ||||||
/// Because the payment failed outright, no payment tracking is done, you do not need to call | ||||||
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work | ||||||
/// for this payment. | ||||||
AllFailedResendSafe(Vec<APIError>), | ||||||
/// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not | ||||||
/// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - "not yet completed or been abandoned" has the opposite meaning from "not yet completed or has been abandoned" :). |
||||||
/// [`ChannelManager::abandon_payment`]). | ||||||
/// | ||||||
/// [`Event::PaymentSent`]: events::Event::PaymentSent | ||||||
DuplicatePayment, | ||||||
/// Some paths which were attempted failed to send, though possibly not all. At least some | ||||||
/// paths have irrevocably committed to the HTLC and retrying the payment in full would result | ||||||
/// in over-/re-payment. | ||||||
|
@@ -2610,9 +2626,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F | |||||
|
||||||
let mut pending_outbounds = self.pending_outbound_payments.lock().unwrap(); | ||||||
match pending_outbounds.entry(payment_id) { | ||||||
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::ParameterError(APIError::RouteError { | ||||||
err: "Payment already in progress" | ||||||
})), | ||||||
hash_map::Entry::Occupied(_) => Err(PaymentSendFailure::DuplicatePayment), | ||||||
hash_map::Entry::Vacant(entry) => { | ||||||
let payment = entry.insert(PendingOutboundPayment::Retryable { | ||||||
session_privs: HashSet::new(), | ||||||
|
@@ -2726,7 +2740,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F | |||||
// `pending_outbound_payments` map, as the user isn't expected to `abandon_payment`. | ||||||
let removed = self.pending_outbound_payments.lock().unwrap().remove(&payment_id).is_some(); | ||||||
debug_assert!(removed, "We should always have a pending payment to remove here"); | ||||||
Err(PaymentSendFailure::AllFailedRetrySafe(results.drain(..).map(|r| r.unwrap_err()).collect())) | ||||||
Err(PaymentSendFailure::AllFailedResendSafe(results.drain(..).map(|r| r.unwrap_err()).collect())) | ||||||
} else { | ||||||
Ok(()) | ||||||
} | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.