1- use crate :: logger:: { log_error, log_info, log_trace, FilesystemLogger , Logger } ;
1+ use crate :: logger:: { log_error, log_info, log_trace, Logger } ;
22
33use crate :: Error ;
44
@@ -27,12 +27,14 @@ use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, Signing};
2727use bitcoin:: { Script , Transaction , TxOut , Txid } ;
2828
2929use std:: collections:: HashMap ;
30+ use std:: ops:: Deref ;
3031use std:: sync:: { Arc , Condvar , Mutex , RwLock } ;
3132use std:: time:: Duration ;
3233
33- pub struct Wallet < D >
34+ pub struct Wallet < D , L : Deref >
3435where
3536 D : BatchDatabase ,
37+ L :: Target : Logger ,
3638{
3739 // A BDK blockchain used for wallet sync.
3840 blockchain : EsploraBlockchain ,
@@ -42,16 +44,17 @@ where
4244 fee_rate_cache : RwLock < HashMap < ConfirmationTarget , FeeRate > > ,
4345 runtime : Arc < RwLock < Option < tokio:: runtime:: Runtime > > > ,
4446 sync_lock : ( Mutex < ( ) > , Condvar ) ,
45- logger : Arc < FilesystemLogger > ,
47+ logger : L ,
4648}
4749
48- impl < D > Wallet < D >
50+ impl < D , L : Deref > Wallet < D , L >
4951where
5052 D : BatchDatabase ,
53+ L :: Target : Logger ,
5154{
5255 pub ( crate ) fn new (
5356 blockchain : EsploraBlockchain , wallet : bdk:: Wallet < D > ,
54- runtime : Arc < RwLock < Option < tokio:: runtime:: Runtime > > > , logger : Arc < FilesystemLogger > ,
57+ runtime : Arc < RwLock < Option < tokio:: runtime:: Runtime > > > , logger : L ,
5558 ) -> Self {
5659 let inner = Mutex :: new ( wallet) ;
5760 let fee_rate_cache = RwLock :: new ( HashMap :: new ( ) ) ;
@@ -286,19 +289,21 @@ where
286289 }
287290}
288291
289- impl < D > FeeEstimator for Wallet < D >
292+ impl < D , L : Deref > FeeEstimator for Wallet < D , L >
290293where
291294 D : BatchDatabase ,
295+ L :: Target : Logger ,
292296{
293297 fn get_est_sat_per_1000_weight ( & self , confirmation_target : ConfirmationTarget ) -> u32 {
294298 ( self . estimate_fee_rate ( confirmation_target) . fee_wu ( 1000 ) as u32 )
295299 . max ( FEERATE_FLOOR_SATS_PER_KW )
296300 }
297301}
298302
299- impl < D > BroadcasterInterface for Wallet < D >
303+ impl < D , L : Deref > BroadcasterInterface for Wallet < D , L >
300304where
301305 D : BatchDatabase ,
306+ L :: Target : Logger ,
302307{
303308 fn broadcast_transaction ( & self , tx : & Transaction ) {
304309 let locked_runtime = self . runtime . read ( ) . unwrap ( ) ;
@@ -325,24 +330,27 @@ where
325330
326331/// Similar to [`KeysManager`], but overrides the destination and shutdown scripts so they are
327332/// directly spendable by the BDK wallet.
328- pub struct WalletKeysManager < D >
333+ pub struct WalletKeysManager < D , L : Deref >
329334where
330335 D : BatchDatabase ,
336+ L :: Target : Logger ,
331337{
332338 inner : KeysManager ,
333- wallet : Arc < Wallet < D > > ,
339+ wallet : Arc < Wallet < D , L > > ,
334340}
335341
336- impl < D > WalletKeysManager < D >
342+ impl < D , L : Deref > WalletKeysManager < D , L >
337343where
338344 D : BatchDatabase ,
345+ L :: Target : Logger ,
339346{
340347 /// Constructs a `WalletKeysManager` that overrides the destination and shutdown scripts.
341348 ///
342349 /// See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
343350 /// `starting_time_nanos`.
344351 pub fn new (
345- seed : & [ u8 ; 32 ] , starting_time_secs : u64 , starting_time_nanos : u32 , wallet : Arc < Wallet < D > > ,
352+ seed : & [ u8 ; 32 ] , starting_time_secs : u64 , starting_time_nanos : u32 ,
353+ wallet : Arc < Wallet < D , L > > ,
346354 ) -> Self {
347355 let inner = KeysManager :: new ( seed, starting_time_secs, starting_time_nanos) ;
348356 Self { inner, wallet }
@@ -378,9 +386,10 @@ where
378386 }
379387}
380388
381- impl < D > NodeSigner for WalletKeysManager < D >
389+ impl < D , L : Deref > NodeSigner for WalletKeysManager < D , L >
382390where
383391 D : BatchDatabase ,
392+ L :: Target : Logger ,
384393{
385394 fn get_node_id ( & self , recipient : Recipient ) -> Result < PublicKey , ( ) > {
386395 self . inner . get_node_id ( recipient)
@@ -407,18 +416,20 @@ where
407416 }
408417}
409418
410- impl < D > EntropySource for WalletKeysManager < D >
419+ impl < D , L : Deref > EntropySource for WalletKeysManager < D , L >
411420where
412421 D : BatchDatabase ,
422+ L :: Target : Logger ,
413423{
414424 fn get_secure_random_bytes ( & self ) -> [ u8 ; 32 ] {
415425 self . inner . get_secure_random_bytes ( )
416426 }
417427}
418428
419- impl < D > SignerProvider for WalletKeysManager < D >
429+ impl < D , L : Deref > SignerProvider for WalletKeysManager < D , L >
420430where
421431 D : BatchDatabase ,
432+ L :: Target : Logger ,
422433{
423434 type Signer = InMemorySigner ;
424435
0 commit comments