@@ -4270,8 +4270,12 @@ where
4270
4270
///
4271
4271
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
4272
4272
pub fn abandon_payment(&self, payment_id: PaymentId) {
4273
+ self.abandon_payment_with_reason(payment_id, PaymentFailureReason::UserAbandoned)
4274
+ }
4275
+
4276
+ fn abandon_payment_with_reason(&self, payment_id: PaymentId, reason: PaymentFailureReason) {
4273
4277
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4274
- self.pending_outbound_payments.abandon_payment(payment_id, PaymentFailureReason::UserAbandoned , &self.pending_events);
4278
+ self.pending_outbound_payments.abandon_payment(payment_id, reason , &self.pending_events);
4275
4279
}
4276
4280
4277
4281
/// Send a spontaneous payment, which is a payment that does not require the recipient to have
@@ -10721,17 +10725,6 @@ where
10721
10725
let secp_ctx = &self.secp_ctx;
10722
10726
let expanded_key = &self.inbound_payment_key;
10723
10727
10724
- let abandon_if_payment = |context| {
10725
- match context {
10726
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac }) => {
10727
- if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
10728
- self.abandon_payment(payment_id);
10729
- }
10730
- },
10731
- _ => {},
10732
- }
10733
- };
10734
-
10735
10728
match message {
10736
10729
OffersMessage::InvoiceRequest(invoice_request) => {
10737
10730
let responder = match responder {
@@ -10851,7 +10844,9 @@ where
10851
10844
logger, "Invoice requires unknown features: {:?}",
10852
10845
invoice.invoice_features(),
10853
10846
);
10854
- abandon_if_payment(context);
10847
+ self.abandon_payment_with_reason(
10848
+ payment_id, PaymentFailureReason::UnknownRequiredFeatures,
10849
+ );
10855
10850
10856
10851
let error = InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures);
10857
10852
let response = match responder {
@@ -10908,10 +10903,21 @@ where
10908
10903
Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
10909
10904
_ => None,
10910
10905
};
10906
+
10911
10907
let logger = WithContext::from(&self.logger, None, None, payment_hash);
10912
10908
log_trace!(logger, "Received invoice_error: {}", invoice_error);
10913
10909
10914
- abandon_if_payment(context);
10910
+ match context {
10911
+ Some(OffersContext::OutboundPayment { payment_id, nonce, hmac }) => {
10912
+ if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
10913
+ self.abandon_payment_with_reason(
10914
+ payment_id, PaymentFailureReason::RecipientRejected,
10915
+ );
10916
+ }
10917
+ },
10918
+ _ => {},
10919
+ }
10920
+
10915
10921
ResponseInstruction::NoResponse
10916
10922
},
10917
10923
}
0 commit comments