Skip to content

Commit b4cad29

Browse files
committed
[example] add example_rpc README
1 parent ee09895 commit b4cad29

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Example RPC CLI
2+
3+
### Simple Regtest Test
4+
5+
1. Start local regtest bitcoind.
6+
```
7+
mkdir -p /tmp/regtest/bitcoind
8+
bitcoind -datadir=/tmp/regtest/bitcoind -regtest -server -fallbackfee=0.0002 -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -blockfilterindex=1 -peerblockfilters=1 -daemon
9+
```
10+
2. Create a test bitcoind wallet and set bitcoind env.
11+
```
12+
bitcoin-cli -datadir=/tmp/regtest/bitcoind -regtest -named createwallet wallet_name="test"
13+
export RPC_URL=127.0.0.1:18443
14+
export RPC_COOKIE=/tmp/regtest/bitcoind/regtest/.cookie
15+
```
16+
3. Get test bitcoind wallet info.
17+
```
18+
bitcoin-cli -rpcwallet="test" -datadir=/tmp/regtest/bitcoind -regtest getwalletinfo
19+
```
20+
4. Get new test bitcoind wallet address.
21+
```
22+
BITCOIND_ADDRESS=$(bitcoin-cli -rpcwallet="test" -datadir=/tmp/regtest/bitcoind -regtest getnewaddress)
23+
echo $BITCOIND_ADDRESS
24+
```
25+
5. Generate 101 blocks with reward to test bitcoind wallet address.
26+
```
27+
bitcoin-cli -datadir=/tmp/regtest/bitcoind -regtest generatetoaddress 101 $BITCOIND_ADDRESS
28+
```
29+
6. Verify test bitcoind wallet balance.
30+
```
31+
bitcoin-cli -rpcwallet="test" -datadir=/tmp/regtest/bitcoind -regtest getbalances
32+
```
33+
7. Set descriptor env and get address from RPC CLI wallet.
34+
```
35+
export DESCRIPTOR="wpkh(tprv8ZgxMBicQKsPfK9BTf82oQkHhawtZv19CorqQKPFeaHDMA4dXYX6eWsJGNJ7VTQXWmoHdrfjCYuDijcRmNFwSKcVhswzqs4fugE8turndGc/1/*)"
36+
cargo run -- --network regtest address next
37+
```
38+
8. Send 5 test bitcoin to RPC CLI wallet.
39+
```
40+
bitcoin-cli -rpcwallet="test" -datadir=/tmp/regtest/bitcoind -regtest send '[{"<address>":5}]'
41+
```
42+
9. Scan blockchain with RPC CLI wallet.
43+
```
44+
cargo run -- --network regtest scan
45+
<CNTRL-C to stop scanning>
46+
```
47+
10. Get RPC CLI wallet unconfirmed balances.
48+
```
49+
cargo run -- --network regtest balance
50+
```
51+
11. Generate 1 block with reward to test bitcoind wallet address.
52+
```
53+
bitcoin-cli -datadir=/tmp/regtest/bitcoind -regtest generatetoaddress 10 $BITCOIND_ADDRESS
54+
```
55+
12. Get RPC CLI wallet confirmed balances.
56+
```
57+
cargo run -- --network regtest balance
58+
```
59+
12. Get RPC CLI wallet transactions.
60+
```
61+
cargo run -- --network regtest txout list
62+
```

0 commit comments

Comments
 (0)