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