Skip to content

Instantly share code, notes, and snippets.

@notmandatory
Last active February 11, 2023 21:14
Show Gist options
  • Save notmandatory/e3bd0c36264744c948edd3d50a024f51 to your computer and use it in GitHub Desktop.
Save notmandatory/e3bd0c36264744c948edd3d50a024f51 to your computer and use it in GitHub Desktop.
bdk_core manual testing
# install bitcoind via your favorite method
# start regtest bitcoind
mkdir -p /tmp/regtest1/bitcoind
bitcoind -datadir=/tmp/regtest1/bitcoind -regtest -server -fallbackfee=0.0002 -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -blockfilterindex=1 -peerblockfilters=1 -daemon
# cookie file location: /tmp/regtest1/bitcoind/regtest/.cookie
# create test bitcoind wallet
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest createwallet "regtest1"
# generate bitcoin blocks
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest getnewaddress
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest generatetoaddress 101 "<newaddress>"
# install electrs (for mac m1)
brew install rocksdb
cargo install electrs --git https://github.com/romanz/electrs.git --branch bump-msrv
# start electrs
mkdir -p /tmp/regtest1/electrs
electrs --db-dir /tmp/regtest1/electrs --daemon-dir /tmp/regtest1/bitcoind --cookie-file /tmp/regtest1/bitcoind/regtest/.cookie --network regtest
# set descriptor env
export DESCRIPTOR="tr(tprv8ZgxMBicQKsPd8kkvjJukqwX6TsEAEscD42chy8edbgFrdRUj72deq7PG4tsqnm3a7SjjBmRZ4F9p9ZSBsb5jKXhirHz2MxQcF2vVq1Xocr/0/*)"
# get new address (from bdk_electrum_example directory)
cargo run -- --network regtest address new
# send coins to bdk_core wallet
bitcoin-cli -datadir=/tmp/regtest1/bitcoind -regtest generatetoaddress 10 "bcrt1pnehvprh4882wjf5t7erw3n3r765pme8xkt287qn5dstax4mu628sn922tk"
# scan wallet addresses (from bdk_electrum_example directory)
cargo run -- --network regtest scan
# check balance (from bdk_electrum_example directory)
cargo run -- --network regtest balance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment