@@ -270,6 +270,45 @@ 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 the reason a retry
284
+ /// attempt failed while being forwarded along the path, a [`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. If the user chooses to include an
290
+ /// [`PaymentParameters::expiry_time`] in their [`PaymentParameters`] this payment will be
291
+ /// failed if it is retried after this time has elapsed.
292
+ ///
293
+ /// [`PaymentParameters`]: crate::routing::router::PaymentParameters
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
+
273
312
/// An Event which you should probably take some action in response to.
274
313
///
275
314
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
0 commit comments