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