@@ -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,
@@ -6022,6 +6024,27 @@ where
6022
6024
});
6023
6025
}
6024
6026
6027
+ /// Performs actions that should happen roughly once every 5 seconds.
6028
+ ///
6029
+ /// Currently, this includes retrying the sending of [`InvoiceRequest`] messages using newly
6030
+ /// generated `reply_path` for payments that are still awaiting their corresponding
6031
+ /// [`Bolt12Invoice`].
6032
+ ///
6033
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
6034
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
6035
+ fn retry_invoice_request_messages(&self) -> Result<(), Bolt12SemanticError> {
6036
+ let invoice_requests = self.pending_outbound_payments.get_invoice_request_awaiting_invoice();
6037
+ if invoice_requests.is_empty() { return Ok(()); }
6038
+ if let Ok(reply_path) = self.create_blinded_path() {
6039
+ let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
6040
+
6041
+ for invoice_request in invoice_requests {
6042
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path.clone())?);
6043
+ }
6044
+ }
6045
+ Ok(())
6046
+ }
6047
+
6025
6048
/// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
6026
6049
/// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
6027
6050
/// along the path (including in our own channel on which we received it).
@@ -8757,30 +8780,7 @@ where
8757
8780
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
8758
8781
8759
8782
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
8760
- if !offer.paths().is_empty() {
8761
- // Send as many invoice requests as there are paths in the offer (with an upper bound).
8762
- // Using only one path could result in a failure if the path no longer exists. But only
8763
- // one invoice for a given payment id will be paid, even if more than one is received.
8764
- const REQUEST_LIMIT: usize = 10;
8765
- for path in offer.paths().into_iter().take(REQUEST_LIMIT) {
8766
- let message = new_pending_onion_message(
8767
- OffersMessage::InvoiceRequest(invoice_request.clone()),
8768
- Destination::BlindedPath(path.clone()),
8769
- Some(reply_path.clone()),
8770
- );
8771
- pending_offers_messages.push(message);
8772
- }
8773
- } else if let Some(signing_pubkey) = offer.signing_pubkey() {
8774
- let message = new_pending_onion_message(
8775
- OffersMessage::InvoiceRequest(invoice_request),
8776
- Destination::Node(signing_pubkey),
8777
- Some(reply_path),
8778
- );
8779
- pending_offers_messages.push(message);
8780
- } else {
8781
- debug_assert!(false);
8782
- return Err(Bolt12SemanticError::MissingSigningPubkey);
8783
- }
8783
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path)?);
8784
8784
8785
8785
Ok(())
8786
8786
}
0 commit comments