@@ -76,6 +76,7 @@ use crate::util::string::UntrustedString;
76
76
use crate::util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
77
77
use crate::util::logger::{Level, Logger, WithContext};
78
78
use crate::util::errors::APIError;
79
+ use super::onion_utils::construct_invoice_request_message;
79
80
80
81
#[cfg(not(c_bindings))]
81
82
use {
@@ -6043,6 +6044,27 @@ where
6043
6044
});
6044
6045
}
6045
6046
6047
+ /// Performs actions that should happen roughly once every 5 seconds.
6048
+ ///
6049
+ /// Currently, this includes retrying the sending of [`InvoiceRequest`] messages using newly
6050
+ /// generated `reply_path` for payments that are still awaiting their corresponding
6051
+ /// [`Bolt12Invoice`].
6052
+ ///
6053
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
6054
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
6055
+ fn retry_invoice_request_messages(&self) -> Result<(), Bolt12SemanticError> {
6056
+ let invoice_requests = self.pending_outbound_payments.get_invoice_request_awaiting_invoice();
6057
+ if invoice_requests.is_empty() { return Ok(()); }
6058
+ if let Ok(reply_path) = self.create_blinded_path() {
6059
+ let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
6060
+
6061
+ for invoice_request in invoice_requests {
6062
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path.clone())?);
6063
+ }
6064
+ }
6065
+ Ok(())
6066
+ }
6067
+
6046
6068
/// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
6047
6069
/// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
6048
6070
/// along the path (including in our own channel on which we received it).
@@ -8777,30 +8799,7 @@ where
8777
8799
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
8778
8800
8779
8801
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
8780
- if !offer.paths().is_empty() {
8781
- // Send as many invoice requests as there are paths in the offer (with an upper bound).
8782
- // Using only one path could result in a failure if the path no longer exists. But only
8783
- // one invoice for a given payment id will be paid, even if more than one is received.
8784
- const REQUEST_LIMIT: usize = 10;
8785
- for path in offer.paths().into_iter().take(REQUEST_LIMIT) {
8786
- let message = new_pending_onion_message(
8787
- OffersMessage::InvoiceRequest(invoice_request.clone()),
8788
- Destination::BlindedPath(path.clone()),
8789
- Some(reply_path.clone()),
8790
- );
8791
- pending_offers_messages.push(message);
8792
- }
8793
- } else if let Some(signing_pubkey) = offer.signing_pubkey() {
8794
- let message = new_pending_onion_message(
8795
- OffersMessage::InvoiceRequest(invoice_request),
8796
- Destination::Node(signing_pubkey),
8797
- Some(reply_path),
8798
- );
8799
- pending_offers_messages.push(message);
8800
- } else {
8801
- debug_assert!(false);
8802
- return Err(Bolt12SemanticError::MissingSigningPubkey);
8803
- }
8802
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path)?);
8804
8803
8805
8804
Ok(())
8806
8805
}
0 commit comments