Skip to content

Commit e43fdfd

Browse files
committed
Merge bitcoin/bitcoin#27225: doc: document json rpc endpoints
65e3abc doc: document json rpc endpoints (willcl-ark) Pull request description: fixes #20246 This documents the two JSON-RPC endpoints available, details when they are active, specifies when they can or must be used, and outlines some known behaviour quirks. ACKs for top commit: fanquake: ACK 65e3abc - Seems fine. Can be improved if need be. Tree-SHA512: d557c2caf000a1bdd7b46c9da38afe63dc28446ba4a961526f1af3cec81d994a9da663e02c81ebdc4f609b794585349cfca77a582dc1e788c120de1d3b4c7db6
2 parents 436c185 + 65e3abc commit e43fdfd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

doc/JSON-RPC-interface.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,41 @@ The headless daemon `bitcoind` has the JSON-RPC API enabled by default, the GUI
55
option. In the GUI it is possible to execute RPC methods in the Debug Console
66
Dialog.
77

8+
## Endpoints
9+
10+
There are two JSON-RPC endpoints on the server:
11+
12+
1. `/`
13+
2. `/wallet/<walletname>/`
14+
15+
### `/` endpoint
16+
17+
This endpoint is always active.
18+
It can always service non-wallet requests and can service wallet requests when
19+
exactly one wallet is loaded.
20+
21+
### `/wallet/<walletname>/` endpoint
22+
23+
This endpoint is only activated when the wallet component has been compiled in.
24+
It can service both wallet and non-wallet requests.
25+
It MUST be used for wallet requests when two or more wallets are loaded.
26+
27+
This is the endpoint used by bitcoin-cli when a `-rpcwallet=` parameter is passed in.
28+
29+
Best practice would dictate using the `/wallet/<walletname>/` endpoint for ALL
30+
requests when multiple wallets are in use.
31+
32+
### Examples
33+
34+
```sh
35+
# Get block count from the / endpoint when rpcuser=alice and rpcport=38332
36+
$ curl --user alice --data-binary '{"jsonrpc": "1.0", "id": "0", "method": "getblockcount", "params": []}' -H 'content-type: text/plain;' localhost:38332/
37+
38+
# Get balance from the /wallet/walletname endpoint when rpcuser=alice, rpcport=38332 and rpcwallet=desc-wallet
39+
$ curl --user alice --data-binary '{"jsonrpc": "1.0", "id": "0", "method": "getbalance", "params": []}' -H 'content-type: text/plain;' localhost:38332/wallet/desc-wallet
40+
41+
```
42+
843
## Parameter passing
944

1045
The JSON-RPC server supports both _by-position_ and _by-name_ [parameter

0 commit comments

Comments
 (0)