BDK Gotchas

2023-01-13

Since I've been playing with BDK in the past few weeks I'd ran into a few things that worked in a way I didn't expect. Here's a non-exhaustive list that might benefit someone else.

Running BDK in regtest mode in REPL mode

BDK supports launching a bitcoind and electrs, and connecting a REPL interface to it. This makes for a fantastic UX!

$ git clone https://github.com/bitcoindevkit/bdk-cli.git
$ cd bdk-cli
$ cargo run --features regtest-electrum,electrum -- -n regtest repl --descriptor 'wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)'
	    

If everything builds correctly, you'll find yourself in the BDK REPL, here you can do cool stuff like:

>> wallet sync
>> wallet get_new_address
{
	address": "bcrt1qakhg7qlpl5rstfdc7zeccl598v820j7rcnm22a"
}
>> node generate 100 # generate a 100 blocks
>> node sendtoaddress bcrt1qakhg7qlpl5rstfdc7zeccl598v820j7rcnm22a 10000 # send 10k sats to this wallet
>> node generate 100
>> wallet sync
>> wallet get_balance
{
  "satoshi": {
    "confirmed": 10000,
    "immature": 0,
    "trusted_pending": 0,
    "untrusted_pending": 0
  }
}