@@ -10318,9 +10318,23 @@ where
10318
10318
#[cfg(c_bindings)]
10319
10319
create_refund_builder!(self, RefundMaybeWithDerivedMetadataBuilder);
10320
10320
10321
+ /// Retrieve our cached [`Offer`] for receiving async payments as an often-offline recipient. Will
10322
+ /// only be set if [`UserConfig::paths_to_static_invoice_server`] is set and we succeeded in
10323
+ /// interactively building a [`StaticInvoice`] with the static invoice server.
10324
+ #[cfg(async_payments)]
10325
+ pub fn get_cached_async_receive_offer(&self) -> Option<Offer> {
10326
+ let mut offer_cache = self.async_receive_offer_cache.lock().unwrap();
10327
+ offer_cache.check_expire_offer(self.duration_since_epoch());
10328
+
10329
+ offer_cache.offer.clone()
10330
+ }
10331
+
10321
10332
/// Create an offer for receiving async payments as an often-offline recipient.
10322
10333
///
10323
- /// Because we may be offline when the payer attempts to request an invoice, you MUST:
10334
+ /// Instead of using this method, prefer to set [`UserConfig::paths_to_static_invoice_server`] and
10335
+ /// retrieve the automatically built offer via [`Self::get_cached_async_receive_offer`].
10336
+ ///
10337
+ /// If you want to build the [`StaticInvoice`] manually using this method instead, you MUST:
10324
10338
/// 1. Provide at least 1 [`BlindedMessagePath`] terminating at an always-online node that will
10325
10339
/// serve the [`StaticInvoice`] created from this offer on our behalf.
10326
10340
/// 2. Use [`Self::create_static_invoice_builder`] to create a [`StaticInvoice`] from this
@@ -10354,6 +10368,10 @@ where
10354
10368
/// Creates a [`StaticInvoiceBuilder`] from the corresponding [`Offer`] and [`Nonce`] that were
10355
10369
/// created via [`Self::create_async_receive_offer_builder`]. If `relative_expiry` is unset, the
10356
10370
/// invoice's expiry will default to [`STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY`].
10371
+ ///
10372
+ /// Instead of using this method to manually build the invoice, prefer to set
10373
+ /// [`UserConfig::paths_to_static_invoice_server`] and retrieve the automatically built offer via
10374
+ /// [`Self::get_cached_async_receive_offer`].
10357
10375
#[cfg(async_payments)]
10358
10376
pub fn create_static_invoice_builder<'a>(
10359
10377
&self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>
0 commit comments