@@ -270,6 +270,41 @@ 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 payment failed while being forwarded along the path. A [`Event::PaymentPathFailed`]
279
+ /// should have come before this.
280
+ FailedAlongPath ,
281
+ /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`].
282
+ ///
283
+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
284
+ UserAbandoned ,
285
+ /// We exhausted all of our retry attempts while trying to send the payment, or we
286
+ /// exhausted the `Retry::Timeout` if the user set one.
287
+ ExhaustedRetryAttempts ,
288
+ /// The payment expired while retrying. If the user chooses to include an `expiry_time` in their
289
+ /// `PaymentParams` this payment will be failed if it is retried after this time has elapsed.
290
+ PaymentExpired ,
291
+ /// We failed to find a route while retrying the payment.
292
+ FailedRoutingRetry ,
293
+ /// This error should generally never happen. This likely means that there is a problem with
294
+ /// your router.
295
+ UnexpectedError ,
296
+ }
297
+
298
+ impl_writeable_tlv_based_enum_upgradable ! ( PaymentFailureReason ,
299
+ ( 0 , RecipientRejected ) => { } ,
300
+ ( 2 , FailedAlongPath ) => { } ,
301
+ ( 4 , UserAbandoned ) => { } ,
302
+ ( 6 , ExhaustedRetryAttempts ) => { } ,
303
+ ( 8 , PaymentExpired ) => { } ,
304
+ ( 10 , FailedRoutingRetry ) => { } ,
305
+ ( 12 , UnexpectedError ) => { } ,
306
+ ) ;
307
+
273
308
/// An Event which you should probably take some action in response to.
274
309
///
275
310
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
0 commit comments