]> Untitled Git - bdk-cli/commitdiff
Add cli feature and make it required for bin build
authorSteve Myers <steve@notmandatory.org>
Fri, 6 Aug 2021 01:35:17 +0000 (18:35 -0700)
committerSteve Myers <steve@notmandatory.org>
Thu, 12 Aug 2021 14:10:29 +0000 (16:10 +0200)
.github/workflows/cont_integration.yml
Cargo.lock
Cargo.toml
README.md
src/bdk_cli.rs
src/lib.rs

index a4e044188b831f13088956cfc92ea54d5ad804db..af0b4f38cafbb3a659691132e3386f340bb6f4e3 100644 (file)
@@ -14,7 +14,6 @@ jobs:
           - 1.46.0 # MSRV
         features:
           - default
-          - repl
           - electrum
           - esplora
           - compiler
@@ -40,11 +39,11 @@ jobs:
           override: true
           components: rustfmt, clippy
       - name: Build
-        run: cargo build --features ${{ matrix.features }} --no-default-features --locked
+        run: cargo build --features ${{ matrix.features }} --locked
       - name: Clippy
         run: cargo clippy -- -D warnings
       - name: Test
-        run: cargo test --features ${{ matrix.features }} --no-default-features
+        run: cargo test --features ${{ matrix.features }}
 
   fmt:
     name: Rust fmt
index 173963b472669f651cfd09f2f766c696cd625d2d..8e1e8fa0ff2409d3e989712fdbdf46a9bf549451 100644 (file)
@@ -117,6 +117,7 @@ dependencies = [
  "rustyline",
  "serde_json",
  "structopt",
+ "zeroize",
 ]
 
 [[package]]
index 507c2f5bfb6419b670862c42763d7e0496c1f784..aa520954c6476a8f8f3e8f7b9478e595fffe52e9 100644 (file)
@@ -28,8 +28,9 @@ clap = { version = "2.33", optional = true }
 regex = {version = "1", optional = true }
 
 [features]
-default = ["repl", "electrum"]
-repl = ["bdk/key-value-db", "clap", "dirs-next", "env_logger", "regex", "rustyline"]
+default = ["cli", "repl"]
+cli = ["bdk/key-value-db", "clap", "dirs-next", "env_logger"]
+repl = ["regex", "rustyline"]
 electrum = ["bdk/electrum"]
 esplora = ["bdk/esplora"]
 compiler = ["bdk/compiler"]
@@ -39,7 +40,7 @@ compact_filters = ["bdk/compact_filters"]
 [[bin]]
 name = "bdk-cli"
 path = "src/bdk_cli.rs"
-required-features = ["repl"]
+required-features = ["cli"]
 
 [package.metadata.docs.rs]
 features = ["compiler"]
index 1855ed09694d244c5f264a963a03e25d01e260c4..484d08ad2ba36894b30a7eed6e5b7b9735f2ad22 100644 (file)
--- a/README.md
+++ b/README.md
@@ -10,28 +10,31 @@ wallet tool based on the [bdk](https://github.com/bitcoindevkit/bdk) library.
 
 ## Install bdk-cli
 ### From source
-To install dev version of `bdk-cli` from local git repo:
+To install dev version of `bdk-cli` from local git repo with the `electrum` blockchain client enabled:
 
 ```shell
 cd <bdk-cli git repo directory>
-cargo install --path .
+cargo install --path . --features electrum
 bdk-cli help # to verify it worked
 ```
 
-By default the `electrum` client feature is enabled, to use the `esplora` or another blockchain backend
-client instead the default features must be disabled and the desired client feature enabled. Below
-is an example of how to enable the `esplora` blockchain client feature instead of `electrum`.
+If no blockchain client feature is enabled online wallet commands `sync` and `broadcast` will be 
+disabled. To enable these commands a blockchain client features such as `electrum` or another 
+blockchain backend feature must be enabled. Below is an example of how run the `bdk-cli` bin with 
+the `esplora` blockchain client feature.
 
 ```shell
-RUST_LOG=debug cargo run --no-default-features --features repl,esplora -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
+RUST_LOG=debug cargo run --features esplora -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
 ```
 
-If no blockchain client feature is enabled then online wallet commands are disabled.
+At most one blockchain feature can be enabled, available blockchain client features are:
+`electrum`, `esplora`, and `compact_filters`.
 
 ### From crates.io
-You can the install the binaries for the latest tag of `bdk-cli` directly from [crates.io](https://crates.io/crates/bdk-cli) like so:
+You can the install the binaries for the latest tag of `bdk-cli` with online wallet features 
+directly from [crates.io](https://crates.io/crates/bdk-cli) with a command as below:
 ```sh
-cargo install bdk-cli 
+cargo install bdk-cli --features `electrum`
 ```
 
 ### bdk-cli bin usage examples
@@ -46,7 +49,7 @@ cargo run
 To sync a wallet to the default electrum server:
 
 ```shell
-cargo run -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
+cargo run --features electrum -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
 ```
 
 To sync a wallet to Bitcoin Core node (assuming a regtest node at 127.0.0.1:18444) serving compact filters:
@@ -55,7 +58,7 @@ Note:
 - Bitcoin Core v0.21.0 or higher is required to serve compact filters.  
 
 ```shell
-cargo run --no-default-features --features repl,compact_filters -- --network regtest wallet --node 127.0.0.1:18444 --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
+cargo run --features compact_filters -- --network regtest wallet --node 127.0.0.1:18444 --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
 ```
 
 To get a wallet balance with customized logging:
index 88d4bef8f36068edfe333c3dd045726abe1e570d..be19a7fa366698dfa796a4067b3ea4b2abb5f684 100644 (file)
@@ -28,8 +28,12 @@ use std::path::PathBuf;
 use bitcoin::Network;
 use clap::AppSettings;
 use log::{debug, error, info, warn};
+
+#[cfg(feature = "repl")]
 use rustyline::error::ReadlineError;
+#[cfg(feature = "repl")]
 use rustyline::Editor;
+
 use structopt::StructOpt;
 
 #[cfg(feature = "compact_filters")]
@@ -53,8 +57,10 @@ use bdk_cli::{CliOpts, CliSubCommand, KeySubCommand, OfflineWalletSubCommand, Wa
 #[cfg(any(feature = "electrum", feature = "esplora", feature = "compact_filters"))]
 use bdk_cli::OnlineWalletSubCommand;
 
+#[cfg(feature = "repl")]
 use regex::Regex;
 
+#[cfg(feature = "repl")]
 const REPL_LINE_SPLIT_REGEX: &str = r#""([^"]*)"|'([^']*)'|([\w\-]+)"#;
 
 /// REPL mode
@@ -251,6 +257,7 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result<String, Error>
             let result = bdk_cli::handle_compile_subcommand(network, policy, script_type)?;
             serde_json::to_string_pretty(&result)?
         }
+        #[cfg(feature = "repl")]
         CliSubCommand::Repl { wallet_opts } => {
             let database = open_database(&wallet_opts);
 
index 19a3eafb88b63528a5a9f94b8ef2f78ed951a2a3..ea68a7d5ea420fdbfabaacfd68534b8f220168df 100644 (file)
@@ -258,6 +258,7 @@ pub enum CliSubCommand {
         script_type: String,
     },
     /// Enter REPL command loop mode
+    #[cfg(feature = "repl")]
     #[structopt(long_about = "REPL command loop mode")]
     Repl {
         #[structopt(flatten)]