Skip to content

Commit 270b9c6

Browse files
committed
f BDK: Account for Wallet not taking database generic
1 parent 3269447 commit 270b9c6

File tree

2 files changed

+19
-37
lines changed

2 files changed

+19
-37
lines changed

src/types.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,11 @@ pub(crate) type Broadcaster = crate::tx_broadcaster::TransactionBroadcaster<Arc<
7272

7373
pub(crate) type FeeEstimator = crate::fee_estimator::OnchainFeeEstimator<Arc<FilesystemLogger>>;
7474

75-
pub(crate) type Wallet = crate::wallet::Wallet<
76-
bdk::database::SqliteDatabase,
77-
Arc<Broadcaster>,
78-
Arc<FeeEstimator>,
79-
Arc<FilesystemLogger>,
80-
>;
75+
pub(crate) type Wallet =
76+
crate::wallet::Wallet<Arc<Broadcaster>, Arc<FeeEstimator>, Arc<FilesystemLogger>>;
8177

82-
pub(crate) type KeysManager = crate::wallet::WalletKeysManager<
83-
bdk::database::SqliteDatabase,
84-
Arc<Broadcaster>,
85-
Arc<FeeEstimator>,
86-
Arc<FilesystemLogger>,
87-
>;
78+
pub(crate) type KeysManager =
79+
crate::wallet::WalletKeysManager<Arc<Broadcaster>, Arc<FeeEstimator>, Arc<FilesystemLogger>>;
8880

8981
pub(crate) type Router = DefaultRouter<
9082
Arc<Graph>,

src/wallet/mod.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ use lightning::util::message_signing;
2525
use lightning_invoice::RawBolt11Invoice;
2626

2727
use bdk::blockchain::EsploraBlockchain;
28-
use bdk::database::BatchDatabase;
2928
use bdk::wallet::AddressIndex;
3029
use bdk::{Balance, SignOptions, SyncOptions};
30+
use bdk_wallet::Wallet as BdkWallet;
3131

3232
use bitcoin::blockdata::constants::WITNESS_SCALE_FACTOR;
3333
use bitcoin::blockdata::locktime::absolute::LockTime;
@@ -48,17 +48,16 @@ enum WalletSyncStatus {
4848
InProgress { subscribers: tokio::sync::broadcast::Sender<Result<(), Error>> },
4949
}
5050

51-
pub(crate) struct Wallet<D, B: Deref, E: Deref, L: Deref>
51+
pub(crate) struct Wallet<B: Deref, E: Deref, L: Deref>
5252
where
53-
D: BatchDatabase,
5453
B::Target: BroadcasterInterface,
5554
E::Target: FeeEstimator,
5655
L::Target: Logger,
5756
{
5857
// A BDK blockchain used for wallet sync.
5958
blockchain: EsploraBlockchain,
6059
// A BDK on-chain wallet.
61-
inner: Mutex<bdk::Wallet<D>>,
60+
inner: Mutex<BdkWallet>,
6261
// A cache storing the most recently retrieved fee rate estimations.
6362
broadcaster: B,
6463
fee_estimator: E,
@@ -69,15 +68,14 @@ where
6968
logger: L,
7069
}
7170

72-
impl<D, B: Deref, E: Deref, L: Deref> Wallet<D, B, E, L>
71+
impl<B: Deref, E: Deref, L: Deref> Wallet<B, E, L>
7372
where
74-
D: BatchDatabase,
7573
B::Target: BroadcasterInterface,
7674
E::Target: FeeEstimator,
7775
L::Target: Logger,
7876
{
7977
pub(crate) fn new(
80-
blockchain: EsploraBlockchain, wallet: bdk::Wallet<D>, broadcaster: B, fee_estimator: E,
78+
blockchain: EsploraBlockchain, wallet: BdkWallet, broadcaster: B, fee_estimator: E,
8179
logger: L,
8280
) -> Self {
8381
let start_balance = wallet.get_balance().unwrap_or(Balance {
@@ -366,9 +364,8 @@ where
366364
}
367365
}
368366

369-
impl<D, B: Deref, E: Deref, L: Deref> WalletSource for Wallet<D, B, E, L>
367+
impl<B: Deref, E: Deref, L: Deref> WalletSource for Wallet<B, E, L>
370368
where
371-
D: BatchDatabase,
372369
B::Target: BroadcasterInterface,
373370
E::Target: FeeEstimator,
374371
L::Target: Logger,
@@ -488,21 +485,19 @@ where
488485

489486
/// Similar to [`KeysManager`], but overrides the destination and shutdown scripts so they are
490487
/// directly spendable by the BDK wallet.
491-
pub(crate) struct WalletKeysManager<D, B: Deref, E: Deref, L: Deref>
488+
pub(crate) struct WalletKeysManager<B: Deref, E: Deref, L: Deref>
492489
where
493-
D: BatchDatabase,
494490
B::Target: BroadcasterInterface,
495491
E::Target: FeeEstimator,
496492
L::Target: Logger,
497493
{
498494
inner: KeysManager,
499-
wallet: Arc<Wallet<D, B, E, L>>,
495+
wallet: Arc<Wallet<B, E, L>>,
500496
logger: L,
501497
}
502498

503-
impl<D, B: Deref, E: Deref, L: Deref> WalletKeysManager<D, B, E, L>
499+
impl<B: Deref, E: Deref, L: Deref> WalletKeysManager<B, E, L>
504500
where
505-
D: BatchDatabase,
506501
B::Target: BroadcasterInterface,
507502
E::Target: FeeEstimator,
508503
L::Target: Logger,
@@ -513,7 +508,7 @@ where
513508
/// `starting_time_nanos`.
514509
pub fn new(
515510
seed: &[u8; 32], starting_time_secs: u64, starting_time_nanos: u32,
516-
wallet: Arc<Wallet<D, B, E, L>>, logger: L,
511+
wallet: Arc<Wallet<B, E, L>>, logger: L,
517512
) -> Self {
518513
let inner = KeysManager::new(seed, starting_time_secs, starting_time_nanos);
519514
Self { inner, wallet, logger }
@@ -532,9 +527,8 @@ where
532527
}
533528
}
534529

535-
impl<D, B: Deref, E: Deref, L: Deref> NodeSigner for WalletKeysManager<D, B, E, L>
530+
impl<B: Deref, E: Deref, L: Deref> NodeSigner for WalletKeysManager<B, E, L>
536531
where
537-
D: BatchDatabase,
538532
B::Target: BroadcasterInterface,
539533
E::Target: FeeEstimator,
540534
L::Target: Logger,
@@ -576,9 +570,8 @@ where
576570
}
577571
}
578572

579-
impl<D, B: Deref, E: Deref, L: Deref> OutputSpender for WalletKeysManager<D, B, E, L>
573+
impl<B: Deref, E: Deref, L: Deref> OutputSpender for WalletKeysManager<B, E, L>
580574
where
581-
D: BatchDatabase,
582575
B::Target: BroadcasterInterface,
583576
E::Target: FeeEstimator,
584577
L::Target: Logger,
@@ -600,9 +593,8 @@ where
600593
}
601594
}
602595

603-
impl<D, B: Deref, E: Deref, L: Deref> EntropySource for WalletKeysManager<D, B, E, L>
596+
impl<B: Deref, E: Deref, L: Deref> EntropySource for WalletKeysManager<B, E, L>
604597
where
605-
D: BatchDatabase,
606598
B::Target: BroadcasterInterface,
607599
E::Target: FeeEstimator,
608600
L::Target: Logger,
@@ -612,9 +604,8 @@ where
612604
}
613605
}
614606

615-
impl<D, B: Deref, E: Deref, L: Deref> SignerProvider for WalletKeysManager<D, B, E, L>
607+
impl<B: Deref, E: Deref, L: Deref> SignerProvider for WalletKeysManager<B, E, L>
616608
where
617-
D: BatchDatabase,
618609
B::Target: BroadcasterInterface,
619610
E::Target: FeeEstimator,
620611
L::Target: Logger,
@@ -664,9 +655,8 @@ where
664655
}
665656
}
666657

667-
impl<D, B: Deref, E: Deref, L: Deref> ChangeDestinationSource for WalletKeysManager<D, B, E, L>
658+
impl<B: Deref, E: Deref, L: Deref> ChangeDestinationSource for WalletKeysManager<B, E, L>
668659
where
669-
D: BatchDatabase,
670660
B::Target: BroadcasterInterface,
671661
E::Target: FeeEstimator,
672662
L::Target: Logger,

0 commit comments

Comments
 (0)