]> Untitled Git - bdk-cli/commitdiff
chore: add Justfile for `just` command runner
authorVihiga Tyonum <withtvpeter@gmail.com>
Fri, 30 May 2025 19:50:39 +0000 (20:50 +0100)
committerVihiga Tyonum <withtvpeter@gmail.com>
Fri, 30 May 2025 19:55:22 +0000 (20:55 +0100)
- add project recipes
- add bitcoind recipes for rpc feature

[Issue: #196]

Justfile [new file with mode: 0644]

diff --git a/Justfile b/Justfile
new file mode 100644 (file)
index 0000000..c1c462a
--- /dev/null
+++ b/Justfile
@@ -0,0 +1,97 @@
+set quiet := true
+msrv := "1.75.0"
+default_wallet := 'regtest_default_wallet'
+default_datadir := "$HOME/.bdk-bitcoin"
+rpc_user := 'user'
+rpc_password := 'password'
+
+# list of recipes
+default:
+  just --list
+
+# format the project code
+fmt:
+    cargo fmt
+
+# lint the project
+clippy: fmt
+    cargo clippy --all-features --tests
+
+# build the project
+build: fmt
+    cargo build --all-features --tests 
+
+# test the project
+test:
+    cargo test --all-features --tests 
+
+# clean the project target directory
+clean:
+    cargo clean
+
+# set the rust version to stable
+stable: clean
+    rustup override set stable; cargo update
+
+# set the rust version to the msrv and pin dependencies
+msrv: clean
+    rustup override set {{msrv}}; cargo update; ./ci/pin-msrv.sh
+
+# start regtest bitcoind in default data directory
+[group('rpc')]
+start:
+    if [ ! -d "{{default_datadir}}" ]; then \
+        mkdir -p "{{default_datadir}}"; \
+    fi
+    bitcoind -datadir={{default_datadir}} -regtest -server -fallbackfee=0.0002 -blockfilterindex=1 -peerblockfilters=1 \
+     -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -daemon
+
+# stop regtest bitcoind
+[group('rpc')]
+stop:
+    pkill bitcoind
+
+# stop and delete regtest bitcoind data
+[group('rpc')]
+reset: stop
+    rm -rf {{default_datadir}}
+
+[group('rpc')]
+create wallet=default_wallet:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} createwallet {{wallet}}
+
+# load regtest wallet
+[group('rpc')]
+load wallet=default_wallet:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} loadwallet {{wallet}}
+
+# unload regtest wallet
+[group('rpc')]
+unload wallet=default_wallet:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} unloadwallet {{wallet}}
+
+
+# get regtest wallet address
+[group('rpc')]
+address wallet=default_wallet:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} getnewaddress
+
+# generate n new blocks to given address
+[group('rpc')]
+generate n address:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} generatetoaddress {{n}} {{address}}
+
+# get regtest wallet balance
+[group('rpc')]
+balance wallet=default_wallet:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} getbalance 
+
+# send n btc to address from wallet
+[group('rpc')]
+send n address wallet=default_wallet:
+    bitcoin-cli -named -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} sendtoaddress address={{address}} amount={{n}}
+
+# list wallet descriptors info, private = (true | false)
+[group('rpc')]
+descriptors private wallet=default_wallet:
+    bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} listdescriptors {{private}}