@@ -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
@@ -10722,17 +10726,6 @@ where
10722
10726
let secp_ctx = &self.secp_ctx;
10723
10727
let expanded_key = &self.inbound_payment_key;
10724
10728
10725
- let abandon_if_payment = |context| {
10726
- match context {
10727
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac }) => {
10728
- if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
10729
- self.abandon_payment(payment_id);
10730
- }
10731
- },
10732
- _ => {},
10733
- }
10734
- };
10735
-
10736
10729
match message {
10737
10730
OffersMessage::InvoiceRequest(invoice_request) => {
10738
10731
let responder = match responder {
@@ -10852,7 +10845,9 @@ where
10852
10845
logger, "Invoice requires unknown features: {:?}",
10853
10846
invoice.invoice_features(),
10854
10847
);
10855
- abandon_if_payment(context);
10848
+ self.abandon_payment_with_reason(
10849
+ payment_id, PaymentFailureReason::UnknownRequiredFeatures,
10850
+ );
10856
10851
10857
10852
let error = InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures);
10858
10853
let response = match responder {
@@ -10909,10 +10904,21 @@ where
10909
10904
Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
10910
10905
_ => None,
10911
10906
};
10907
+
10912
10908
let logger = WithContext::from(&self.logger, None, None, payment_hash);
10913
10909
log_trace!(logger, "Received invoice_error: {}", invoice_error);
10914
10910
10915
- abandon_if_payment(context);
10911
+ match context {
10912
+ Some(OffersContext::OutboundPayment { payment_id, nonce, hmac }) => {
10913
+ if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
10914
+ self.abandon_payment_with_reason(
10915
+ payment_id, PaymentFailureReason::RecipientRejected,
10916
+ );
10917
+ }
10918
+ },
10919
+ _ => {},
10920
+ }
10921
+
10916
10922
ResponseInstruction::NoResponse
10917
10923
},
10918
10924
}
0 commit comments