bitcoindevkit / bdk-cli

A CLI wallet library and REPL tool to demo and test the BDK library
Other
111 stars 65 forks source link

Auto deploy regtest nodes in background #65

Closed rajarshimaitra closed 2 years ago

rajarshimaitra commented 2 years ago

Description

Fixes https://github.com/bitcoindevkit/bdk-cli/issues/55. I decided to go for one feature flag for each backends as they made dependency management easier. Because different backend will have different dependency, and we don't wanna have redundant ones. Also it makes the commands a little shorter.

Notes to the reviewers

Right now its not that useful because the backend APIs are not exposed. So I can't really do much other than sync/send in the command line. (unlike testnet we cannot send coins to bdk from outside of local regtest node). So to make it useful in repl mode as described in the issue, we also have to expose the blockchain apis in bdk-cli command in some way (at least the basic stuffs, address, send, generate). Looking for suggestions on this.

usage looks like this:

cargo run --features regtest-rpc -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
{}

Although I am having trouble connecting to the esplora end of electrs. Not sure whats the issue, will have to look more.

Checklists

All Submissions:

New Features:

rajarshimaitra commented 2 years ago

Fixed merge conflict with some enhancements.

rajarshimaitra commented 2 years ago

Updated the commit history for better structuring.

notmandatory commented 2 years ago

@rajarshimaitra Looks like this one needs a rebase or if you're tied up I can do the rebase but would have to rewrite your commits. Once that's done I'll do some testing and see if I can figure out how to expose the core rpc in repl mode.

rajarshimaitra commented 2 years ago

Rebased and resolved conflicts..

notmandatory commented 2 years ago

I spent some time today testing and reviewing and this is a great start! There are still the two (related) issues you found:

I believe issue 2 is because electrsd won't sync until at least one block is created by bitcoind; so if we fix 1 we should also fix 2. My idea for fixing 1 is to change the bitcoind lib to allow us to set a reusable (not randomly generated tmp) directory for the bitcoind data dir; and maybe the same for electrsd. Then we can add some simple RPC commands to bdk-cli to update the bitcoind (and electrsd) database and that data will persist for future invocations of bdk-cli.

But for now as long as we add the comment that the regtest-* features are experimental this should be OK to merge. Then we have more time to to play with and get merged any PRs to bitcoind (and electrsd) that we need to have it all working end to end.

rajarshimaitra commented 2 years ago

Thanks @notmandatory .. Updated as per suggested and rebased..

rajarshimaitra commented 2 years ago

Rebased on latest master.

rajarshimaitra commented 2 years ago