]> Untitled Git - bdk-cli/commitdiff
fix(cbf): typo and cbf dir config when sqlite feature disabled
authorSteve Myers <steve@notmandatory.org>
Fri, 16 May 2025 16:15:49 +0000 (11:15 -0500)
committerSteve Myers <steve@notmandatory.org>
Fri, 16 May 2025 16:37:47 +0000 (11:37 -0500)
src/error.rs
src/handlers.rs
src/utils.rs

index 27606d730f75cd1c6f07ab7126365ca2f1680823..ad7d383ce2e5974f7fb7253a2ef2ceb665791f5c 100644 (file)
@@ -1,4 +1,5 @@
 use bdk_wallet::bitcoin::hex::HexToBytesError;
+use bdk_wallet::bitcoin::psbt::ExtractTxError;
 use bdk_wallet::bitcoin::{base64, consensus};
 use thiserror::Error;
 
@@ -51,7 +52,7 @@ pub enum BDKCliError {
     ParseOutPointError(#[from] bdk_wallet::bitcoin::blockdata::transaction::ParseOutPointError),
 
     #[error("PsbtExtractTxError: {0}")]
-    PsbtExtractTxError(#[from] bdk_wallet::bitcoin::psbt::ExtractTxError),
+    PsbtExtractTxError(Box<ExtractTxError>),
 
     #[error("PsbtError: {0}")]
     PsbtError(#[from] bdk_wallet::bitcoin::psbt::Error),
@@ -90,3 +91,9 @@ pub enum BDKCliError {
     #[error("BDK-Kyoto error: {0}")]
     BuilderError(#[from] bdk_kyoto::builder::BuilderError),
 }
+
+impl From<ExtractTxError> for BDKCliError {
+    fn from(value: ExtractTxError) -> Self {
+        BDKCliError::PsbtExtractTxError(Box::new(value))
+    }
+}
index 35c881a3e0e355a65ec4cf0fab417ed55f8d0d4a..db15bd639d8a117fe07cc1bb4503243a083d704f 100644 (file)
@@ -42,7 +42,7 @@ use std::collections::BTreeMap;
 #[cfg(any(feature = "electrum", feature = "esplora"))]
 use std::collections::HashSet;
 use std::convert::TryFrom;
-#[cfg(feature = "repl")]
+#[cfg(any(feature = "repl", feature = "electrum", feature = "esplora"))]
 use std::io::Write;
 use std::str::FromStr;
 
@@ -580,7 +580,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
                         while let Some(info) = info_subscriber.recv().await {
                             match info {
                                 Info::TxGossiped(wtxid) => {
-                                    tracing::info!("Succuessfully broadcast WTXID: {wtxid}");
+                                    tracing::info!("Successfully broadcast WTXID: {wtxid}");
                                     break;
                                 }
                                 Info::ConnectionsMet => {
@@ -745,11 +745,11 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
             subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand),
         } => {
             let network = cli_opts.network;
+            let home_dir = prepare_home_dir(cli_opts.datadir)?;
+            let wallet_name = &wallet_opts.wallet;
+            let database_path = prepare_wallet_db_dir(wallet_name, &home_dir)?;
             #[cfg(feature = "sqlite")]
             let result = {
-                let home_dir = prepare_home_dir(cli_opts.datadir)?;
-                let wallet_name = &wallet_opts.wallet;
-                let database_path = prepare_wallet_db_dir(wallet_name, &home_dir)?;
                 let mut persister = match &wallet_opts.database_type {
                     #[cfg(feature = "sqlite")]
                     DatabaseType::Sqlite => {
@@ -762,7 +762,7 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
 
                 let mut wallet = new_persisted_wallet(network, &mut persister, &wallet_opts)?;
                 let blockchain_client =
-                    new_blockchain_client(&wallet_opts, &wallet, Some(database_path))?;
+                    new_blockchain_client(&wallet_opts, &wallet, database_path)?;
 
                 let result = handle_online_wallet_subcommand(
                     &mut wallet,
@@ -775,6 +775,9 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
             };
             #[cfg(not(any(feature = "sqlite")))]
             let result = {
+                let wallet = new_wallet(network, &wallet_opts)?;
+                let blockchain_client =
+                    crate::utils::new_blockchain_client(&wallet_opts, &wallet, database_path)?;
                 let mut wallet = new_wallet(network, &wallet_opts)?;
                 handle_online_wallet_subcommand(&mut wallet, blockchain_client, online_subcommand)
                     .await?
@@ -871,7 +874,7 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
                     &mut wallet,
                     &wallet_opts,
                     line,
-                    Some(database_path.clone()),
+                    database_path.clone(),
                 )
                 .await;
                 #[cfg(feature = "sqlite")]
@@ -904,7 +907,7 @@ async fn respond(
     wallet: &mut Wallet,
     wallet_opts: &WalletOpts,
     line: &str,
-    _datadir: Option<std::path::PathBuf>,
+    _datadir: std::path::PathBuf,
 ) -> Result<bool, String> {
     use clap::Parser;
 
index 3e31710b264ae1532e6829bdd5074f7f8bd83f39..8302e227fbda4d0307e9d7644a95ce76dd85b318 100644 (file)
@@ -12,7 +12,6 @@
 use crate::error::BDKCliError as Error;
 use std::str::FromStr;
 
-#[cfg(feature = "sqlite")]
 use std::path::{Path, PathBuf};
 
 use crate::commands::WalletOpts;
@@ -76,11 +75,11 @@ pub(crate) fn parse_address(address_str: &str) -> Result<Address, Error> {
     Ok(unchecked_address.assume_checked())
 }
 
-#[cfg(feature = "sqlite")]
 /// Prepare bdk-cli home directory
 ///
 /// This function is called to check if [`crate::CliOpts`] datadir is set.
 /// If not the default home directory is created at `~/.bdk-bitcoin`.
+#[allow(dead_code)]
 pub(crate) fn prepare_home_dir(home_path: Option<PathBuf>) -> Result<PathBuf, Error> {
     let dir = home_path.unwrap_or_else(|| {
         let mut dir = PathBuf::new();
@@ -101,11 +100,11 @@ pub(crate) fn prepare_home_dir(home_path: Option<PathBuf>) -> Result<PathBuf, Er
 }
 
 /// Prepare wallet database directory.
-#[cfg(feature = "sqlite")]
+#[allow(dead_code)]
 pub(crate) fn prepare_wallet_db_dir(
     wallet_name: &Option<String>,
     home_path: &Path,
-) -> Result<PathBuf, Error> {
+) -> Result<std::path::PathBuf, Error> {
     let mut dir = home_path.to_owned();
     if let Some(wallet_name) = wallet_name {
         dir.push(wallet_name);
@@ -153,8 +152,8 @@ pub(crate) enum BlockchainClient {
 /// Create a new blockchain from the wallet configuration options.
 pub(crate) fn new_blockchain_client(
     wallet_opts: &WalletOpts,
-    wallet: &Wallet,
-    datadir: Option<std::path::PathBuf>,
+    _wallet: &Wallet,
+    _datadir: PathBuf,
 ) -> Result<BlockchainClient, Error> {
     #[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]
     let url = wallet_opts.url.as_str();
@@ -200,14 +199,12 @@ pub(crate) fn new_blockchain_client(
                 None => Sync,
             };
 
-            let mut builder = NodeBuilder::new(wallet.network());
+            let 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)?;
+                .data_dir(&_datadir)
+                .build_with_wallet(_wallet, scan_type)?;
 
             BlockchainClient::KyotoClient { client }
         }