Last active
April 25, 2025 21:33
-
-
Save notmandatory/376c56f53f22c802ce34259636c9ed4b to your computer and use it in GitHub Desktop.
justfile for bitcoind regtest testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set quiet := true | |
default_wallet := 'test' | |
# list of recipes | |
default: | |
echo default_wallet = {{default_wallet}} | |
echo | |
just --list | |
# start regtest bitcoind in /tmp/bitcoind directory | |
[group('regtest')] | |
start: | |
mkdir -p /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 | |
# stop regtest bitcoind | |
[group('regtest')] | |
stop: | |
pkill bitcoind | |
# stop and delete regtest bitcoind data | |
[group('regtest')] | |
reset: stop | |
rm -rf /tmp/bitcoind | |
# create a regtest wallet | |
[group('regtest')] | |
create wallet=default_wallet: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest createwallet {{wallet}} | |
# load regtest wallet | |
[group('regtest')] | |
load wallet=default_wallet: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest loadwallet {{wallet}} | |
# unload regtest wallet | |
[group('regtest')] | |
unload wallet=default_wallet: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest unloadwallet {{wallet}} | |
# view debug log for regtest wallet address | |
[group('regtest')] | |
debug: | |
less +G /tmp/bitcoind/regtest/debug.log | |
# get regtest wallet address | |
[group('regtest')] | |
address wallet=default_wallet: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest -rpcwallet={{wallet}} getnewaddress | |
# generate n new blocks to given address | |
[group('regtest')] | |
generate n address: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest generatetoaddress {{n}} {{address}} | |
# get regtest wallet balance | |
[group('regtest')] | |
balance wallet=default_wallet: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest -rpcwallet={{wallet}} getbalance | |
# list wallet descriptors info, private = (true | false) | |
[group('regtest')] | |
descriptors private wallet=default_wallet: | |
bitcoin-cli -datadir=/tmp/bitcoind -regtest -rpcwallet={{wallet}} listdescriptors {{private}} | |
# send n btc to address from wallet | |
[group('regtest')] | |
send n address wallet=default_wallet: | |
bitcoin-cli -named -datadir=/tmp/bitcoind -regtest -rpcwallet={{wallet}} sendtoaddress address={{address}} amount={{n}} | |
# manually created bitcoin-cli RPC command, see just rpc help | |
[group('regtest')] | |
rpc command wallet=default_wallet: | |
bitcoin-cli -named -datadir=/tmp/bitcoind -regtest -rpcwallet={{wallet}} {{command}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
bitcoind
,bitcoin-cli
,just
justfile
in your project directorySetup regtest bitcoind with
just
commandsjust generate 110 $(just address)
Create test wallets and get their descriptors
Send to and from test wallets
just generate 1 $(just address)
just generate 1 $(just address)