55// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66// accordance with one or both of these licenses.
77
8+ use crate :: static_invoice_store:: StaticInvoiceStore ;
89use crate :: types:: { CustomTlvRecord , DynStore , PaymentStore , Sweeper , Wallet } ;
910
1011use crate :: {
@@ -37,8 +38,6 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
3738use lightning:: impl_writeable_tlv_based_enum;
3839use lightning:: ln:: channelmanager:: PaymentId ;
3940use lightning:: ln:: types:: ChannelId ;
40- use lightning:: offers:: static_invoice:: StaticInvoice ;
41- use lightning:: onion_message:: messenger:: Responder ;
4241use lightning:: routing:: gossip:: NodeId ;
4342use lightning:: util:: config:: {
4443 ChannelConfigOverrides , ChannelConfigUpdate , ChannelHandshakeConfigUpdate ,
@@ -58,7 +57,7 @@ use rand::{thread_rng, Rng};
5857
5958use core:: future:: Future ;
6059use core:: task:: { Poll , Waker } ;
61- use std:: collections:: { HashMap , VecDeque } ;
60+ use std:: collections:: VecDeque ;
6261use std:: ops:: Deref ;
6362use std:: sync:: { Arc , Condvar , Mutex } ;
6463
@@ -463,31 +462,6 @@ where
463462 static_invoice_store : StaticInvoiceStore ,
464463}
465464
466- struct StaticInvoiceStore {
467- pub static_invoices : Mutex < HashMap < ( Vec < u8 > , u16 ) , StaticInvoice > > ,
468- }
469-
470- impl StaticInvoiceStore {
471- fn new ( ) -> Self {
472- Self { static_invoices : Mutex :: new ( HashMap :: new ( ) ) }
473- }
474-
475- fn handle_static_invoice_requested (
476- & self , recipient_id : Vec < u8 > , invoice_slot : u16 ,
477- ) -> Option < StaticInvoice > {
478- let map = self . static_invoices . lock ( ) . unwrap ( ) ;
479-
480- map. get ( & ( recipient_id. clone ( ) , invoice_slot) ) . cloned ( )
481- }
482-
483- fn handle_persist_static_invoice (
484- & self , invoice : StaticInvoice , invoice_slot : u16 , recipient_id : Vec < u8 > ,
485- ) {
486- let mut map = self . static_invoices . lock ( ) . unwrap ( ) ;
487- map. insert ( ( recipient_id, invoice_slot) , invoice) ;
488- }
489- }
490-
491465impl < L : Deref + Clone + Sync + Send + ' static > EventHandler < L >
492466where
493467 L :: Target : LdkLogger ,
@@ -498,8 +472,9 @@ where
498472 channel_manager : Arc < ChannelManager > , connection_manager : Arc < ConnectionManager < L > > ,
499473 output_sweeper : Arc < Sweeper > , network_graph : Arc < Graph > ,
500474 liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
501- payment_store : Arc < PaymentStore > , peer_store : Arc < PeerStore < L > > , runtime : Arc < Runtime > ,
502- logger : L , config : Arc < Config > ,
475+ payment_store : Arc < PaymentStore > , peer_store : Arc < PeerStore < L > > ,
476+ static_invoice_store : StaticInvoiceStore , runtime : Arc < Runtime > , logger : L ,
477+ config : Arc < Config > ,
503478 ) -> Self {
504479 Self {
505480 event_queue,
@@ -515,7 +490,7 @@ where
515490 logger,
516491 runtime,
517492 config,
518- static_invoice_store : StaticInvoiceStore :: new ( ) ,
493+ static_invoice_store,
519494 }
520495 }
521496
@@ -1530,18 +1505,17 @@ where
15301505 recipient_id,
15311506 invoice_persisted_path,
15321507 } => {
1533- self . static_invoice_store . handle_persist_static_invoice (
1534- invoice,
1535- invoice_slot,
1536- recipient_id,
1537- ) ;
1508+ self . static_invoice_store
1509+ . handle_persist_static_invoice ( invoice, invoice_slot, recipient_id)
1510+ . await ;
15381511
15391512 self . channel_manager . static_invoice_persisted ( invoice_persisted_path) ;
15401513 } ,
15411514 LdkEvent :: StaticInvoiceRequested { recipient_id, invoice_slot, reply_path } => {
15421515 let invoice = self
15431516 . static_invoice_store
1544- . handle_static_invoice_requested ( recipient_id, invoice_slot) ;
1517+ . handle_static_invoice_requested ( recipient_id, invoice_slot)
1518+ . await ;
15451519
15461520 if let Some ( invoice) = invoice {
15471521 match self . channel_manager . send_static_invoice ( invoice, reply_path) {
0 commit comments