wallet-rpc.md 15.2 KB
Newer Older
moneromooo-monero's avatar
moneromooo-monero committed
1
2
3
---
layout: static_page
title: "Wallet RPC documentation"
Mike C's avatar
Mike C committed
4
title-pre-kick: "Developer Guide: "
moneromooo-monero's avatar
moneromooo-monero committed
5
6
7
8
9
10
11
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 -->"
---

12
13
## Introduction

14
This is a list of the monero-wallet-cli RPC calls, their inputs and outputs, and examples of each.
15

16
All monero-wallet-cli methods use the same JSON RPC interface. For example:
17
18
19
20
21
22
23
24
25
26

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

Mike C's avatar
Mike C committed
27
Note: "atomic units" refer to the smallest fraction of 1 XMR according to the bitmonerod implementation. **1 XMR = 1e12 atomic units.**
Mike C's avatar
Mike C committed
28
29

### Index of JSON RPC Methods:
30
31
32
33
34

* [getbalance](#getbalance)
* [getaddress](#getaddress)
* [getheight](#getheight)
* [transfer](#transfer)
Mike C's avatar
Mike C committed
35
36
* [transfer_split](#transfersplit)
* [sweep_dust](#sweepdust)
37
* [store](#store)
Mike C's avatar
Mike C committed
38
39
40
41
42
43
44
* [get_payments](#getpayments)
* [get_bulk_payments](#getbulkpayments)
* [incoming_transfers](#incomingtransfers)
* [query_key](#querykey)
* [make_integrated_address](#makeintegratedaddress)
* [split_integrated_address](#splitintegratedaddress)
* [stop_wallet](#stopwallet)
45
46
47

---

Mike C's avatar
Mike C committed
48
49
## JSON RPC Methods:

50
51
52
53
54
55
56
57
### getbalance

Return the wallet's balance.

Inputs: *None*.

Outputs:

58
* *balance* - unsigned int; The total balance of the current monero-wallet-cli in session.
Mike C's avatar
Mike C committed
59
* *unlocked_balance* - unsigned int; Unlocked funds are those funds that are sufficiently deep enough in the Monero blockchain to be considered safe to spend.
60
61
62

Example:

Mike C's avatar
Mike C committed
63
64
65
66
67
68
69
70
71
72
73
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getbalance"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "balance": 140000000000,
    "unlocked_balance": 50000000000
  }
}

74
75
76
77
78
79
80
81
82

### getaddress

Return the wallet's address.

Inputs: *None*.

Outputs:

83
* *address* - string; The 95-character hex address string of the monero-wallet-cli in session.
84
85
86

Example:

Mike C's avatar
Mike C committed
87
88
89
90
91
92
93
94
95
96
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getaddress"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "address": "427ZuEhNJQRXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQGaDsaBA"
  }
}

97
98
99
100
101
102
103
104
105

### getheight

Returns the wallet's current block height.

Inputs: *None*.

Outputs:

106
* *height* - string; The current monero-wallet-cli's blockchain height. If the wallet has been offline for a long time, it may need to catch up with the daemon.
107
108
109

Example:

Mike C's avatar
Mike C committed
110
111
112
113
114
115
116
117
118
119
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getheight"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "height": 994310
  }
}

120
121
122
123
124
125
126

### transfer

Send monero to a number of recipients.

Inputs:

Mike C's avatar
Mike C committed
127
128
129
* *destinations* - array of destinations to receive XMR:
  * *amount* - unsigned int; Amount to send to each destination, in atomic units.
  * *address* - string; Destination public address.
130
131
132
* *fee* - unsigned int; Ignored, will be automatically calculated.
* *mixin* - unsigned int; Number of outpouts from the blockchain to mix with (0 means no mixing).
* *unlock_time* - unsigned int; Number of blocks before the monero can be spent (0 to not add a lock).
Mike C's avatar
Mike C committed
133
134
* *payment_id* - string; (Optional) Random 32-byte/64-character hex string to identify a transaction.
* *get_tx_key* - boolean; (Optional) Return the transaction key after sending.
135
136
137
Outputs:

* *tx_hash* - array of: string
Mike C's avatar
Mike C committed
138
* *tx_key* - 
139
140
141

Example:

Mike C's avatar
Mike C committed
142
143
144
145
146
147
148
149
150
151
152
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{"destinations":[{"amount":10000000000000,"address":"427ZuEhNJQRXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQGaDsaBA"},{"amount":200000000000,"address":"49VtwYXDbbh7hq57wwkLH36x4D6XV6Tr2P93ANnBi9qFGyYZbx8SXWPUHC9V1o7N41b4c3WJ1kubkffRfPTPfMuB8QUqFD5"}],"fee":150000000000,"mixin":3,"unlock_time":0,"payment_id":"001f181e2a2e076e8451e9dd7b5fe8fbd2b204cd6a20cb3e21b9a2a42b0ce03c","get_tx_key":true}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "tx_hash": "&lt;29d933789db5483fa63694ed2560d3829dbf0b945fdea3c42fbfa4d381e7ac22&gt;",
    "tx_key": "&lt;c228dff7aa455d770f8cf71b9d319d2055a125cfbac1ca9485aeb1a107604d0d&gt;"
  }
}

153
154
155
156
157
158
159

### transfer_split

Same as transfer, but can split into more than one tx if necessary.

Inputs:

Mike C's avatar
Mike C committed
160
161
162
* *destinations* - array of destinations to receive XMR:
  * *amount* - unsigned int; Amount to send to each destination, in atomic units.
  * *address* - string; Destination public address.
163
164
165
* *fee* - unsigned int; Ignored, will be automatically calculated.
* *mixin* - unsigned int; Number of outpouts from the blockchain to mix with (0 means no mixing).
* *unlock_time* - unsigned int; Number of blocks before the monero can be spent (0 to not add a lock).
Mike C's avatar
Mike C committed
166
167
* *payment_id* - string; (Optional) Random 32-byte/64-character hex string to identify a transaction.
* *get_tx_key* - boolean; (Optional) Return the transaction key after sending.
168
169
170
171
* *new_algorithm* - boolean; True to use the new transaction construction algorithm, defaults to false.

Outputs:

Mike C's avatar
Mike C committed
172
* *tx_hash_list* - array of: string
173
174
175

Example:

Mike C's avatar
Mike C committed
176
177
178
179
180
181
182
183
184
185
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"destinations":[{"amount":2000000000000,"address":"427ZuEhNJQRXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQGaDsaBA"},{"amount":3000000000000,"address":"49VtwYXDbbh7hq57wwkLH36x4D6XV6Tr2P93ANnBi9qFGyYZbx8SXWPUHC9V1o7N41b4c3WJ1kubkffRfPTPfMuB8QUqFD5"}],"mixin":3,"unlock_time":0,"payment_id":"a29602cc261fecbc93c22a152a942cc791ca6112cffe201c3e809945c9da672f","get_tx_key":true,"new_algorithm":true}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "tx_hash_list": ["&lt;fb39c42cb5ff231ee9e8b381bb8734fd655b6ca28a23cbd82aa9422aa870e91b&gt;"]
  }
}

186
187
188
189
190
191
192
193
194
195
196

### sweep_dust

Send all dust outputs back to the wallet's, to make them easier to spend (and mix).

Inputs: *None*.

Outputs:

* *tx_hash_list* - list of: string

Mike C's avatar
Mike C committed
197
Example (In this example, `sweep_dust` returns an error due to insufficient funds to sweep):
198

Mike C's avatar
Mike C committed
199
200
201
202
203
204
205
206
207
208
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"sweep_dust"}' -H 'Content-Type: application/json'
{
  "error": {
    "code": -4,
    "message": "not enough money"
  },
  "id": "0",
  "jsonrpc": "2.0"
}
209
210
211
212
213
214
215

### store

Save the blockchain.

Inputs: *None*.

Mike C's avatar
Mike C committed
216
Outputs: *None*.
217
218
219

Example:

Mike C's avatar
Mike C committed
220
221
222
223
224
225
226
227
228
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"store"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
  }
}

229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248

### get_payments

Get a list of incoming payments using a given payment id.

Inputs:

* *payment_id* - string

Outputs:

* *payments* - list of:
  * *payment_id* - string
  * *tx_hash* - string
  * *amount* - unsigned int
  * *block_height* - unsigned int
  * *unlock_time* - unsigned int

Example:

Mike C's avatar
Mike C committed
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_payments","params":{"payment_id":"4279257e0a20608e25dba8744949c9e1caff4fcdafc7d5362ecf14225f3d9030"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "payments": [{
      "amount": 10350000000000,
      "block_height": 994327,
      "payment_id": "4279257e0a20608e25dba8744949c9e1caff4fcdafc7d5362ecf14225f3d9030",
      "tx_hash": "c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1",
      "unlock_time": 0
    }]
  }
}

265
266
267

### get_bulk_payments

Mike C's avatar
Mike C committed
268
Get a list of incoming payments using a given payment id, or a list of payments ids, from a given height. This method is the preferred method over `get_payments` because it has the same functionality but is more extendable. Either is fine for looking up transactions by a single payment ID.
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285

Inputs:

* *payment_ids* - array of: string
 * *min_block_height* - unsigned int; The block height at which to start looking for payments.

Outputs:

* *payments* - list of:
  * *payment_id* - string
  * *tx_hash* - string
  * *amount* - unsigned int
  * *block_height* - unsigned int
  * *unlock_time* - unsigned int

Example:

Mike C's avatar
Mike C committed
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_bulk_payments","params":{"payment_ids":["4279257e0a20608e25dba8744949c9e1caff4fcdafc7d5362ecf14225f3d9030"],"min_block_height":990000}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "payments": [{
      "amount": 10350000000000,
      "block_height": 994327,
      "payment_id": "4279257e0a20608e25dba8744949c9e1caff4fcdafc7d5362ecf14225f3d9030",
      "tx_hash": "c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1",
      "unlock_time": 0
    }]
  }
}

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319

### incoming_transfers

Return a list of incoming transfers to the wallet.

Inputs:

* *transfer_type* - string; "all": all the transfers, "available": only transfers which are not yet spent, OR "unavailable": only transfers which are already spent.
				
Outputs:

* *transfers* - list of:
  * *amount* - unsigned int
  * *spent* - boolean
  * *global_index* - unsigned int; Mostly internal use, can be ignored by most users.
  * *tx_hash* - string; Several incoming transfers may share the same hash if they were in the same transaction.
  * *tx_size* - unsigned int

Mike C's avatar
Mike C committed
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
Example (Return "all" transaction types):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"incoming_transfers","params":{"transfer_type":"all"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "transfers": [{
      "amount": 10000000000000,
      "global_index": 711506,
      "spent": false,
      "tx_hash": "&lt;c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1&gt;",
      "tx_size": 5870
    },{
      "amount": 300000000000,
      "global_index": 794232,
      "spent": false,
      "tx_hash": "&lt;c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1&gt;",
      "tx_size": 5870
    },{
      "amount": 50000000000,
      "global_index": 213659,
      "spent": false,
      "tx_hash": "&lt;c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1&gt;",
      "tx_size": 5870
    }]
  }
}

Example (Return "available" transactions):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"incoming_transfers","params":{"transfer_type":"available"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "transfers": [{
      "amount": 10000000000000,
      "global_index": 711506,
      "spent": false,
      "tx_hash": "&lt;c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1&gt;",
      "tx_size": 5870
    },{
      "amount": 300000000000,
      "global_index": 794232,
      "spent": false,
      "tx_hash": "&lt;c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1&gt;",
      "tx_size": 5870
    },{
      "amount": 50000000000,
      "global_index": 213659,
      "spent": false,
      "tx_hash": "&lt;c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1&gt;",
      "tx_size": 5870
    }]
  }
}

Example (Return "unavailable" transaction. Note that this particular example returns 0 unavailable transactions):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"incoming_transfers","params":{"transfer_type":"unavailable"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
  }
}
390
391
392
393
394
395
396
397


### query_key

Return the spend or view private key.

Inputs:

Mike C's avatar
Mike C committed
398
* *key_type* - string; Which key to retrieve: "mnemonic" - the mnemonic seed (older wallets do not have one) OR "view_key" - the view key
399
400
401

Outputs:

Mike C's avatar
Mike C committed
402
* *key* - string; The view key will be hex encoded, while the mnemonic will be a string of words.
403

Mike C's avatar
Mike C committed
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
Example (Query view key):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"query_key","params":{"key_type":"view_key"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "key": "7e341d..."
  }
}

Example (Query mnemonic key):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"query_key","params":{"key_type":"mnemonic"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "key": "adapt adapt nostril ..."
  }
}
427
428
429
430
431
432
433
434
435
436
437
438
439
440


### make_integrated_address

Make an integrated address from the wallet address and a payment id.

Inputs:

* *payment_id* - string; hex encoded; can be empty, in which case a random payment id is generated

Outputs:

* *integrated_address* - string

Mike C's avatar
Mike C committed
441
442
443
444
445
446
447
448
449
450
451
Example (Payment ID is empty, use a random ID):

{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"make_integrated_address","params":{"payment_id":""}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "integrated_address": "4BpEv3WrufwXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQQ8H2RRJveAtUeiFs6J"
  }
}
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468


### split_integrated_address

Retrieve the standard address and payment id corresponding to an integrated address.

Inputs:

* *integrated_address* - string

Outputs:

* *standard_address* - string
* *payment* - string; hex encoded

Example:

Mike C's avatar
Mike C committed
469
470
471
472
473
474
475
476
477
478
479
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"split_integrated_address","params":{"integrated_address": "4BpEv3WrufwXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQQ8H2RRJveAtUeiFs6J"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "payment_id": "&lt;420fa29b2d9a49f5&gt;",
    "standard_address": "427ZuEhNJQRXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQGaDsaBA"
  }
}

480
481
482
483
484
485
486

### stop_wallet

Stops the wallet, storing the current state.

Inputs: *None*.

Mike C's avatar
Mike C committed
487
Outputs: *None*.
488
489
490

Example:

Mike C's avatar
Mike C committed
491
492
493
494
495
496
497
498
{:.cli-code}
<span style="color: cyan;">[ monero->~ ]$</span> curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"stop_wallet"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
  }
}
499