Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-organize wallet sub-commands and add key sub-commands #14

Merged
merged 18 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
- 1.45.0 # MSRV
features:
- default
- default,esplora
- repl
- electrum
- esplora
- repl,electrum,esplora
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Project
- Upgrade BDK to `0.3`

#### Added
- Add support for `wasm`
- `CliOpts` struct and `CliSubCommand` enum representing top level cli options and commands
- `KeySubCommand` enum
- `handle_key_subcommand` function

#### Changed
- Upgrade BDK to `0.3`
- Renamed `WalletOpt` struct to `WalletOpts`
- `WalletSubCommand` enum split into `OfflineWalletSubCommand` and `OnlineWalletSubCommand`
- Split `handle_wallet_subcommand` into two functions, `handle_offline_wallet_subcommand` and `handle_online_wallet_subcommand`
- A wallet without a `Blockchain` is used when handling offline wallet sub-commands

### `bdk-cli` bin

#### Added
- Top level commands "wallet", "key", and "repl"
- "key" command has sub-commands to "generate" and "restore" a master extended key
- "repl" command now has an "exit" sub-command

#### Changed
- "wallet" sub-commands and options must be proceeded by "wallet" command
- "repl" command loop now includes both "wallet" and "key" sub-commands

## [0.1.0]

Expand Down
14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ readme = "README.md"
license = "MIT"

[dependencies]
bdk = { version = "^0.3", default-features = false }
bdk-macros = "^0.2"
bdk = { git = "https://github.com/bitcoindevkit/bdk.git", rev = "c4f2179", default-features = false, features = ["all-keys"]}
bdk-macros = { git = "https://github.com/bitcoindevkit/bdk.git", rev = "c4f2179" }
structopt = "^0.3"
serde_json = { version = "^1.0" }
log = "^0.4"
Expand All @@ -25,15 +25,19 @@ rustyline = { version = "6.0", optional = true }
dirs-next = { version = "2.0", optional = true }
env_logger = { version = "0.7", optional = true }
clap = { version = "2.33", optional = true }
regex = {version = "1", optional = true }

[features]
default = ["repl", "esplora", "electrum", "bdk/key-value-db"]
repl = ["async-trait", "rustyline", "dirs-next", "env_logger", "clap", "electrum"]
default = []
repl = ["async-trait", "bdk/key-value-db", "clap", "dirs-next", "env_logger", "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 = ["repl", "electrum"]

[package.metadata.docs.rs]
all-features = true
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,32 @@ To get usage information for the `bdk-cli` bin use the below command which retur
available wallet options and commands:

```shell
cargo run
cargo run --features repl,electrum
```

To sync a wallet to the default electrum server:

```shell
cargo run -- --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
cargo run --features repl,electrum,esplora -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
```

To get a wallet balance with customized logging:

```shell
RUST_LOG=debug,sled=info,rustls=info cargo run -- --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" get_balance
RUST_LOG=debug,sled=info,rustls=info cargo run --features repl,electrum,esplora -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" get_balance
```

To generate a new extended master key, suitable for using in a descriptor:

```shell
cargo run --features repl,electrum -- key generate
```

To install dev version of `bdk-cli` from local git repo:

```shell
cd <bdk-cli git repo directory>
cargo install --path . --features repl,electrum,esplora

bdk-cli help # to verify it worked
```
Loading