Some notes on my manual rpc cli setup and testing:
- start bitcoind in regtest mode
mkdir /tmp/bitcoind
bitcoind -datadir=/tmp/bitcoind -regtest -server -fallbackfee=0.0002 -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -blockfilterindex=1 --peerblockfilters=1 -daemon
- create bitcoind test wallet and generate blocks
bitcoin-cli -datadir=/tmp/bitcoind -regtest createwallet "test"
CORE_ADDRESS=$(bitcoin-cli -datadir=/tmp/bitcoind -regtest getnewaddress)
bitcoin-cli -datadir=/tmp/bitcoind -regtest generatetoaddress 155 $CORE_ADDRESS
- setup env for example_bitcoind_rpc_polling
cd example-crates/example_bitcoind_rpc_polling
export BITCOIN_NETWORK=regtest
export RPC_URL=127.0.0.1:18443
export RPC_COOKIE=/tmp/bitcoind/regtest/.cookie
export DESCRIPTOR="wpkh(tprv8ZgxMBicQKsPeahLBQMDWRatCzmT1T1HkqyXj7y6GZsrMyp9Ndy6Wgj9hJ4jPsAb3soNi9UzCiEnfDkVHRredhdYrXhDW9mCdWo2wXswv3G/*)"
- get new rpc wallet deposit address
cargo run -- address new
- send btc to rpc wallet
bitcoin-cli -datadir=/tmp/bitcoind -regtest sendtoaddress "<rpc wallet address>" 0.1
- verify balance recieved by rpc wallet
cargo run -- balance # should be no balance yet
cargo run -- sync
cargo run -- balance # should see the expected balance as unconfirmed
- create block and verify confirmed balance
bitcoin-cli -datadir=/tmp/bitcoind -regtest generatetoaddress 1 $CORE_ADDRESS
cargo run -- balance # balance still unconfirmed
cargo run -- sync
cargo run -- balance # balance is now confirmed 🥳
- create address at index 1000. Note: this started at ~400ms to went up to ~800ms per address, we should add a
address peek <index#>
cli command to make this sort of testing easier. Should also figure out why the time to generate a new address grows.
for i in $(seq 0 1000);
do
cargo run -- address new
done
- rename the wallet database
mv .bdk_example_rpc.db old.bdk_example_rpc.db
- send btc to address at index 1001 (should be outside lookahead range)
cargo run -- sync
cargo run -- balance
bitcoin-cli -datadir=/tmp/bitcoind -regtest sendtoaddress "<rpc wallet address at index 1000>" 0.001
cargo run -- sync
cargo run -- balance # balances should be found only on address at index 0
- create new address at index 1
cargo run -- address new
cargo run -- sync
cargo run -- balance # balance should now include confirmed index 0 and unconfirm index 1000 amounts
- create block and verify confirmed balance
bitcoin-cli -datadir=/tmp/bitcoind -regtest generatetoaddress 1 $CORE_ADDRESS
cargo run -- sync
cargo run -- balance # balance is now confirmed 🎉
- confirm utxos at index 0 and 1001
cargo run -- txout list