Skip to content

Commit ef84b92

Browse files
committed
chore: add Justfile for just command runner
- add project recipes - add bitcoind recipes for rpc feature [Issue: #196]
1 parent 573eea7 commit ef84b92

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

Justfile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
set quiet := true
2+
msrv := "1.75.0"
3+
default_wallet := 'regtest_default_wallet'
4+
default_datadir := "$HOME/.bdk-bitcoin"
5+
rpc_user := 'user'
6+
rpc_password := 'password'
7+
8+
# list of recipes
9+
default:
10+
just --list
11+
12+
# format the project code
13+
fmt:
14+
cargo fmt
15+
16+
# lint the project
17+
clippy: fmt
18+
cargo clippy --all-features --tests
19+
20+
# build the project
21+
build: fmt
22+
cargo build --all-features --tests
23+
24+
# test the project
25+
test:
26+
cargo test --all-features --tests
27+
28+
# clean the project target directory
29+
clean:
30+
cargo clean
31+
32+
# set the rust version to stable
33+
stable: clean
34+
rustup override set stable; cargo update
35+
36+
# set the rust version to the msrv and pin dependencies
37+
msrv: clean
38+
rustup override set {{msrv}}; cargo update; ./ci/pin-msrv.sh
39+
40+
# start regtest bitcoind in default data directory
41+
[group('rpc')]
42+
start:
43+
if [ ! -d "{{default_datadir}}" ]; then \
44+
mkdir -p "{{default_datadir}}"; \
45+
fi
46+
bitcoind -datadir={{default_datadir}} -regtest -server -fallbackfee=0.0002 -blockfilterindex=1 -peerblockfilters=1 \
47+
-rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -daemon
48+
49+
# stop regtest bitcoind
50+
[group('rpc')]
51+
stop:
52+
pkill bitcoind
53+
54+
# stop and delete regtest bitcoind data
55+
[group('rpc')]
56+
reset: stop
57+
rm -rf {{default_datadir}}
58+
59+
[group('rpc')]
60+
create wallet=default_wallet:
61+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} createwallet {{wallet}}
62+
63+
# load regtest wallet
64+
[group('rpc')]
65+
load wallet=default_wallet:
66+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} loadwallet {{wallet}}
67+
68+
# unload regtest wallet
69+
[group('rpc')]
70+
unload wallet=default_wallet:
71+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} unloadwallet {{wallet}}
72+
73+
74+
# get regtest wallet address
75+
[group('rpc')]
76+
address wallet=default_wallet:
77+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} getnewaddress
78+
79+
# generate n new blocks to given address
80+
[group('rpc')]
81+
generate n address:
82+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} generatetoaddress {{n}} {{address}}
83+
84+
# get regtest wallet balance
85+
[group('rpc')]
86+
balance wallet=default_wallet:
87+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} getbalance
88+
89+
# send n btc to address from wallet
90+
[group('rpc')]
91+
send n address wallet=default_wallet:
92+
bitcoin-cli -named -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} sendtoaddress address={{address}} amount={{n}}
93+
94+
# list wallet descriptors info, private = (true | false)
95+
[group('rpc')]
96+
descriptors private wallet=default_wallet:
97+
bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} listdescriptors {{private}}

0 commit comments

Comments
 (0)