- 1.46.0 # MSRV
features:
- default
- - repl
- electrum
- esplora
- compiler
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
"rustyline",
"serde_json",
"structopt",
+ "zeroize",
]
[[package]]
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"]
[[bin]]
name = "bdk-cli"
path = "src/bdk_cli.rs"
-required-features = ["repl"]
+required-features = ["cli"]
[package.metadata.docs.rs]
features = ["compiler"]
## 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
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:
- 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:
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")]
#[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
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);
script_type: String,
},
/// Enter REPL command loop mode
+ #[cfg(feature = "repl")]
#[structopt(long_about = "REPL command loop mode")]
Repl {
#[structopt(flatten)]