Skip to content

Commit 65e3abc

Browse files
committed
doc: document json rpc endpoints
fixes #20246 Document both JSON-RPC endpoints, when they are active and which types of requests they are able to service. Adds two example curl requests, one for each endpoint.
1 parent d4ebdce commit 65e3abc

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)