@@ -153,8 +153,9 @@ where
153
153
/// If we are an async recipient, on startup we'll interactively build offers and static invoices
154
154
/// with an always-online node that will serve static invoices on our behalf. Once the offer is
155
155
/// built and the static invoice is confirmed as persisted by the server, the underlying
156
- /// [`AsyncReceiveOfferCache`] should be persisted so we remember the offers we've built.
157
- pub ( crate ) fn with_async_payments_offers_cache (
156
+ /// [`AsyncReceiveOfferCache`] should be persisted using
157
+ /// [`Self::writeable_async_receive_offer_cache`] so we remember the offers we've built.
158
+ pub fn with_async_payments_offers_cache (
158
159
mut self , async_receive_offer_cache : AsyncReceiveOfferCache ,
159
160
) -> Self {
160
161
self . paths_to_static_invoice_server =
@@ -170,7 +171,7 @@ where
170
171
/// This method only needs to be called once when the server first takes on the recipient as a
171
172
/// client, or when the paths change, e.g. if the paths are set to expire at a particular time.
172
173
#[ cfg( async_payments) ]
173
- pub ( crate ) fn set_paths_to_static_invoice_server (
174
+ pub fn set_paths_to_static_invoice_server (
174
175
& self , paths_to_static_invoice_server : Vec < BlindedMessagePath > ,
175
176
) -> Result < ( ) , ( ) > {
176
177
// Store the paths in the async receive cache so they are persisted with the cache, but also
@@ -286,7 +287,7 @@ where
286
287
///
287
288
/// Errors if blinded path creation fails or the provided `recipient_id` is larger than 1KiB.
288
289
#[ cfg( async_payments) ]
289
- pub ( crate ) fn blinded_paths_for_async_recipient (
290
+ pub fn blinded_paths_for_async_recipient (
290
291
& self , recipient_id : Vec < u8 > , relative_expiry : Option < Duration > ,
291
292
peers : Vec < MessageForwardNode > ,
292
293
) -> Result < Vec < BlindedMessagePath > , ( ) > {
@@ -1113,9 +1114,11 @@ where
1113
1114
Ok ( ( ) )
1114
1115
}
1115
1116
1116
- /// Forwards a [`StaticInvoice`] over the provided `responder`.
1117
+ /// Forwards a [`StaticInvoice`] over the provided [`Responder`] in response to an
1118
+ /// [`InvoiceRequest`] that we as a static invoice server received on behalf of an often-offline
1119
+ /// recipient.
1117
1120
#[ cfg( async_payments) ]
1118
- pub ( crate ) fn enqueue_static_invoice (
1121
+ pub fn enqueue_static_invoice (
1119
1122
& self , invoice : StaticInvoice , responder : Responder ,
1120
1123
) -> Result < ( ) , Bolt12SemanticError > {
1121
1124
let duration_since_epoch = self . duration_since_epoch ( ) ;
@@ -1226,8 +1229,11 @@ where
1226
1229
/// Retrieve an [`Offer`] for receiving async payments as an often-offline recipient. Will only
1227
1230
/// return an offer if [`Self::set_paths_to_static_invoice_server`] was called and we succeeded in
1228
1231
/// interactively building a [`StaticInvoice`] with the static invoice server.
1232
+ ///
1233
+ /// Returns the requested offer as well as a bool indicating whether the cache needs to be
1234
+ /// persisted using [`Self::writeable_async_receive_offer_cache`].
1229
1235
#[ cfg( async_payments) ]
1230
- pub ( crate ) fn get_async_receive_offer ( & self ) -> Result < ( Offer , bool ) , ( ) > {
1236
+ pub fn get_async_receive_offer ( & self ) -> Result < ( Offer , bool ) , ( ) > {
1231
1237
let mut cache = self . async_receive_offer_cache . lock ( ) . unwrap ( ) ;
1232
1238
cache. get_async_receive_offer ( self . duration_since_epoch ( ) )
1233
1239
}
@@ -1249,7 +1255,7 @@ where
1249
1255
///
1250
1256
/// Errors if we failed to create blinded reply paths when sending an [`OfferPathsRequest`] message.
1251
1257
#[ cfg( async_payments) ]
1252
- pub ( crate ) fn check_refresh_async_receive_offer_cache < ES : Deref , R : Deref > (
1258
+ pub fn check_refresh_async_receive_offer_cache < ES : Deref , R : Deref > (
1253
1259
& self , peers : Vec < MessageForwardNode > , usable_channels : Vec < ChannelDetails > , entropy : ES ,
1254
1260
router : R , timer_tick_occurred : bool ,
1255
1261
) -> Result < ( ) , ( ) >
@@ -1385,7 +1391,7 @@ where
1385
1391
/// wants us (the static invoice server) to serve [`StaticInvoice`]s to payers on their behalf.
1386
1392
/// Sends out [`OfferPaths`] onion messages in response.
1387
1393
#[ cfg( async_payments) ]
1388
- pub ( crate ) fn handle_offer_paths_request < ES : Deref > (
1394
+ pub fn handle_offer_paths_request < ES : Deref > (
1389
1395
& self , context : AsyncPaymentsContext , peers : Vec < MessageForwardNode > , entropy_source : ES ,
1390
1396
) -> Option < ( OfferPaths , MessageContext ) >
1391
1397
where
@@ -1448,7 +1454,7 @@ where
1448
1454
/// Returns `None` if we have enough offers cached already, verification of `message` fails, or we
1449
1455
/// fail to create blinded paths.
1450
1456
#[ cfg( async_payments) ]
1451
- pub ( crate ) fn handle_offer_paths < ES : Deref , R : Deref > (
1457
+ pub fn handle_offer_paths < ES : Deref , R : Deref > (
1452
1458
& self , message : OfferPaths , context : AsyncPaymentsContext , responder : Responder ,
1453
1459
peers : Vec < MessageForwardNode > , usable_channels : Vec < ChannelDetails > , entropy : ES ,
1454
1460
router : R ,
@@ -1599,7 +1605,7 @@ where
1599
1605
/// the static invoice from the database.
1600
1606
///
1601
1607
/// Errors if the [`ServeStaticInvoice::invoice`] is expired or larger than
1602
- /// [`MAX_STATIC_INVOICE_SIZE_BYTES`], or if blinded path verification fails .
1608
+ /// [`MAX_STATIC_INVOICE_SIZE_BYTES`].
1603
1609
///
1604
1610
/// [`ServeStaticInvoice::invoice`]: crate::onion_message::async_payments::ServeStaticInvoice::invoice
1605
1611
#[ cfg( async_payments) ]
@@ -1641,17 +1647,18 @@ where
1641
1647
}
1642
1648
1643
1649
/// Handles an incoming [`StaticInvoicePersisted`] onion message from the static invoice server.
1644
- /// Returns a bool indicating whether the async receive offer cache needs to be re-persisted.
1650
+ /// Returns a bool indicating whether the async receive offer cache needs to be re-persisted using
1651
+ /// [`Self::writeable_async_receive_offer_cache`].
1645
1652
///
1646
1653
/// [`StaticInvoicePersisted`]: crate::onion_message::async_payments::StaticInvoicePersisted
1647
1654
#[ cfg( async_payments) ]
1648
- pub ( crate ) fn handle_static_invoice_persisted ( & self , context : AsyncPaymentsContext ) -> bool {
1655
+ pub fn handle_static_invoice_persisted ( & self , context : AsyncPaymentsContext ) -> bool {
1649
1656
let mut cache = self . async_receive_offer_cache . lock ( ) . unwrap ( ) ;
1650
1657
cache. static_invoice_persisted ( context, self . duration_since_epoch ( ) )
1651
1658
}
1652
1659
1653
- /// Get the `AsyncReceiveOfferCache` for persistence.
1654
- pub ( crate ) fn writeable_async_receive_offer_cache ( & self ) -> impl Writeable + ' _ {
1655
- & self . async_receive_offer_cache
1660
+ /// Get the [ `AsyncReceiveOfferCache`] for persistence.
1661
+ pub fn writeable_async_receive_offer_cache ( & self ) -> impl Writeable + ' _ {
1662
+ self . async_receive_offer_cache . encode ( )
1656
1663
}
1657
1664
}
0 commit comments