@@ -4270,8 +4270,12 @@ where
42704270 ///
42714271 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
42724272 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) {
42734277 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);
42754279 }
42764280
42774281 /// Send a spontaneous payment, which is a payment that does not require the recipient to have
@@ -10721,17 +10725,6 @@ where
1072110725 let secp_ctx = &self.secp_ctx;
1072210726 let expanded_key = &self.inbound_payment_key;
1072310727
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-
1073510728 match message {
1073610729 OffersMessage::InvoiceRequest(invoice_request) => {
1073710730 let responder = match responder {
@@ -10851,7 +10844,9 @@ where
1085110844 logger, "Invoice requires unknown features: {:?}",
1085210845 invoice.invoice_features(),
1085310846 );
10854- abandon_if_payment(context);
10847+ self.abandon_payment_with_reason(
10848+ payment_id, PaymentFailureReason::UnknownRequiredFeatures,
10849+ );
1085510850
1085610851 let error = InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures);
1085710852 let response = match responder {
@@ -10908,10 +10903,21 @@ where
1090810903 Some(OffersContext::InboundPayment { payment_hash }) => Some(payment_hash),
1090910904 _ => None,
1091010905 };
10906+
1091110907 let logger = WithContext::from(&self.logger, None, None, payment_hash);
1091210908 log_trace!(logger, "Received invoice_error: {}", invoice_error);
1091310909
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+
1091510921 ResponseInstruction::NoResponse
1091610922 },
1091710923 }
0 commit comments