@@ -75,6 +75,8 @@ use crate::util::string::UntrustedString;
75
75
use crate::util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
76
76
use crate::util::logger::{Level, Logger, WithContext};
77
77
use crate::util::errors::APIError;
78
+ use super::onion_utils::construct_invoice_request_message;
79
+
78
80
#[cfg(not(c_bindings))]
79
81
use {
80
82
crate::offers::offer::DerivedMetadata,
@@ -6030,6 +6032,28 @@ where
6030
6032
});
6031
6033
}
6032
6034
6035
+ /// Performs actions that should happen roughly once every 5 seconds.
6036
+ ///
6037
+ /// Currently, this includes retrying the sending of [`InvoiceRequest`] messages using newly
6038
+ /// generated `reply_path` for payments that are still awaiting their corresponding
6039
+ /// [`Bolt12Invoice`].
6040
+ ///
6041
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
6042
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
6043
+ fn retry_invoice_request_messages(&self) {
6044
+ let invoice_requests = self.pending_outbound_payments.get_invoice_request_awaiting_invoice();
6045
+
6046
+ if invoice_requests.is_empty() { return; }
6047
+
6048
+ if let Ok(reply_path) = self.create_blinded_path() {
6049
+ let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
6050
+
6051
+ for invoice_request in invoice_requests {
6052
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path.clone()));
6053
+ }
6054
+ }
6055
+ }
6056
+
6033
6057
/// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
6034
6058
/// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
6035
6059
/// along the path (including in our own channel on which we received it).
@@ -8765,27 +8789,7 @@ where
8765
8789
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
8766
8790
8767
8791
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
8768
- if offer.paths().is_empty() {
8769
- let message = new_pending_onion_message(
8770
- OffersMessage::InvoiceRequest(invoice_request),
8771
- Destination::Node(offer.signing_pubkey()),
8772
- Some(reply_path),
8773
- );
8774
- pending_offers_messages.push(message);
8775
- } else {
8776
- // Send as many invoice requests as there are paths in the offer (with an upper bound).
8777
- // Using only one path could result in a failure if the path no longer exists. But only
8778
- // one invoice for a given payment id will be paid, even if more than one is received.
8779
- const REQUEST_LIMIT: usize = 10;
8780
- for path in offer.paths().into_iter().take(REQUEST_LIMIT) {
8781
- let message = new_pending_onion_message(
8782
- OffersMessage::InvoiceRequest(invoice_request.clone()),
8783
- Destination::BlindedPath(path.clone()),
8784
- Some(reply_path.clone()),
8785
- );
8786
- pending_offers_messages.push(message);
8787
- }
8788
- }
8792
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path));
8789
8793
8790
8794
Ok(())
8791
8795
}
0 commit comments