};
);
+/// The reason the payment failed. Used in [`Event::PaymentFailed`].
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum PaymentFailureReason {
+ /// The intended recipient rejected our payment.
+ RecipientRejected,
+ /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`].
+ ///
+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ UserAbandoned,
+ /// We exhausted all of our retry attempts while trying to send the payment, or we
+ /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry
+ /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will
+ /// have come before this.
+ ///
+ /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout
+ RetriesExhausted,
+ /// The payment expired while retrying, based on the provided
+ /// [`PaymentParameters::expiry_time`].
+ ///
+ /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
+ PaymentExpired,
+ /// We failed to find a route while retrying the payment.
+ RouteNotFound,
+ /// This error should generally never happen. This likely means that there is a problem with
+ /// your router.
+ UnexpectedError,
+}
+
+impl_writeable_tlv_based_enum!(PaymentFailureReason,
+ (0, RecipientRejected) => {},
+ (2, UserAbandoned) => {},
+ (4, RetriesExhausted) => {},
+ (6, PaymentExpired) => {},
+ (8, RouteNotFound) => {},
+ (10, UnexpectedError) => {}, ;
+);
+
/// An Event which you should probably take some action in response to.
///
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use