From bff2d375a1dc811b96e0ce47b21ab8ebb17f1d23 Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Tue, 30 Aug 2022 17:22:12 +0200 Subject: [PATCH] `open_database` avoids creating a wallet dir if... ...not necessary This is useful for the wasm integration, where we want to call the `open_database` function directly, without wanting it to create any directories. Note that when using bdk-cli normally, it won't create a db directory if it's useless, but it will still create a base directory (even if empty). This is suboptimal, but fixing it would require a quite big refactor to the code. --- src/utils.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 566db9f..0ebd9a5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -164,6 +164,11 @@ pub(crate) fn prepare_home_dir(home_path: Option) -> Result Result { let mut dir = home_path.to_owned(); @@ -178,6 +183,7 @@ fn prepare_wallet_dir(wallet_name: &str, home_path: &Path) -> Result Result { let mut db_dir = prepare_wallet_dir(wallet_name, home_path)?; @@ -248,12 +254,14 @@ pub(crate) fn prepare_electrum_datadir(home_path: &Path) -> Result Result { let wallet_name = wallet_opts.wallet.as_ref().expect("wallet name"); + #[cfg(any(feature = "key-value-db", feature = "sqlite-db",))] let database_path = prepare_wallet_db_dir(wallet_name, home_path)?; #[cfg(feature = "key-value-db")] -- 2.49.0