@@ -61,10 +61,7 @@ use crate::sync::{Mutex, RwLock};
6161use crate :: types:: payment:: { PaymentHash , PaymentSecret } ;
6262use crate :: util:: logger:: Logger ;
6363use crate :: util:: ser:: Writeable ;
64- #[ cfg( feature = "std" ) ]
65- use crate :: util:: wakers:: Future ;
66- #[ cfg( feature = "std" ) ]
67- use crate :: util:: wakers:: Notifier ;
64+ use crate :: util:: wakers:: { Future , Notifier } ;
6865
6966/// A BOLT12 offers code and flow utility provider, which facilitates
7067/// BOLT12 builder generation and onion message handling.
@@ -91,7 +88,6 @@ pub struct OffersMessageFlow<MR: MessageRouter, L: Logger> {
9188
9289 pending_async_payments_messages : Mutex < Vec < ( AsyncPaymentsMessage , MessageSendInstructions ) > > ,
9390 async_receive_offer_cache : Mutex < AsyncReceiveOfferCache > ,
94- #[ cfg( feature = "std" ) ]
9591 async_receive_offer_ready_notifier : Notifier ,
9692
9793 logger : L ,
@@ -122,7 +118,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
122118 pending_async_payments_messages : Mutex :: new ( Vec :: new ( ) ) ,
123119
124120 async_receive_offer_cache : Mutex :: new ( AsyncReceiveOfferCache :: new ( ) ) ,
125- #[ cfg( feature = "std" ) ]
126121 async_receive_offer_ready_notifier : Notifier :: new ( ) ,
127122
128123 logger,
@@ -1369,6 +1364,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
13691364 Some ( idx) => idx,
13701365 None => return Ok ( ( ) ) ,
13711366 } ;
1367+
13721368 // If we need new offers, send out offer paths request messages to the static invoice server.
13731369 let context = MessageContext :: AsyncPayments ( AsyncPaymentsContext :: OfferPaths {
13741370 path_absolute_expiry : duration_since_epoch
@@ -1482,6 +1478,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
14821478 } ,
14831479 _ => return None ,
14841480 } ;
1481+
14851482 // Create the blinded paths that will be included in the async recipient's offer.
14861483 let ( offer_paths, paths_expiry) = {
14871484 let path_absolute_expiry =
@@ -1543,6 +1540,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15431540 } ,
15441541 _ => return None ,
15451542 } ;
1543+
15461544 {
15471545 // Only respond with `ServeStaticInvoice` if we actually need a new offer built.
15481546 let mut cache = self . async_receive_offer_cache . lock ( ) . unwrap ( ) ;
@@ -1574,6 +1572,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15741572 return None ;
15751573 } ,
15761574 } ;
1575+
15771576 let ( invoice, forward_invoice_request_path) = match self . create_static_invoice_for_server (
15781577 & offer,
15791578 offer_nonce,
@@ -1587,6 +1586,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15871586 return None ;
15881587 } ,
15891588 } ;
1589+
15901590 if let Err ( ( ) ) = self . async_receive_offer_cache . lock ( ) . unwrap ( ) . cache_pending_offer (
15911591 offer,
15921592 message. paths_absolute_expiry ,
@@ -1598,6 +1598,7 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
15981598 log_error ! ( self . logger, "Failed to cache pending offer" ) ;
15991599 return None ;
16001600 }
1601+
16011602 let reply_path_context = {
16021603 MessageContext :: AsyncPayments ( AsyncPaymentsContext :: StaticInvoicePersisted {
16031604 offer_id,
@@ -1714,7 +1715,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
17141715 pub fn handle_static_invoice_persisted ( & self , context : AsyncPaymentsContext ) -> bool {
17151716 let mut cache = self . async_receive_offer_cache . lock ( ) . unwrap ( ) ;
17161717 let updated = cache. static_invoice_persisted ( context) ;
1717- #[ cfg( feature = "std" ) ]
17181718 if updated {
17191719 self . async_receive_offer_ready_notifier . notify ( ) ;
17201720 }
@@ -1727,7 +1727,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
17271727 /// Callers can either `.await` the returned [`Future`] in an async context or call
17281728 /// [`Future::wait_timeout`] from a synchronous context. After it completes, use
17291729 /// [`Self::get_async_receive_offer`] to retrieve the offer.
1730- #[ cfg( feature = "std" ) ]
17311730 pub fn get_async_receive_offer_ready_future ( & self ) -> Future {
17321731 self . async_receive_offer_ready_notifier . get_future ( )
17331732 }
0 commit comments