/// The reason the payment failed. Used in [`Event::PaymentFailed`].
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PaymentFailureReason {
- /// The intended recipient rejected our payment or invoice request.
+ /// The intended recipient rejected our payment.
RecipientRejected,
/// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`].
///
UnknownRequiredFeatures,
/// A [`Bolt12Invoice`] was not received in a reasonable amount of time.
InvoiceRequestExpired,
+ /// An [`InvoiceRequest`] for the payment was rejected by the recipient.
+ ///
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ InvoiceRequestRejected,
}
impl_writeable_tlv_based_enum!(PaymentFailureReason,
(2, UserAbandoned) => {},
(3, InvoiceRequestExpired) => {},
(4, RetriesExhausted) => {},
+ (5, InvoiceRequestRejected) => {},
(6, PaymentExpired) => {},
(8, RouteNotFound) => {},
(10, UnexpectedError) => {},
Some(OffersContext::OutboundPayment { payment_id, nonce, hmac: Some(hmac) }) => {
if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
self.abandon_payment_with_reason(
- payment_id, PaymentFailureReason::RecipientRejected,
+ payment_id, PaymentFailureReason::InvoiceRequestRejected,
);
}
},
// Confirm that david drops this failed payment from his pending outbound payments.
match get_event!(david, Event::PaymentFailed) {
- Event::PaymentFailed { payment_id: actual_payment_id, .. } => {
+ Event::PaymentFailed { payment_id: actual_payment_id, reason, .. } => {
assert_eq!(payment_id, actual_payment_id);
+ assert_eq!(reason, Some(PaymentFailureReason::InvoiceRequestRejected));
},
_ => panic!("No Event::PaymentFailed"),
}