@@ -10853,43 +10853,51 @@ where
10853
10853
&self.logger, None, None, Some(invoice.payment_hash()),
10854
10854
);
10855
10855
10856
- let result = {
10857
- let features = self.bolt12_invoice_features();
10858
- if invoice.invoice_features().requires_unknown_bits_from(&features) {
10859
- Err(InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures))
10860
- } else if self.default_configuration.manually_handle_bolt12_invoices {
10861
- let event = Event::InvoiceReceived {
10862
- payment_id, invoice, context, responder,
10863
- };
10864
- self.pending_events.lock().unwrap().push_back((event, None));
10865
- return ResponseInstruction::NoResponse;
10866
- } else {
10867
- self.send_payment_for_verified_bolt12_invoice(&invoice, payment_id)
10868
- .map_err(|e| {
10869
- log_trace!(logger, "Failed paying invoice: {:?}", e);
10870
- InvoiceError::from_string(format!("{:?}", e))
10871
- })
10872
- }
10873
- };
10856
+ let features = self.bolt12_invoice_features();
10857
+ if invoice.invoice_features().requires_unknown_bits_from(&features) {
10858
+ log_trace!(
10859
+ logger, "Invoice requires unknown features: {:?}",
10860
+ invoice.invoice_features(),
10861
+ );
10862
+ abandon_if_payment(context);
10874
10863
10875
- match result {
10876
- Ok(_) => ResponseInstruction::NoResponse,
10877
- Err(err) => match responder {
10878
- Some(responder) => {
10879
- abandon_if_payment(context);
10880
- responder.respond(OffersMessage::InvoiceError(err))
10881
- },
10864
+ let error = InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures);
10865
+ let response = match responder {
10866
+ Some(responder) => responder.respond(OffersMessage::InvoiceError(error)),
10882
10867
None => {
10883
- abandon_if_payment(context);
10884
- log_trace!(
10885
- logger,
10886
- "An error response was generated, but there is no reply_path specified \
10887
- for sending the response. Error: {}",
10888
- err
10889
- );
10890
- return ResponseInstruction::NoResponse;
10868
+ log_trace!(logger, "No reply path to send error: {:?}", error);
10869
+ ResponseInstruction::NoResponse
10891
10870
},
10871
+ };
10872
+ return response;
10873
+ }
10874
+
10875
+ if self.default_configuration.manually_handle_bolt12_invoices {
10876
+ let event = Event::InvoiceReceived {
10877
+ payment_id, invoice, context, responder,
10878
+ };
10879
+ self.pending_events.lock().unwrap().push_back((event, None));
10880
+ return ResponseInstruction::NoResponse;
10881
+ }
10882
+
10883
+ match self.send_payment_for_verified_bolt12_invoice(&invoice, payment_id) {
10884
+ // Payments with SendingFailed error will already have been abandoned.
10885
+ Err(Bolt12PaymentError::SendingFailed(e)) => {
10886
+ log_trace!(logger, "Failed paying invoice: {:?}", e);
10887
+
10888
+ let err = InvoiceError::from_string(format!("{:?}", e));
10889
+ match responder {
10890
+ Some(responder) => responder.respond(OffersMessage::InvoiceError(err)),
10891
+ None => {
10892
+ log_trace!(logger, "No reply path to send error: {:?}", err);
10893
+ ResponseInstruction::NoResponse
10894
+ },
10895
+ }
10892
10896
},
10897
+ // Otherwise, don't abandon unknown, pending, or successful payments.
10898
+ Err(Bolt12PaymentError::UnexpectedInvoice)
10899
+ | Err(Bolt12PaymentError::DuplicateInvoice)
10900
+ | Ok(()) => ResponseInstruction::NoResponse,
10893
10901
}
10894
10902
},
10895
10903
#[cfg(async_payments)]
0 commit comments