bitcoindevkit / bdk-cli

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

Add options to start regtest bitcoind and electrsd #55

Closed notmandatory closed 2 years ago

notmandatory commented 2 years ago

For users who are manually testing bdk with bdk-cli in regtest mode, add a new regtest-net cargo feature that will automatically start and stop a bitcoind and if needed an electrsd daemon with electrum or esplora support. The regtest net daemons will only be started if the --network regtest option is enabled.

The feature should work similarly to the bdk integration tests but store node data in the users ~/.bdk-bitcoin directory and not a random temp directory, and use standard regtest network ports.

Using this feature would look something like this:

# start regtest `bitcoind` and `electrs` and stop daemons when repl (or wallet command) finishes
cargo run --features regtest-net,electrum -- --network regtest repl --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" 

By enabling the regtest-net feature when running or installing bdk-cli a localhost bitcoind and (if electrum or esplora features enabled) electrsd daemon would be started and stopped for each command. This will be most convenient when running multiple commands via the repl shell but still usable (but slow) for single wallet commands.

The bitcoind and electrsd crates provide most of what is needed to download, start, and stop the needed daemons. This will only work on linux and macos systems.

It may also be useful to add additional wallet commands to get a new address from bitcoind or trigger bitcoind to send regtest coins to the bdk-cli wallet.

rajarshimaitra commented 2 years ago

This would be really helpful to make bdk-cli testing process more seamless..