@@ -272,6 +272,43 @@ impl_writeable_tlv_based_enum!(InterceptNextHop,
272272 } ;
273273) ;
274274
275+ /// The reason the payment failed. Used in [`Event::PaymentFailed`].
276+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
277+ pub enum PaymentFailureReason {
278+ /// The intended recipient rejected our payment.
279+ RecipientRejected ,
280+ /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`].
281+ ///
282+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
283+ UserAbandoned ,
284+ /// We exhausted all of our retry attempts while trying to send the payment, or we
285+ /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry
286+ /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will
287+ /// have come before this.
288+ ///
289+ /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout
290+ RetriesExhausted ,
291+ /// The payment expired while retrying, based on the provided
292+ /// [`PaymentParameters::expiry_time`].
293+ ///
294+ /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
295+ PaymentExpired ,
296+ /// We failed to find a route while retrying the payment.
297+ RouteNotFound ,
298+ /// This error should generally never happen. This likely means that there is a problem with
299+ /// your router.
300+ UnexpectedError ,
301+ }
302+
303+ impl_writeable_tlv_based_enum ! ( PaymentFailureReason ,
304+ ( 0 , RecipientRejected ) => { } ,
305+ ( 2 , UserAbandoned ) => { } ,
306+ ( 4 , RetriesExhausted ) => { } ,
307+ ( 6 , PaymentExpired ) => { } ,
308+ ( 8 , RouteNotFound ) => { } ,
309+ ( 10 , UnexpectedError ) => { } , ;
310+ ) ;
311+
275312/// An Event which you should probably take some action in response to.
276313///
277314/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
0 commit comments