daemon-rpc.md 7.51 KB
Newer Older
Mike C's avatar
Mike C committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
layout: static_page
title: "Wallet RPC documentation"
title-pre-kick: "How to "
title-kick: "Wallet RPC documentation "
title-post-kick: ""
kick-class: "green-kicks"
icon: "icon_client"
attribution: "<!-- Icon is based on work by Freepik (http://www.freepik.com) and is licensed under Creative Commons BY 3.0 -->"
---

## General Remarks

This is a list of the bitmonerod daemon RPC calls, their inputs and outputs, and examples of each. Many RPC calls use the Daemon's JSON RPC interface, while others use their own interfaces.

On this page, you will find examples of these RPC calls.


## JSON RPC Methods

The majority of bitmonerod RPC calls use the daemon's `json_rpc` interface to request various bits of information. These methods all follow a similar structure, for example:

    IP=127.0.0.1
    PORT=18081
    METHOD="getblockheaderbyheight"
	PARAMS="{\"height\":912345}"
	curl \
		-X POST http://$IP:$PORT/json_rpc \
		-d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}' \
		-H 'Content-Type: application/json'

Some methods include parameters, while others do not. Examples of each JSON RPC method follow.

### getblockcount

### on_getblockhash

### getblocktemplate

### submitblock

Mike C's avatar
Mike C committed
42

Mike C's avatar
Mike C committed
43
44
### getlastblockheader

Mike C's avatar
Mike C committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Block header information for the most recent block is easily retrieved with this method. No inputs are needed.

Outputs:

* *block_header* - A structure containing block header information.
  * *depth* -  The number of blocks succeeding this block on the blockchain. A larger number means an older block.
  * *difficulty* - The strength of the Monero network based on mining power.
  * *hash* - The hash of this block.
  * *height* - The number of blocks preceding this block on the blockchain.
  * *major_version* - The major version of the monero protocol at this block height.
  * *minor_version* - The minor version of the monero protocol at this block height.
  * *nonce* - a cryptographic random one-time number used in mining a Monero block.
  * *orphan_status* - Usually `false`. If `true`, this block is not part of the longest chain.
  * *prev_hash* - The hash of the block immediately preceding this block in the chain.
  * *reward* - The amount of new atomic units generated in this block and rewarded to the miner. Note: 1 XMR = 1e12 atomic units.
  * *timestamp* - The time the block was recorded into the blockchain.

In this example, the most recent block (990793 at the time) is returned:

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getlastblockheader"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "depth": 0,
      "difficulty": 746963928,
      "hash": "ac0f1e226268d45c99a16202fdcb730d8f7b36ea5e5b4a565b1ba1a8fc252eb0",
      "height": 990793,
      "major_version": 1,
      "minor_version": 1,
      "nonce": 1550,
      "orphan_status": false,
      "prev_hash": "386575e3b0b004ed8d458dbd31bff0fe37b280339937f971e06df33f8589b75c",
      "reward": 6856609225169,
      "timestamp": 1457589942
    },
    "status": "OK"
  }
}


Mike C's avatar
Mike C committed
88
89
### getblockheaderbyhash

Mike C's avatar
Mike C committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Block header information can be retrieved using either a block's hash or height. This method includes a block's hash as an input parameter to retrieve basic information about the block.

Inputs:

* *hash* - The block's sha256 hash.

Outputs:

* *block_header* - A structure containing block header information.
  * *depth* -  The number of blocks succeeding this block on the blockchain. A larger number means an older block.
  * *difficulty* - The strength of the Monero network based on mining power.
  * *hash* - The hash of this block.
  * *height* - The number of blocks preceding this block on the blockchain.
  * *major_version* - The major version of the monero protocol at this block height.
  * *minor_version* - The minor version of the monero protocol at this block height.
  * *nonce* - a cryptographic random one-time number used in mining a Monero block.
  * *orphan_status* - Usually `false`. If `true`, this block is not part of the longest chain.
  * *prev_hash* - The hash of the block immediately preceding this block in the chain.
  * *reward* - The amount of new atomic units generated in this block and rewarded to the miner. Note: 1 XMR = 1e12 atomic units.
  * *timestamp* - The time the block was recorded into the blockchain.

In this example, block 912345 is looked up by its hash:

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getblockheaderbyhash","params":{"hash":"e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "depth": 78376,
      "difficulty": 815625611,
      "hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
      "height": 912345,
      "major_version": 1,
      "minor_version": 2,
      "nonce": 1646,
      "orphan_status": false,
      "prev_hash": "b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff78",
      "reward": 7388968946286,
      "timestamp": 1452793716
    },
    "status": "OK"
  }
}


Mike C's avatar
Mike C committed
137
138
### getblockheaderbyheight

Mike C's avatar
Mike C committed
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
Similar to `getblockheaderbyhash` above, this method includes a block's height as an input parameter to retrieve basic information about the block.

Inputs:

* *height* - The block's height.

Outputs:

* *block_header* - A structure containing block header information.
  * *depth* -  The number of blocks succeeding this block on the blockchain. A larger number means an older block.
  * *difficulty* - The strength of the Monero network based on mining power.
  * *hash* - The hash of this block.
  * *height* - The number of blocks preceding this block on the blockchain.
  * *major_version* - The major version of the monero protocol at this block height.
  * *minor_version* - The minor version of the monero protocol at this block height.
  * *nonce* - a cryptographic random one-time number used in mining a Monero block.
  * *orphan_status* - Usually `false`. If `true`, this block is not part of the longest chain.
  * *prev_hash* - The hash of the block immediately preceding this block in the chain.
  * *reward* - The amount of new atomic units generated in this block and rewarded to the miner. Note: 1 XMR = 1e12 atomic units.
  * *timestamp* - The time the block was recorded into the blockchain.

In this example, block 912345 is looked up by its height (notice that the returned information is the save as in the previous example):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getblockheaderbyheight","params":{"height":912345}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "depth": 78376,
      "difficulty": 815625611,
      "hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
      "height": 912345,
      "major_version": 1,
      "minor_version": 2,
      "nonce": 1646,
      "orphan_status": false,
      "prev_hash": "b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff78",
      "reward": 7388968946286,
      "timestamp": 1452793716
    },
    "status": "OK"
  }
}

Mike C's avatar
Mike C committed
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
### getblock

### get_connections

### get_info

### hard_fork_info

### setbans

### getbans

### flush_txpool


## Other Daemon RPC Calls

Not all daemon RPC calls use the JSON_RPC interface. This section gives examples of these calls.

###