@@ -4275,8 +4275,12 @@ where
4275
4275
///
4276
4276
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
4277
4277
pub fn abandon_payment(&self, payment_id: PaymentId) {
4278
+ self.abandon_payment_with_reason(payment_id, PaymentFailureReason::UserAbandoned)
4279
+ }
4280
+
4281
+ fn abandon_payment_with_reason(&self, payment_id: PaymentId, reason: PaymentFailureReason) {
4278
4282
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4279
- self.pending_outbound_payments.abandon_payment(payment_id, PaymentFailureReason::UserAbandoned , &self.pending_events);
4283
+ self.pending_outbound_payments.abandon_payment(payment_id, reason , &self.pending_events);
4280
4284
}
4281
4285
4282
4286
/// Send a spontaneous payment, which is a payment that does not require the recipient to have
@@ -10729,17 +10733,6 @@ where
10729
10733
let secp_ctx = &self.secp_ctx;
10730
10734
let expanded_key = &self.inbound_payment_key;
10731
10735
10732
- let abandon_if_payment = |context| {
10733
- match context {
10734
- Some(OffersContext::OutboundPayment { payment_id, nonce, hmac }) => {
10735
- if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
10736
- self.abandon_payment(payment_id);
10737
- }
10738
- },
10739
- _ => {},
10740
- }
10741
- };
10742
-
10743
10736
match message {
10744
10737
OffersMessage::InvoiceRequest(invoice_request) => {
10745
10738
let responder = match responder {
@@ -10859,7 +10852,9 @@ where
10859
10852
logger, "Invoice requires unknown features: {:?}",
10860
10853
invoice.invoice_features(),
10861
10854
);
10862
- abandon_if_payment(context);
10855
+ self.abandon_payment_with_reason(
10856
+ payment_id, PaymentFailureReason::UnknownRequiredFeatures,
10857
+ );
10863
10858
10864
10859
let error = InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures);
10865
10860
let response = match responder {
@@ -10916,10 +10911,21 @@ where
10916
10911
Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
10917
10912
_ => None,
10918
10913
};
10914
+
10919
10915
let logger = WithContext::from(&self.logger, None, None, payment_hash);
10920
10916
log_trace!(logger, "Received invoice_error: {}", invoice_error);
10921
10917
10922
- abandon_if_payment(context);
10918
+ match context {
10919
+ Some(OffersContext::OutboundPayment { payment_id, nonce, hmac }) => {
10920
+ if signer::verify_payment_id(payment_id, hmac, nonce, expanded_key) {
10921
+ self.abandon_payment_with_reason(
10922
+ payment_id, PaymentFailureReason::RecipientRejected,
10923
+ );
10924
+ }
10925
+ },
10926
+ _ => {},
10927
+ }
10928
+
10923
10929
ResponseInstruction::NoResponse
10924
10930
},
10925
10931
}
0 commit comments