};
let mut wallet = new_persisted_wallet(network, &mut persister, &wallet_opts)?;
- let blockchain_client = new_blockchain_client(&wallet_opts, &wallet)?;
+ let blockchain_client =
+ new_blockchain_client(&wallet_opts, &wallet, Some(database_path))?;
let result = handle_online_wallet_subcommand(
&mut wallet,
let (mut wallet, mut persister) = {
let wallet_name = &wallet_opts.wallet;
- let home_dir = prepare_home_dir(cli_opts.datadir)?;
+ let home_dir = prepare_home_dir(cli_opts.datadir.clone())?;
let database_path = prepare_wallet_db_dir(wallet_name, &home_dir)?;
};
#[cfg(not(any(feature = "sqlite")))]
let mut wallet = new_wallet(network, &wallet_opts)?;
+ let home_dir = prepare_home_dir(cli_opts.datadir.clone())?;
+ let database_path = prepare_wallet_db_dir(&wallet_opts.wallet, &home_dir)?;
loop {
let line = readline()?;
continue;
}
- let result = respond(network, &mut wallet, &wallet_opts, line).await;
+ let result = respond(
+ network,
+ &mut wallet,
+ &wallet_opts,
+ line,
+ Some(database_path.clone()),
+ )
+ .await;
#[cfg(feature = "sqlite")]
wallet.persist(&mut persister)?;
wallet: &mut Wallet,
wallet_opts: &WalletOpts,
line: &str,
+ _datadir: Option<std::path::PathBuf>,
) -> Result<bool, String> {
use clap::Parser;
subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand),
} => {
let blockchain =
- new_blockchain_client(wallet_opts, &wallet).map_err(|e| e.to_string())?;
+ new_blockchain_client(wallet_opts, &wallet, _datadir).map_err(|e| e.to_string())?;
let value = handle_online_wallet_subcommand(wallet, blockchain, online_subcommand)
.await
.map_err(|e| e.to_string())?;
pub(crate) fn new_blockchain_client(
wallet_opts: &WalletOpts,
wallet: &Wallet,
+ datadir: Option<std::path::PathBuf>,
) -> Result<BlockchainClient, Error> {
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]
let url = wallet_opts.url.as_str();
None => Sync,
};
- let client = NodeBuilder::new(wallet.network())
+ let mut builder = NodeBuilder::new(wallet.network());
+
+ if let Some(datadir) = datadir {
+ builder = builder.data_dir(&datadir);
+ };
+ let client = builder
.required_peers(wallet_opts.compactfilter_opts.conn_count)
.build_with_wallet(wallet, scan_type)?;