Skip to content

Commit

Permalink
Merge #102: Satoshi's Calculator.
Browse files Browse the repository at this point in the history
fa0454e Create node backend once in repl mode (Steve Myers)
322f6f1 Update changelog (rajarshimaitra)
0ce8426 Simplify main (rajarshimaitra)
4906764 Add the integration test framework (rajarshimaitra)
b596c9f Update utility (rajarshimaitra)
aa6a687 Update nodes.rs (rajarshimaitra)
0eb2dc8 Update handlers (rajarshimaitra)
0212b48 Update commands (rajarshimaitra)
992915b update cargo.toml (rajarshimaitra)

Pull request description:

  ### Description

  fixes #62
  fixes #76

  On the name :
  If Bitcoin wallet devs had to have a "calculator", this is what it might look like. One single interface to do all wallet and node operations.

  This PR does the following
   - Update electrsd to latest version. We need this to use it for out auto deployed backends.
   - Add the remaining codes to `nodes.rs` module to define basic node operation apis on the `Nodes` enum.
   - Add a new `node` command in ` CliSubCommand` which has its own subcommand `NodeSubCommand`, These subcommands are essentially `bitcoin-cli` calls. And only the basic ones are included so far. We can also compose multiple `bitcoin-cli` calls to create our own commands in future.
   - Update the `handlers` to handle newly added `NodeSubCommands`.
   - Update in `utils` :
     - This includes handling auto blockchain client creation for `regtest-*` features.
     -  update on the directory creation workflow. We are creating many directories for many stuffs, and I was trying to figure out the easiest way to keep the whole datadir struct intact, no matter where the user points its `datadir` to. Note that now `datadir` is a global app option, not just available for `regtest` nodes. Default `datadir` is the previous `~/.bdk-bitcoin`.
     - Finally add an integration test in `tests/integration.rs` that runs a basic wallet operation with a bdk-cli wallet connected to auto deployed regtest-bitcoin/electrum.

  ### Notes to the reviewers

  @sandipndev @krtk6160. I feel this PR is now ready to try out #87 .

  Also looking for more integration test ideas too add into.

  basic `node` usage looks like this
  ```
  $ ./target/debug/bdk-cli node --help
  bdk-cli-node 0.5.0
  Regtest Node mode

  USAGE:
      bdk-cli node <SUBCOMMAND>

  FLAGS:
      -h, --help
              Prints help information

      -V, --version
              Prints version information

  SUBCOMMANDS:
      generate         Generate blocks
      getbalance       Get Wallet balance
      getinfo          Get info
      getnewaddress    Get new address from node's test wallet
      help             Prints this message or the help of the given subcommand(s)
      sendtoaddress    Send to an external wallet address
  ```
  The biggest benefit is I think in the `repl` mode. That now kinda becomes an integrated tool the like python interpreter to operate a bdk-cli and a bitcoin backend from one single interface.

  I am excited to see what kind of demonstrations with bdk-cli we can create with this..

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  notmandatory:
    tACK fa0454e

Tree-SHA512: 919abcee8291d5181c77cc1e53c630d013504861a5325ddf1d9fc8269db45afa91298852902dffafd576c19eae74e62f675ccba625055b6464c6d73a76a29913
  • Loading branch information
notmandatory committed Sep 10, 2022
2 parents 99a329f + fa0454e commit 7869bdb
Show file tree
Hide file tree
Showing 9 changed files with 761 additions and 282 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change default database to `sqlite`.
- Change the `esplora-reqwest` feature to always use async mode
- Change rpc `--skip-blocks` option to `--start-time` which specifies time initial sync will start scanning from.
- Add new `bdk-cli node <command> [<args>]` to control the backend node deployed by `regtest-*` features.
- Add an integration testing framework in `src/tests/integration.rs`. This framework uses the `regtest-*` feature to run automated testing with bdk-cli.

## [0.5.0]

Expand Down
119 changes: 40 additions & 79 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rustyline = { version = "~9.0", optional = true }
fd-lock = { version = "=3.0.2", optional = true }
regex = { version = "1", optional = true }
bdk-reserves = { version = "0.22", optional = true }
electrsd = { version= "0.12", features = ["trigger", "bitcoind_22_0"], optional = true}
electrsd = { version= "0.19", features = ["bitcoind_22_0"], optional = true}
tokio = { version = "1", features = ["rt", "macros", "rt-multi-thread"], optional = true }

[features]
Expand Down Expand Up @@ -63,8 +63,9 @@ reserves = ["bdk-reserves"]
#
# This is most useful for integrations testing as well as quick demo testing
# by devs using bdk and various types of background nodes.
regtest-node = []
regtest-bitcoin = ["regtest-node" , "rpc", "electrsd"]
regtest-node = ["electrsd"]
regtest-bitcoin = ["regtest-node" , "rpc"]
regtest-electrum = ["regtest-node", "electrum", "electrsd/electrs_0_8_10"]
regtest-esplora-ureq = ["regtest-node", "esplora-ureq", "electrsd/esplora_a33e97e1"]
regtest-esplora-reqwest = ["regtest-node", "esplora-reqwest", "electrsd/esplora_a33e97e1"]
#TODO: Check why esplora in electrsd isn't working.
#regtest-esplora-ureq = ["regtest-node", "esplora-ureq", "electrsd/esplora_a33e97e1"]
#regtest-esplora-reqwest = ["regtest-node", "esplora-reqwest", "electrsd/esplora_a33e97e1"]
Loading

0 comments on commit 7869bdb

Please sign in to comment.