daemon-rpc.md 82.9 KB
Newer Older
woodser's avatar
woodser committed
1
{% assign version = '2.2.0' | split: '.' %}
el00ruobuob's avatar
el00ruobuob committed
2
{% include disclaimer.html translated="false" version=page.version %}
erciccione's avatar
erciccione committed
3
4
5
6
7
8
## Introduction

This is a list of the monerod 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, as demonstrated below.

9
Note: "@atomic-units" refer to the smallest fraction of 1 XMR according to the monerod implementation. **1 XMR = 1e12 @atomic-units.**
erciccione's avatar
erciccione committed
10

11
12
Note2: Guide updated as of network height of 1,562,465.

erciccione's avatar
erciccione committed
13
14
### [JSON RPC Methods](#json-rpc-methods):

15
16
17
18
19
20
21
22
23
* [get_block_count](#get_block_count)
* [on_get_block_hash](#on_get_block_hash)
* [get_block_template](#get_block_template)
* [submit_block](#submit_block)
* [get_last_block_header](#get_last_block_header)
* [get_block_header_by_hash](#get_block_header_by_hash)
* [get_block_header_by_height](#get_block_header_by_height)
* [get_block_headers_range](#get_block_headers_range)
* [get_block](#get_block)
erciccione's avatar
erciccione committed
24
25
26
* [get_connections](#get_connections)
* [get_info](#get_info)
* [hard_fork_info](#hard_fork_info)
27
28
29
30
31
32
33
34
35
36
37
38
* [set_bans](#set_bans)
* [get_bans](#get_bans)
* [flush_txpool](#flush_txpool)
* [get_output_histogram](#get_output_histogram)
* [get_version](#get_version)
* [get_coinbase_tx_sum](#get_coinbase_tx_sum)
* [get_fee_estimate](#get_fee_estimate)
* [get_alternate_chains](#get_alternate_chains)
* [relay_tx](#relay_tx)
* [sync_info](#sync_info)
* [get_txpool_backlog](#get_txpool_backlog)
* [get_output_distribution](#get_output_distribution)
erciccione's avatar
erciccione committed
39
40
41

### [Other RPC Methods](#other-daemon-rpc-calls):

42
* [/get_height](#get_height)
Paul K's avatar
Paul K committed
43
44
45
46
47
48
49
* [/get_blocks.bin](#get_blocksbin)
* [/get_blocks_by_height.bin](#get_blocks_by_heightbin)
* [/get_hashes.bin](#get_hashesbin)
* [/get_o_indexes.bin](#get_o_indexesbin)
* [/get_random_outs.bin](#get_random_outsbin)
* [/get_outs.bin](#get_outsbin)
* [/get_random_rctouts.bin](#get_random_rctoutsbin)
50
51
* [/get_transactions](#get_transactions)
* [/get_alt_blocks_hashes](#get_alt_blocks_hashes)
erciccione's avatar
erciccione committed
52
* [/is_key_image_spent](#is_key_image_spent)
53
54
55
56
57
58
59
60
61
* [/send_raw_transaction](#send_raw_transaction)
* [/start_mining](#start_mining)
* [/stop_mining](#stop_mining)
* [/mining_status](#mining_status)
* [/save_bc](#save_bc)
* [/get_peer_list](#get_peer_list)
* [/set_log_hash_rate](#set_log_hash_rate)
* [/set_log_level](#set_log_level)
* [/set_log_categories](#set_log_categories)
erciccione's avatar
erciccione committed
62
* [/get_transaction_pool](#get_transaction_pool)
Paul K's avatar
Paul K committed
63
* [/get_transaction_pool_hashes.bin](#get_transaction_pool_hashesbin)
64
* [/get_transaction_pool_stats](#get_transaction_pool_stats)
erciccione's avatar
erciccione committed
65
* [/stop_daemon](#stop_daemon)
66
67
68
69
70
71
72
73
74
* [/get_info (not JSON)](#get_info-not-json)
* [/get_limit](#get_limit)
* [/set_limit](#set_limit)
* [/out_peers](#out_peers)
* [/in_peers](#in_peers)
* [/start_save_graph](#start_save_graph)
* [/stop_save_graph](#stop_save_graph)
* [/get_outs](#get_outs)
* [/update](#update)
erciccione's avatar
erciccione committed
75
76
77
78
79
80
81
82
83
84
85


---

## JSON RPC Methods

The majority of monerod 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
86
87
METHOD='get_block_header_by_height'
ALIAS='getblockheaderbyheight'
erciccione's avatar
erciccione committed
88
89
90
91
92
93
94
95
96
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.

97
### **get_block_count**
erciccione's avatar
erciccione committed
98
99
100

Look up how many blocks are in the longest chain known to the node.

101
102
Alias: *getblockcount*.

erciccione's avatar
erciccione committed
103
104
105
106
107
108
109
110
111
112
Inputs: *None*.

Outputs:

* *count* - unsigned int; Number of blocks in longest chain seen by the node.
* *status* - string; General RPC error code. "OK" means everything looks good.

Example:

```
113
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_count"}' -H 'Content-Type: application/json'  
erciccione's avatar
erciccione committed
114
115
116
117
118
119
120
121
122
123
124
125

{  
  "id": "0",  
  "jsonrpc": "2.0",  
  "result": {  
    "count": 993163,  
    "status": "OK"  
  }  
}  
```


126
### **on_get_block_hash**
erciccione's avatar
erciccione committed
127
128
129

Look up a block's hash by its height.

130
131
Alias: *on_getblockhash*.

erciccione's avatar
erciccione committed
132
133
134
Inputs:

* block height (int array of length 1)
135

erciccione's avatar
erciccione committed
136
137
138
139
140
141
142
Outputs:

* block hash (string)

Example:

```
143
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"on_get_block_hash","params":[912345]}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
144
145
146
147
148
149
150
151
152

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6"
}
```


153
154
155
156
157
### **get_block_template**

Get a block template on which mining a new block.

Alias: *getblocktemplate*.
erciccione's avatar
erciccione committed
158
159
160
161
162
163
164
165
166

Inputs:

* *wallet_address* - string; Address of wallet to receive coinbase transactions if block is successfully mined.
* *reserve_size* - unsigned int; Reserve size.

Outputs:

* *blocktemplate_blob* - string; Blob on which to try to mine a new block.
167
* *blockhashing_blob* - string; Blob on which to try to find a valid nonce.
erciccione's avatar
erciccione committed
168
* *difficulty* - unsigned int; Difficulty of next block.
169
* *expected_reward* - unsigned int; Coinbase reward expected to be received if block is successfully mined.
erciccione's avatar
erciccione committed
170
171
172
173
* *height* - unsigned int; Height on which to mine.
* *prev_hash* - string; Hash of the most recent block on which to mine the next block.
* *reserved_offset* - unsigned int; Reserved offset.
* *status* - string; General RPC error code. "OK" means everything looks good.
174
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
erciccione's avatar
erciccione committed
175
176
177
178

Example:

```
179
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_template","params":{"wallet_address":"44GBHzv6ZyQdJkjqZje6KLZ3xSyN1hBSFAnLP6EAqJtCRVzMzZmeXTC2AHKDS9aEDTRKmo6a6o9r9j86pYfhCWDkKjbtcns","reserve_size":60}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
180
181
182
183
184

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
185
186
187
188
189
190
191
192
193
    "blockhashing_blob": "070786a498d705f8dc58791266179087907a2ff4cd883615216749b97d2f12173171c725a6f84a00000000fc751ea4a94c2f840751eaa36138eee66dda15ef554e7d6594395827994e31da10",
    "blocktemplate_blob": "070786a498d705f8dc58791266179087907a2ff4cd883615216749b97d2f12173171c725a6f84a0000000002aeab5f01fff2aa5f01e0a9d0f2f08a01028fdb3d5b5a2c363d36ea17a4add99a23a3ec7935b4c3e1e0364fcc4295c7a2ef5f01f912b15f5d17c1539d4722f79d8856d8654c5af87f54cfb3a4ff7f6b512b2a08023c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f1755090c809421d69873c161e7969b8bf33cee3b451dd4859bfc244a705f0b4900498f804b6023e13fa023a0fb759e8b7c9a39506a21442bc47077beeedc6b78d34c4ebdae91bd96097ccc9a882bc5056568b0d2f1f06559368fea4acba8e745444e883e53156d5083c1fd260edf05292934c8b40c098b81fe4e261720bdd272b209e317247a1d2c55dc4718891af0d16273c5a610f36f382a3bf50f54808aaa6a508e51d4601dd0d8fbf8b3b1685066ce121666a1409e8ac7a4d673c1cc36d10b825f764af647441f53230518e4d2efbcf8791c6060912c76e90db4982a66d51bbd96290bbb34db8080b216c2940cec407260bf5e2c3a5ee280835f15298f0801e9d98c4d414792282fbc2c28c3e20bc0fcb1829b5c3ad8f8d20847be8fdb2a949fd96f0205fbd6d271c880c5d8c83e9813606cd803a44d377fdeae45bfa67112132af601e9b3b0613ba7dff2ec3d4b935c447b47bfe39f7b950981b2f4c66c0d853e2218f1f69229a9b608c3d98be09b6d4d640a9f6ff0e920dbacf7e58b59554c0b398b1ae4b1d497104b4e4e745d850eed7eddb8aa93437427bf442ae5beb22cbf10a8fa738ea38cfa5d86dfd30675d4be11a38016e36936fd5601e52643e8b8bc433702ea7ae6149309c95b898cc854850e73fe0b95c5b8879b7325ecd4",
    "difficulty": 61043624293,
    "expected_reward": 4771949057248,
    "height": 1561970,
    "prev_hash": "f8dc58791266179087907a2ff4cd883615216749b97d2f12173171c725a6f84a",
    "reserved_offset": 129,
    "status": "OK",
    "untrusted": false
erciccione's avatar
erciccione committed
194
195
196
197
198
  }
}
```


199
### **submit_block**
erciccione's avatar
erciccione committed
200
201
202

Submit a mined block to the network.

203
204
Alias: *submitblock*.

erciccione's avatar
erciccione committed
205
206
Inputs:

207
* Block blob data - array of strings; list of block blobs which have been mined.  See [get_block_template](#get_block_template) to get a blob on which to mine.
erciccione's avatar
erciccione committed
208
209
210
211
212

Outputs:

* *status* - string; Block submit status.

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
In this example, a block blob which has not been mined is submitted:

```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"submit_block","params":["0707e6bdfedc053771512f1bc27c62731ae9e8f2443db64ce742f4e57f5cf8d393de28551e441a0000000002fb830a01ffbf830a018cfe88bee283060274c0aae2ef5730e680308d9c00b6da59187ad0352efe3c71d36eeeb28782f29f2501bd56b952c3ddc3e350c2631d3a5086cac172c56893831228b17de296ff4669de020200000000"]' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "error": {
    "code": -7,
    "message": "Block not accepted"
  }
}
```

erciccione's avatar
erciccione committed
228

229
### **get_last_block_header**
erciccione's avatar
erciccione committed
230
231
232

Block header information for the most recent block is easily retrieved with this method. No inputs are needed.

233
234
Alias: *getlastblockheader*.

erciccione's avatar
erciccione committed
235
236
237
238
239
Inputs: *None*.

Outputs:

* *block_header* - A structure containing block header information.
240
  * *block_size* - unsigned int; The block size in bytes.
erciccione's avatar
erciccione committed
241
242
243
244
245
246
247
  * *depth* -  unsigned int; The number of blocks succeeding this block on the blockchain. A larger number means an older block.
  * *difficulty* - unsigned int; The strength of the Monero network based on mining power.
  * *hash* - string; The hash of this block.
  * *height* - unsigned int; The number of blocks preceding this block on the blockchain.
  * *major_version* - unsigned int; The major version of the monero protocol at this block height.
  * *minor_version* - unsigned int; The minor version of the monero protocol at this block height.
  * *nonce* - unsigned int; a cryptographic random one-time number used in mining a Monero block.
248
  * *num_txes* - unsigned int; Number of transactions in the block, not counting the coinbase tx.
erciccione's avatar
erciccione committed
249
250
  * *orphan_status* - boolean; Usually `false`. If `true`, this block is not part of the longest chain.
  * *prev_hash* - string; The hash of the block immediately preceding this block in the chain.
251
  * *reward* - unsigned int; The amount of new @atomic-units generated in this block and rewarded to the miner. Note: 1 XMR = 1e12 @atomic-units.
252
  * *timestamp* - unsigned int; The unix time at which the block was recorded into the blockchain.
erciccione's avatar
erciccione committed
253
* *status* - string; General RPC error code. "OK" means everything looks good.
254
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
erciccione's avatar
erciccione committed
255

256
In this example, the most recent block (1562023 at the time) is returned:
erciccione's avatar
erciccione committed
257
258

```
259
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_last_block_header"}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
260
261
262
263
264
265

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
266
      "block_size": 62774,
erciccione's avatar
erciccione committed
267
      "depth": 0,
268
269
270
271
272
273
274
      "difficulty": 60097900840,
      "hash": "3a289b8fa88b10e2163826c230b45d79f2be37d14fa3153ee58ff8a427782d14",
      "height": 1562023,
      "major_version": 7,
      "minor_version": 7,
      "nonce": 3789681204,
      "num_txes": 5,
erciccione's avatar
erciccione committed
275
      "orphan_status": false,
276
277
278
      "prev_hash": "743e5d0a26849efe27b96086f2c4ecc39a0bc744bf21473dad6710221aff6ac3",
      "reward": 4724029079703,
      "timestamp": 1525029411
erciccione's avatar
erciccione committed
279
    },
280
281
    "status": "OK",
    "untrusted": false
erciccione's avatar
erciccione committed
282
283
284
285
286
  }
}
```


287
### **get_block_header_by_hash**
erciccione's avatar
erciccione committed
288
289
290

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.

291
292
Alias: *getblockheaderbyhash*.

erciccione's avatar
erciccione committed
293
294
295
296
297
298
Inputs:

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

Outputs:

299
300
301
* *block_header* - A structure containing block header information. See [get_last_block_header](#get_last_block_header).
* *status* - string; General RPC error code. "OK" means everything looks good.
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
erciccione's avatar
erciccione committed
302
303
304
305

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

```
306
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_hash","params":{"hash":"e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6"}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
307
308
309
310
311
312

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
313
314
      "block_size": 210,
      "depth": 649717,
erciccione's avatar
erciccione committed
315
316
317
318
319
320
      "difficulty": 815625611,
      "hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
      "height": 912345,
      "major_version": 1,
      "minor_version": 2,
      "nonce": 1646,
321
      "num_txes": 0,
erciccione's avatar
erciccione committed
322
323
324
325
326
      "orphan_status": false,
      "prev_hash": "b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff78",
      "reward": 7388968946286,
      "timestamp": 1452793716
    },
327
328
    "status": "OK",
    "untrusted": false
erciccione's avatar
erciccione committed
329
330
331
332
333
  }
}
```


334
335
336
### **get_block_header_by_height**

Similar to [get_block_header_by_hash](#get_block_header_by_hash) above, this method includes a block's height as an input parameter to retrieve basic information about the block.
erciccione's avatar
erciccione committed
337

338
Alias: *getblockheaderbyheight*.
erciccione's avatar
erciccione committed
339
340
341
342
343
344
345

Inputs:

* *height* - unsigned int; The block's height.

Outputs:

346
347
348
* *block_header* - A structure containing block header information. See [get_last_block_header](#get_last_block_header).
* *status* - string; General RPC error code. "OK" means everything looks good.
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
erciccione's avatar
erciccione committed
349

350
In this example, block 912345 is looked up by its height (notice that the returned information is the same as in the previous example):
erciccione's avatar
erciccione committed
351
352

```
353
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_height","params":{"height":912345}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
354
355
356
357
358
359

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
360
361
      "block_size": 210,
      "depth": 649721,
erciccione's avatar
erciccione committed
362
363
364
365
366
367
      "difficulty": 815625611,
      "hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
      "height": 912345,
      "major_version": 1,
      "minor_version": 2,
      "nonce": 1646,
368
      "num_txes": 0,
erciccione's avatar
erciccione committed
369
370
371
372
373
      "orphan_status": false,
      "prev_hash": "b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff78",
      "reward": 7388968946286,
      "timestamp": 1452793716
    },
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
    "status": "OK",
    "untrusted": false
  }
}
```

### **get_block_headers_range**

Similar to [get_block_header_by_height](#get_block_header_by_height) above, but for a range of blocks. This method includes a starting block height and an ending block height as parameters to retrieve basic information about the range of blocks.

Alias: *getblockheadersrange*.

Inputs:

* *start_height* - unsigned int; The starting block's height.
* *end_height* - unsigned int; The ending block's height.

Outputs:

* *headers* - array of `block_header` (a structure containing block header information. See [get_last_block_header](#get_last_block_header)).
* *status* - string; General RPC error code. "OK" means everything looks good.
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).

In this example, blocks range from height 1545999 to 1546000 is looked up (notice that the returned informations are ascending order and that it is at the April 2018 network upgrade time):

```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_headers_range","params":{"start_height":1545999,"end_height":1546000}}' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "headers": [{
      "block_size": 301413,
      "depth": 16085,
      "difficulty": 134636057921,
      "hash": "86d1d20a40cefcf3dd410ff6967e0491613b77bf73ea8f1bf2e335cf9cf7d57a",
      "height": 1545999,
      "major_version": 6,
      "minor_version": 6,
      "nonce": 3246403956,
      "num_txes": 20,
      "orphan_status": false,
      "prev_hash": "0ef6e948f77b8f8806621003f5de24b1bcbea150bc0e376835aea099674a5db5",
      "reward": 5025593029981,
      "timestamp": 1523002893
    },{
      "block_size": 13322,
      "depth": 16084,
      "difficulty": 134716086238,
      "hash": "b408bf4cfcd7de13e7e370c84b8314c85b24f0ba4093ca1d6eeb30b35e34e91a",
      "height": 1546000,
      "major_version": 7,
      "minor_version": 7,
      "nonce": 3737164176,
      "num_txes": 1,
      "orphan_status": false,
      "prev_hash": "86d1d20a40cefcf3dd410ff6967e0491613b77bf73ea8f1bf2e335cf9cf7d57a",
      "reward": 4851952181070,
      "timestamp": 1523002931
    }],
    "status": "OK",
    "untrusted": false
erciccione's avatar
erciccione committed
437
438
439
440
441
  }
}
```


442
### **get_block**
erciccione's avatar
erciccione committed
443
444
445

Full block information can be retrieved by either block height or hash, like with the above block header calls. For full block information, both lookups use the same method, but with different input parameters.

446
447
Alias: *getblock*.

erciccione's avatar
erciccione committed
448
449
450
451
452
453
454
455
Inputs (pick one of the following):

* *height* - unsigned int; The block's height.
* *hash* - string; The block's hash.

Outputs:

* *blob* - string; Hexadecimal blob of block information.
456
* *block_header* - A structure containing block header information. See [get_last_block_header](#get_last_block_header).
erciccione's avatar
erciccione committed
457
458
459
460
461
462
463
464
465
466
467
468
469
* *json* - json string; JSON formatted block details:
  * *major_version* - Same as in block header.
  * *minor_version* - Same as in block header.
  * *timestamp* - Same as in block header.
  * *prev_id* - Same as `prev_hash` in block header.
  * *nonce* - Same as in block header.
  * *miner_tx* - Miner transaction information
    * *version* - Transaction version number.
    * *unlock_time* - The block height when the coinbase transaction becomes spendable.
    * *vin* - List of transaction inputs:
      * *gen* - Miner txs are coinbase txs, or "gen".
        * *height* - This block height, a.k.a. when the coinbase is generated.
    * *vout* - List of transaction outputs. Each output contains:
470
      * *amount* - The amount of the output, in @atomic-units.
471
472
      * *target* -
        * *key* -
erciccione's avatar
erciccione committed
473
474
475
476
    * *extra* - Usually called the "transaction ID" but can be used to include any random 32 byte/64 character hex string.
    * *signatures* - Contain signatures of tx signers. Coinbased txs do not have signatures.
  * *tx_hashes* - List of hashes of non-coinbase transactions in the block. If there are no other transactions, this will be an empty list.
* *status* - string; General RPC error code. "OK" means everything looks good.
477
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
erciccione's avatar
erciccione committed
478
479
480
481
482
483

**Look up by height:**

In the following example, block 912345 is looked up by its height. Note that block 912345 does not have any non-coinbase transactions. (See the next example for a block with extra transactions):

```
484
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"height":912345}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
485
486
487
488
489

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
490
    "blob": "0102f4bedfb405b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff786e0600000195d83701ffd9d73704ee84ddb42102378b043c1724c92c69d923d266fe86477d3a5ddd21145062e148c64c5767700880c0fc82aa020273733cbd6e6218bda671596462a4b062f95cfe5e1dbb5b990dacb30e827d02f280f092cbdd080247a5dab669770da69a860acde21616a119818e1a489bb3c4b1b6b3c50547bc0c80e08d84ddcb01021f7e4762b8b755e3e3c72b8610cc87b9bc25d1f0a87c0c816ebb952e4f8aff3d2b01fd0a778957f4f3103a838afda488c3cdadf2697b3d34ad71234282b2fad9100e02080000000bdfc2c16c00",
erciccione's avatar
erciccione committed
491
    "block_header": {
492
493
      "block_size": 210,
      "depth": 649772,
erciccione's avatar
erciccione committed
494
495
496
497
498
499
      "difficulty": 815625611,
      "hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
      "height": 912345,
      "major_version": 1,
      "minor_version": 2,
      "nonce": 1646,
500
      "num_txes": 0,
erciccione's avatar
erciccione committed
501
502
503
504
505
506
      "orphan_status": false,
      "prev_hash": "b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff78",
      "reward": 7388968946286,
      "timestamp": 1452793716
    },
    "json": "{\n  \"major_version\": 1, \n  \"minor_version\": 2, \n  \"timestamp\": 1452793716, \n  \"prev_id\": \"b61c58b2e0be53fad5ef9d9731a55e8a81d972b8d90ed07c04fd37ca6403ff78\", \n  \"nonce\": 1646, \n  \"miner_tx\": {\n    \"version\": 1, \n    \"unlock_time\": 912405, \n    \"vin\": [ {\n        \"gen\": {\n          \"height\": 912345\n        }\n      }\n    ], \n    \"vout\": [ {\n        \"amount\": 8968946286, \n        \"target\": {\n          \"key\": \"378b043c1724c92c69d923d266fe86477d3a5ddd21145062e148c64c57677008\"\n        }\n      }, {\n        \"amount\": 80000000000, \n        \"target\": {\n          \"key\": \"73733cbd6e6218bda671596462a4b062f95cfe5e1dbb5b990dacb30e827d02f2\"\n        }\n      }, {\n        \"amount\": 300000000000, \n        \"target\": {\n          \"key\": \"47a5dab669770da69a860acde21616a119818e1a489bb3c4b1b6b3c50547bc0c\"\n        }\n      }, {\n        \"amount\": 7000000000000, \n        \"target\": {\n          \"key\": \"1f7e4762b8b755e3e3c72b8610cc87b9bc25d1f0a87c0c816ebb952e4f8aff3d\"\n        }\n      }\n    ], \n    \"extra\": [ 1, 253, 10, 119, 137, 87, 244, 243, 16, 58, 131, 138, 253, 164, 136, 195, 205, 173, 242, 105, 123, 61, 52, 173, 113, 35, 66, 130, 178, 250, 217, 16, 14, 2, 8, 0, 0, 0, 11, 223, 194, 193, 108\n    ], \n    \"signatures\": [ ]\n  }, \n  \"tx_hashes\": [ ]\n}",
507
508
509
    "miner_tx_hash": "c7da3965f25c19b8eb7dd8db48dcd4e7c885e2491db77e289f0609bf8e08ec30",
    "status": "OK",
    "untrusted": false
erciccione's avatar
erciccione committed
510
511
512
513
514
515
516
517
518
  }
}
```

**Look up by hash:**

In the following example, block 993056 is looked up by its hash. Note that block 993056 has 3 non-coinbase transactions:

```
519
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"hash":"510ee3c4e14330a7b96e883c323a60ebd1b5556ac1262d0bc03c24a3b785516f"}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
520
521
522
523
524

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
525
    "blob": "0102a3978cb7050ea4af6547c05c965afc8df6d31509ff3105dc7ae6b10172521d77e09711fd6df407000001dcce3c01ffa0ce3c049da8bece070259e9d685b3484886bc7b47c133e6099ecdf212d5eaa16ce19cd58e8c3c1e590a80d88ee16f024c5e2f542d25513c46b9e3b7d40140a22d0ae5314bfcae492ad9f56fff8185f080d0b8e1981a0213dd8ffdac9e6a2f71e327dad65328198dc879a492d145eae72677c0703a351580c0f9decfae010262bda00341681dccbc066757862da593734395745bdfe1fdc89b5948c86a5d4c2b01b691851cf057b9c302a3dbca879e1cba4cc45061ca55aaa6e03cdc67ab9e455002080000000c617fdf160379c6b9f00db027bde151705aafe85c495883aae2597d5cb8e1adb2e0f3ae1d07d715db73331abc3ec588ef07c7bb195786a4724b08dff431b51ffa32a4ce899bb197066426c0ed89f0b431fe171f7fd62bc95dd29943daa7cf3585cf1fdfc99d",
erciccione's avatar
erciccione committed
526
    "block_header": {
527
528
      "block_size": 3981,
      "depth": 569068,
erciccione's avatar
erciccione committed
529
530
531
532
533
534
      "difficulty": 964985344,
      "hash": "510ee3c4e14330a7b96e883c323a60ebd1b5556ac1262d0bc03c24a3b785516f",
      "height": 993056,
      "major_version": 1,
      "minor_version": 2,
      "nonce": 2036,
535
      "num_txes": 3,
erciccione's avatar
erciccione committed
536
537
538
539
540
541
      "orphan_status": false,
      "prev_hash": "0ea4af6547c05c965afc8df6d31509ff3105dc7ae6b10172521d77e09711fd6d",
      "reward": 6932043647005,
      "timestamp": 1457720227
    },
    "json": "{\n  \"major_version\": 1, \n  \"minor_version\": 2, \n  \"timestamp\": 1457720227, \n  \"prev_id\": \"0ea4af6547c05c965afc8df6d31509ff3105dc7ae6b10172521d77e09711fd6d\", \n  \"nonce\": 2036, \n  \"miner_tx\": {\n    \"version\": 1, \n    \"unlock_time\": 993116, \n    \"vin\": [ {\n        \"gen\": {\n          \"height\": 993056\n        }\n      }\n    ], \n    \"vout\": [ {\n        \"amount\": 2043647005, \n        \"target\": {\n          \"key\": \"59e9d685b3484886bc7b47c133e6099ecdf212d5eaa16ce19cd58e8c3c1e590a\"\n        }\n      }, {\n        \"amount\": 30000000000, \n        \"target\": {\n          \"key\": \"4c5e2f542d25513c46b9e3b7d40140a22d0ae5314bfcae492ad9f56fff8185f0\"\n        }\n      }, {\n        \"amount\": 900000000000, \n        \"target\": {\n          \"key\": \"13dd8ffdac9e6a2f71e327dad65328198dc879a492d145eae72677c0703a3515\"\n        }\n      }, {\n        \"amount\": 6000000000000, \n        \"target\": {\n          \"key\": \"62bda00341681dccbc066757862da593734395745bdfe1fdc89b5948c86a5d4c\"\n        }\n      }\n    ], \n    \"extra\": [ 1, 182, 145, 133, 28, 240, 87, 185, 195, 2, 163, 219, 202, 135, 158, 28, 186, 76, 196, 80, 97, 202, 85, 170, 166, 224, 60, 220, 103, 171, 158, 69, 80, 2, 8, 0, 0, 0, 12, 97, 127, 223, 22\n    ], \n    \"signatures\": [ ]\n  }, \n  \"tx_hashes\": [ \"79c6b9f00db027bde151705aafe85c495883aae2597d5cb8e1adb2e0f3ae1d07\", \"d715db73331abc3ec588ef07c7bb195786a4724b08dff431b51ffa32a4ce899b\", \"b197066426c0ed89f0b431fe171f7fd62bc95dd29943daa7cf3585cf1fdfc99d\"\n  ]\n}",
542
    "miner_tx_hash": "372395aeac5e5ad2c40b4c546b0bad00c4242fb2bd88e2e25f4e43231876f81e",
erciccione's avatar
erciccione committed
543
    "status": "OK",
544
545
    "tx_hashes": ["79c6b9f00db027bde151705aafe85c495883aae2597d5cb8e1adb2e0f3ae1d07","d715db73331abc3ec588ef07c7bb195786a4724b08dff431b51ffa32a4ce899b","b197066426c0ed89f0b431fe171f7fd62bc95dd29943daa7cf3585cf1fdfc99d"],
    "untrusted": false
erciccione's avatar
erciccione committed
546
547
548
549
550
551
552
553
554
  }
}
```


### **get_connections**

Retrieve information about incoming and outgoing connections to your node.

555
556
Alias: *None*.

erciccione's avatar
erciccione committed
557
558
559
560
561
Inputs: *None*.

Outputs:

* *connections* - List of all connections and their info:
562
  * *address* - string; The peer's address, actually IPv4 & port
erciccione's avatar
erciccione committed
563
564
  * *avg_download* - unsigned int; Average bytes of data downloaded by node.
  * *avg_upload* - unsigned int; Average bytes of data uploaded by node.
565
  * *connection_id* - string; The connection ID
erciccione's avatar
erciccione committed
566
567
  * *current_download* - unsigned int; Current bytes downloaded by node.
  * *current_upload* - unsigned int; Current bytes uploaded by node.
568
569
  * *height*- unsigned int; The peer height
  * *host* - string; The peer host
erciccione's avatar
erciccione committed
570
571
572
573
574
575
  * *incoming* - boolean; Is the node getting information from your node?
  * *ip* - string; The node's IP address.
  * *live_time* - unsigned int
  * *local_ip* - boolean
  * *localhost* - boolean
  * *peer_id* - string; The node's ID on the network.
576
  * *port* - string; The port that the node is using to connect to the network.
erciccione's avatar
erciccione committed
577
578
579
580
581
  * *recv_count* - unsigned int
  * *recv_idle_time* - unsigned int
  * *send_count* - unsigned int
  * *send_idle_time* - unsigned int
  * *state* - string
582
  * *support_flags* - unsigned int
erciccione's avatar
erciccione committed
583
584
585
586
587
588
589
590
591
592
593

Following is an example of `get_connections` and it's return:

```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_connections"}' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "connections": [{
594
      "address": "173.90.69.136:62950",
erciccione's avatar
erciccione committed
595
      "avg_download": 0,
596
597
      "avg_upload": 2,
      "connection_id": "083c301a3030329a487adb12ad981d2c",
erciccione's avatar
erciccione committed
598
      "current_download": 0,
599
600
601
602
603
604
      "current_upload": 2,
      "height": 1562127,
      "host": "173.90.69.136",
      "incoming": true,
      "ip": "173.90.69.136",
      "live_time": 8,
erciccione's avatar
erciccione committed
605
606
      "local_ip": false,
      "localhost": false,
607
608
609
610
611
612
613
614
      "peer_id": "c959fbfbed9e44fb",
      "port": "62950",
      "recv_count": 259,
      "recv_idle_time": 8,
      "send_count": 24342,
      "send_idle_time": 8,
      "state": "state_normal",
      "support_flags": 0
erciccione's avatar
erciccione committed
615
616
617
618
619
620
621
622
623
624
625
626
627
    },{
    ...
    }],
    "status": "OK"
  }
}
```


### **get_info**

Retrieve general information about the state of your node and the network.

628
629
630
631
632
633
634
Alias:

* */get_info*
* */getinfo*

See other RPC Methods [/get_info (not JSON)](#get_info-not-json)

erciccione's avatar
erciccione committed
635
636
637
638
639
Inputs: *None*.

Outputs:

* *alt_blocks_count* - unsigned int; Number of alternative blocks to main chain.
640
641
642
643
* *block_size_limit* - unsigned int; Maximum allowed block size
* *block_size_median* - unsigned int; Median block size of latest 100 blocks
* *bootstrap_daemon_address* - string; @Bootstrap-node to give immediate usability to wallets while syncing by proxying RPC to it. (Note: the replies may be untrustworthy).
* *cumulative_difficulty* - unsigned int; Cumulative difficulty of all blocks in the blockchain.
erciccione's avatar
erciccione committed
644
* *difficulty* - unsigned int; Network difficulty (analogous to the strength of the network)
645
* *free_space* - unsigned int; Available disk space on the node.
erciccione's avatar
erciccione committed
646
647
* *grey_peerlist_size* - unsigned int; Grey Peerlist Size
* *height* - unsigned int; Current length of longest chain known to daemon.
648
* *height_without_bootstrap* - unsigned int; Current length of the local chain of the daemon.
erciccione's avatar
erciccione committed
649
* *incoming_connections_count* - unsigned int; Number of peers connected to and pulling from your node.
650
651
* *mainnet* - boolean; States if the node is on the mainnet (`true`) or not (`false`).
* *offline* - boolean; States if the node is offline (`true`) or online (`false`).
erciccione's avatar
erciccione committed
652
* *outgoing_connections_count* - unsigned int; Number of peers that you are connected to and getting information from.
653
654
655
* *rpc_connections_count* - unsigned int; Number of RPC client connected to the daemon (Including this RPC request).
* *stagenet* - boolean; States if the node is on the stagenet (`true`) or not (`false`).
* *start_time* - unsigned int; Start time of the daemon, as UNIX time.
erciccione's avatar
erciccione committed
656
657
658
* *status* - string; General RPC error code. "OK" means everything looks good.
* *target* - unsigned int; Current target for next proof of work.
* *target_height* - unsigned int; The height of the next block in the chain.
659
* *testnet* - boolean; States if the node is on the testnet (`true`) or not (`false`).
erciccione's avatar
erciccione committed
660
661
* *top_block_hash* - string; Hash of the highest block in the chain.
* *tx_count* - unsigned int; Total number of non-coinbase transaction in the chain.
662
663
664
* *tx_pool_size* - unsigned int; Number of transactions that have been broadcast but not included in a block.
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
* *was_bootstrap_ever_used* - boolean; States if a bootstrap node has ever been used since the daemon started.
erciccione's avatar
erciccione committed
665
666
667
668
669
670
671
672
673
674
675
* *white_peerlist_size* - unsigned int; White Peerlist Size

Following is an example `get_info` call and its return:

```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
676
677
678
679
680
681
682
683
684
685
686
687
688
    "alt_blocks_count": 6,
    "block_size_limit": 600000,
    "block_size_median": 129017,
    "bootstrap_daemon_address": "",
    "cumulative_difficulty": 14121125493385685,
    "difficulty": 60580751777,
    "free_space": 138758750208,
    "grey_peerlist_size": 4998,
    "height": 1562168,
    "height_without_bootstrap": 1562168,
    "incoming_connections_count": 2,
    "mainnet": true,
    "offline": false,
erciccione's avatar
erciccione committed
689
    "outgoing_connections_count": 8,
690
691
692
    "rpc_connections_count": 2,
    "stagenet": false,
    "start_time": 1524751757,
erciccione's avatar
erciccione committed
693
    "status": "OK",
694
695
    "target": 120,
    "target_height": 1562063,
erciccione's avatar
erciccione committed
696
    "testnet": false,
697
698
699
700
701
702
    "top_block_hash": "7a7ba647080844073fdd8e3a069e00554c773d6e6863354dba1dec45a43f5592",
    "tx_count": 2759894,
    "tx_pool_size": 755,
    "untrusted": false,
    "was_bootstrap_ever_used": false,
    "white_peerlist_size": 1000
erciccione's avatar
erciccione committed
703
704
705
706
707
708
709
710
711
  }
}
```


### **hard_fork_info**

Look up information regarding hard fork voting and readiness.

712
713
Alias: *None*.

erciccione's avatar
erciccione committed
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
Inputs: *None*.

Outputs:

* *earliest_height* - unsigned int; Block height at which hard fork would be enabled if voted in.
* *enabled* - boolean; Tells if hard fork is enforced.
* *state* - unsigned int; Current hard fork state: 0 (There is likely a hard fork), 1 (An update is needed to fork properly), or 2 (Everything looks good).
* *status* - string; General RPC error code. "OK" means everything looks good.
* *threshold* - unsigned int; Minimum percent of votes to trigger hard fork. Default is 80.
* *version* - unsigned int; The major block version for the fork.
* *votes* - unsigned int; Number of votes towards hard fork.
* *voting* - unsigned int; Hard fork voting status.
* *window* - unsigned int; Number of blocks over which current votes are cast. Default is 10080 blocks.

Example:

```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"hard_fork_info"}' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "earliest_height": 1009827,
    "enabled": false,
    "state": 2,
    "status": "OK",
    "threshold": 0,
    "version": 1,
    "votes": 7277,
    "voting": 2,
    "window": 10080
  }
}
```


751
### **set_bans**
erciccione's avatar
erciccione committed
752
753
754

Ban another node by IP.

755
756
Alias: *None*.

erciccione's avatar
erciccione committed
757
758
759
Inputs:

* *bans* - A list of nodes to ban:
760
  * *host* - string; Host to ban (IP in A.B.C.D form - will support I2P address in the future).
erciccione's avatar
erciccione committed
761
762
763
  * *ip* - unsigned int; IP address to ban, in Int format.
  * *ban* - boolean; Set `true` to ban.
  * *seconds* - unsigned int; Number of seconds to ban node.
764

erciccione's avatar
erciccione committed
765
766
767
768
Outputs:

* *status* - string; General RPC error code. "OK" means everything looks good.

769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
Examples:

**banning by host**

In the following example, host is banned with its IP address string-formatted as A.B.C.D:

```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"set_bans","params":{"bans":[{"host":"192.168.1.51","ban":true,"seconds":30}]}}' -H  'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "status": "OK"
  }
}
```

**banning by ip**

In the following example, integer-formatted IP is banned:
erciccione's avatar
erciccione committed
790
791

```
792
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"set_bans","params":{"bans":[{"ip":838969536,"ban":true,"seconds":30}]}}' -H  'Content-Type: application/json'
erciccione's avatar
erciccione committed
793
794
795
796
797
798
799
800
801
802
803

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "status": "OK"
  }
}
```


804
805
806
807
808
### **get_bans**

Get list of banned IPs.

Alias: *None*.
erciccione's avatar
erciccione committed
809
810
811
812
813
814

Inputs: *None*.

Outputs:

* *bans* - List of banned nodes:
815
  * *host* - string; Banned host (IP in A.B.C.D form).
erciccione's avatar
erciccione committed
816
817
818
819
820
821
822
  * *ip* - unsigned int; Banned IP address, in Int format.
  * *seconds* - unsigned int; Local Unix time that IP is banned until.
* *status* - string; General RPC error code. "OK" means everything looks good.

Example:

```
823
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_bans"}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
824
825
826
827
828
829

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "bans": [{
830
831
832
833
834
      "host": "102.168.1.51",
      "ip": 855746662,
      "seconds": 22
    },{
      "host": "192.168.1.50",
erciccione's avatar
erciccione committed
835
      "ip": 838969536,
836
      "seconds": 28
erciccione's avatar
erciccione committed
837
838
839
840
841
842
843
    }],
    "status": "OK"
  }
}
```


844
### **flush_txpool**
erciccione's avatar
erciccione committed
845

846
Flush tx ids from transaction pool
erciccione's avatar
erciccione committed
847

848
Alias: *None*.
erciccione's avatar
erciccione committed
849

850
Inputs:
erciccione's avatar
erciccione committed
851

852
* *txids* - array of strings; Optional, list of transactions IDs to flush from pool (all tx ids flushed if empty).
erciccione's avatar
erciccione committed
853

854
Outputs:
erciccione's avatar
erciccione committed
855

856
* *status* - string; General RPC error code. "OK" means everything looks good.
erciccione's avatar
erciccione committed
857

858
Example:
erciccione's avatar
erciccione committed
859

860
861
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"flush_txpool","params":{"txids":["dc16fa8eaffe1484ca9014ea050e13131d3acf23b419f33bb4cc0b32b6c49308",""]}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
862

863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "status": "OK"
  }
}
```

### **get_output_histogram**

Get a histogram of output amounts. For all amounts (possibly filtered by parameters), gives the number of outputs on the chain for that amount.
RingCT outputs counts as 0 amount.

Inputs:

* *amounts* - list of unsigned int
* *min_count* - unsigned int
* *max_count* - unsigned int
* *unlocked* - boolean
* *recent_cutoff* - unsigned int
erciccione's avatar
erciccione committed
884
885
886

Outputs:

887
888
889
890
891
892
893
894
895
* *histogram* - list of histogram entries, in the following structure:
  * *amount* - unsigned int; Output amount in @atomic-units
  * *total_instances* - unsigned int;
  * *unlocked_instances* - unsigned int;
  * *recent_instances* - unsigned int;
* *status* - string; General RPC error code. "OK" means everything looks good.
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).

Example:
erciccione's avatar
erciccione committed
896
897

```
898
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_output_histogram","params":{"amounts":[20000000000]}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
899
900

{
901
902
903
904
905
906
907
908
909
910
911
912
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "histogram": [{
      "amount": 20000000000,
      "recent_instances": 0,
      "total_instances": 381458,
      "unlocked_instances": 0
    }],
    "status": "OK",
    "untrusted": false
  }
erciccione's avatar
erciccione committed
913
914
915
916
}
```


917
### **get_coinbase_tx_sum**
erciccione's avatar
erciccione committed
918

919
920
921
Get the coinbase ammount and the fees ammount for n last blocks starting at particular height

Alias: *None*.
erciccione's avatar
erciccione committed
922
923
924

Inputs:

925
926
* *height* - unsigned int; Block height from which getting the amounts
* *count* - unsigned int; number of blocks to include in the sum
erciccione's avatar
erciccione committed
927
928
929

Outputs:

930
931
932
933
934
* *emission_amount* - unsigned int; amount of coinbase reward in @atomic-units
* *fee_amount* - unsigned int; amount of fees in @atomic-units
* *status* - string; General RPC error code. "OK" means everything looks good.

Example:
erciccione's avatar
erciccione committed
935
936

```
937
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_coinbase_tx_sum","params":{"height":1563078,"count":2}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
938
939

{
940
941
942
943
944
945
946
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "emission_amount": 9387854817320,
    "fee_amount": 83981380000,
    "status": "OK"
  }
erciccione's avatar
erciccione committed
947
948
949
950
}
```


951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
### **get_version**

Give the node current version

Alias: *None*.

Inputs: *None*.

Outputs:

* *status* - string; General RPC error code. "OK" means everything looks good.
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
* *version* - unsigned int;

Example:
erciccione's avatar
erciccione committed
966
967

```
968
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_version"}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
969
970

{
971
972
973
974
975
976
977
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "status": "OK",
    "untrusted": false,
    "version": 65555
  }
erciccione's avatar
erciccione committed
978
979
980
981
}
```


982
### **get_fee_estimate**
erciccione's avatar
erciccione committed
983

984
985
986
Gives an estimation on fees per kB.

Alias: *None*.
erciccione's avatar
erciccione committed
987
988
989

Inputs:

990
* *grace_blocks* - unsigned int; Optional
erciccione's avatar
erciccione committed
991
992
993

Outputs:

994
* *fee* - unsigned int; Amount of fees estimated per kB in @atomic-units
erciccione's avatar
erciccione committed
995
* *status* - string; General RPC error code. "OK" means everything looks good.
996
* *untrusted* - boolean; States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
erciccione's avatar
erciccione committed
997
998
999
1000

Example:

```
1001
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_fee_estimate"}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
1002
1003

{
1004
1005
1006
1007
1008
1009
1010
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "fee": 187610000,
    "status": "OK",
    "untrusted": false
  }
erciccione's avatar
erciccione committed
1011
1012
1013
1014
}
```


1015
### **get_alternate_chains**
erciccione's avatar
erciccione committed
1016

1017
Display alternative chains seen by the node.
erciccione's avatar
erciccione committed
1018

1019
Alias: *None*.
erciccione's avatar
erciccione committed
1020

1021
Inputs: *None*.
erciccione's avatar
erciccione committed
1022
1023
1024

Outputs:

1025
1026
1027
1028
1029
1030
* *chains* - array of chains, the following structure:
  * *block_hash* - string; the block hash of the first diverging block of this alternative chain.
  * *difficulty* - unsigned int; the cumulative difficulty of all blocks in the alternative chain.
  * *height* - unsigned int; the block height of the first diverging block of this alternative chain.
  * *length* - unsigned int; the length in blocks of this alternative chain, after divergence.
* *status* - string; General RPC error code. "OK" means everything looks good.
erciccione's avatar
erciccione committed
1031

1032
Example:
erciccione's avatar
erciccione committed
1033
1034

```
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_alternate_chains"}' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "chains": [{
      "block_hash": "697cf03c89a9b118f7bdf11b1b3a6a028d7b3617d2d0ed91322c5709acf75625",
      "difficulty": 14114729638300280,
      "height": 1562062,
      "length": 2
    }],
    "status": "OK"
  }
}
erciccione's avatar
erciccione committed
1050
1051
1052
```


1053
### **relay_tx**
erciccione's avatar
erciccione committed
1054

1055
Relay a list of transaction IDs.
erciccione's avatar
erciccione committed
1056

1057
1058
1059
1060
1061
Alias: *None*.

Inputs:

* *txids* - array of string; list of transaction IDs to relay
erciccione's avatar
erciccione committed
1062
1063
1064
1065
1066

Outputs:

* *status* - string; General RPC error code. "OK" means everything looks good.

1067
Example:
erciccione's avatar
erciccione committed
1068
1069

```
1070
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"relay_tx","params":{"txids":[9fd75c429cbe52da9a52f2ffc5fbd107fe7fd2099c0d8de274dc8a67e0c98613]}}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
1071
1072

{
1073
1074
1075
1076
1077
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "status": "OK"
  }
erciccione's avatar
erciccione committed
1078
1079
1080
1081
}
```


1082
### **sync_info**
erciccione's avatar
erciccione committed
1083

1084
1085
1086
Get synchronisation informations

Alias: *None*.
erciccione's avatar
erciccione committed
1087
1088
1089
1090
1091

Inputs: *None*.

Outputs:

1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
* *height* - unsigned int;
* *peers* - array of peer structure, defined as follows:
  * *info* - structure of connection info, as defined in [get_connections](#get_connections)
* *spans* - array of span structure, defined as follows (optional, absent if node is fully synced):
  * *connection_id* - string; Id of connection
  * *nblocks* - unsigned int; number of blocks in that span
  * *rate* - unsigned int; connection rate
  * *remote_address* - string; peer address the node is downloading (or has downloaded) than span from
  * *size* - unsigned int; total number of bytes in that span's blocks (including txes)
  * *speed* - unsigned int; connection speed
  * *start_block_height* - unsigned int; block height of the first block in that span
erciccione's avatar
erciccione committed
1103
* *status* - string; General RPC error code. "OK" means everything looks good.
1104
* *target_height* - unsigned int; target height the node is syncing from (optional, absent if node is fully synced)
erciccione's avatar
erciccione committed
1105
1106
1107
1108

Example:

```
1109
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"sync_info"}' -H 'Content-Type: application/json'
erciccione's avatar
erciccione committed
1110
1111

{
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "height": 1563543,
    "peers": [{
      "info": {
        "address": "70.109.53.128:60064",
        "avg_download": 0,
        "avg_upload": 5,
        "connection_id": "204067223b9b3415c265dd25ad29ee48",
        "current_download": 0,
        "current_upload": 1,
        "height": 1559975,
        "host": "70.109.53.128",
        "incoming": true,
        "ip": "70.109.53.128",
        "live_time": 38,
        "local_ip": false,
        "localhost": false,
        "peer_id": "96b8545dbc7a8866",
        "port": "60064",
        "recv_count": 1580,
        "recv_idle_time": 28,
        "send_count": 203603,
        "send_idle_time": 8,
        "state": "state_normal",
        "support_flags": 1
      }
    },{
      "info": {
        ...
      }
    },{
      ...
    },{
      ...
    },{
      ...
    }],
    "status": "OK",
    "target_height": 1564067
  }
erciccione's avatar
erciccione committed
1154
}
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752