@@ -76,6 +76,8 @@ 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;
80
+
79
81
#[cfg(not(c_bindings))]
80
82
use {
81
83
crate::offers::offer::DerivedMetadata,
@@ -6010,6 +6012,20 @@ where
6010
6012
});
6011
6013
}
6012
6014
6015
+ pub fn retry_tick_occurred(&self) {
6016
+ let invoice_requests = self.pending_outbound_payments.get_invoice_request_awaiting_invoice();
6017
+
6018
+ if invoice_requests.is_empty() { return; }
6019
+
6020
+ if let Ok(reply_path) = self.create_blinded_path() {
6021
+ let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
6022
+
6023
+ for invoice_request in invoice_requests {
6024
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path.clone()));
6025
+ }
6026
+ }
6027
+ }
6028
+
6013
6029
/// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
6014
6030
/// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
6015
6031
/// along the path (including in our own channel on which we received it).
@@ -8745,27 +8761,7 @@ where
8745
8761
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
8746
8762
8747
8763
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
8748
- if offer.paths().is_empty() {
8749
- let message = new_pending_onion_message(
8750
- OffersMessage::InvoiceRequest(invoice_request),
8751
- Destination::Node(offer.signing_pubkey()),
8752
- Some(reply_path),
8753
- );
8754
- pending_offers_messages.push(message);
8755
- } else {
8756
- // Send as many invoice requests as there are paths in the offer (with an upper bound).
8757
- // Using only one path could result in a failure if the path no longer exists. But only
8758
- // one invoice for a given payment id will be paid, even if more than one is received.
8759
- const REQUEST_LIMIT: usize = 10;
8760
- for path in offer.paths().into_iter().take(REQUEST_LIMIT) {
8761
- let message = new_pending_onion_message(
8762
- OffersMessage::InvoiceRequest(invoice_request.clone()),
8763
- Destination::BlindedPath(path.clone()),
8764
- Some(reply_path.clone()),
8765
- );
8766
- pending_offers_messages.push(message);
8767
- }
8768
- }
8764
+ pending_offers_messages.extend(construct_invoice_request_message(invoice_request, reply_path));
8769
8765
8770
8766
Ok(())
8771
8767
}
0 commit comments