Skip to content

Commit 595f104

Browse files
committed
Merge #198: Add Justfile command runner
98bef7e chore(add-justfile): update README (Vihiga Tyonum) ef84b92 chore: add Justfile for `just` command runner (Vihiga Tyonum) Pull request description: ### Description This PR adds Justfile config file for the just command runner. ### Notes to the reviewers The default values for `datadir`, `rpcuser` and `rpcpassword` set in the Justfile are those used in the project. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [x] I've added docs for the new feature * [ ] I've updated `CHANGELOG.md` ACKs for top commit: notmandatory: ACK 98bef7e Tree-SHA512: 3b515b19a79e545596fbc7fa458bb2a3c382557bdc17d6794299e2364524ede9509810807c2e0c7fe79879314e361ff9bd6cbc42ed5cbd812e30e77a82ad98e1
2 parents f56ca5e + 98bef7e commit 595f104

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-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}}

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ To generate a new extended master key, suitable for use in a descriptor:
113113
cargo run -- key generate
114114
```
115115

116+
## Justfile
117+
118+
We have added the `just` command runner to help you with common commands (during development) and running regtest `bitcoind` if you are using the `rpc` feature.
119+
Visit the [just](https://just.systems/man/en/packages.html) page for setup instructions.
120+
121+
The below are some of the commands included:
122+
123+
``` shell
124+
just # list all available recipes
125+
just start # start regtest bitcoind in default dir
126+
just test # test the project
127+
just build # build the project
128+
```
129+
130+
116131
## Minimum Supported Rust Version (MSRV)
117132

118133
This library should always compile with any valid combination of features on Rust **1.75.0**.

0 commit comments

Comments
 (0)