From 0173949446c790c85fa1c1bbebbb024387bfb924 Mon Sep 17 00:00:00 2001 From: Mike C Date: Wed, 9 Mar 2016 22:16:03 -0700 Subject: [PATCH 01/14] initial daemon-rpc.md commit. --- knowledge-base/developer-guides/daemon-rpc.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 knowledge-base/developer-guides/daemon-rpc.md diff --git a/knowledge-base/developer-guides/daemon-rpc.md b/knowledge-base/developer-guides/daemon-rpc.md new file mode 100644 index 0000000..00f7ca3 --- /dev/null +++ b/knowledge-base/developer-guides/daemon-rpc.md @@ -0,0 +1,68 @@ +--- +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: "" +--- + +## 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 + +### getlastblockheader + +### getblockheaderbyhash + +### getblockheaderbyheight + +### 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. + +### + From 4b7967bf63022036cf7dfc8f353c3c5dfa817f68 Mon Sep 17 00:00:00 2001 From: Mike C Date: Wed, 9 Mar 2016 23:19:30 -0700 Subject: [PATCH 02/14] block header methods w/ examples. --- knowledge-base/developer-guides/daemon-rpc.md | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/knowledge-base/developer-guides/daemon-rpc.md b/knowledge-base/developer-guides/daemon-rpc.md index 00f7ca3..a2099ad 100644 --- a/knowledge-base/developer-guides/daemon-rpc.md +++ b/knowledge-base/developer-guides/daemon-rpc.md @@ -39,12 +39,149 @@ Some methods include parameters, while others do not. Examples of each JSON RPC ### submitblock + ### getlastblockheader +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} +[ monero->~ ]$ 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" + } +} + + ### getblockheaderbyhash +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} +[ monero->~ ]$ 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" + } +} + + ### getblockheaderbyheight +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} +[ monero->~ ]$ 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" + } +} + ### getblock ### get_connections From db6e73c56ec2d365052902b7e0df5a46b4b07ba2 Mon Sep 17 00:00:00 2001 From: Mike C Date: Fri, 11 Mar 2016 10:18:19 -0700 Subject: [PATCH 03/14] Link to daemon-rpc page on dev guide index --- knowledge-base/developer-guides/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/knowledge-base/developer-guides/index.md b/knowledge-base/developer-guides/index.md index 46fb7d2..ff00601 100644 --- a/knowledge-base/developer-guides/index.md +++ b/knowledge-base/developer-guides/index.md @@ -11,4 +11,5 @@ attribution: "" --- -## General Remarks +# 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. -## Index -JSON RPC Methods: +--- + +# Index + +## JSON RPC Methods: * [getblockcount](#getblockcount) * [on_getblockhash](#on_getblockhash) @@ -33,17 +36,19 @@ JSON RPC Methods: * [setbans](#setbans) * [getbans](#getbans) -Other RPC Methods: +## Other RPC Methods: -* [getheight](#getheight) -* [gettransactions](#gettransactions) -* [is_key_image_spent](#is_key_image_spent) -* [sendrawtransaction](#sendrawtransaction) -* [get_transaction_pool](#get_transaction_pool) -* [stop_daemon](#stop_daemon) +* [/getheight](#getheight) +* [/gettransactions](#gettransactions) +* [/is_key_image_spent](#is_key_image_spent) +* [/sendrawtransaction](#sendrawtransaction) +* [/get_transaction_pool](#get_transaction_pool) +* [/stop_daemon](#stop_daemon) -## JSON RPC Methods +--- + +# 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: @@ -66,8 +71,8 @@ Inputs: *None*. Outputs: -* *count* - Number of blocks in longest chain seen by the node. -* *status* - General RPC error code. "OK" means everything looks good. +* *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: @@ -110,17 +115,17 @@ Example: Inputs: -* *wallet_address* - Address of wallet to receive coinbase transactions if block is successfully mined. -* *reserve_size* - Reserve size. +* *wallet_address* - string; Address of wallet to receive coinbase transactions if block is successfully mined. +* *reserve_size* - unsigned int; Reserve size. Outputs: -* *blocktemplate_blob* - Blob on which to try to mine a new block. -* *difficulty* - Difficulty of next block. -* *height* - Height on which to mine. -* *prev_hash* - Hash of the most recent block on which to mine the next block. -* *reserved_offset* - Reserved offset. -* *status* - General RPC error code. "OK" means everything looks good. +* *blocktemplate_blob* - string; Blob on which to try to mine a new block. +* *difficulty* - unsigned int; Difficulty of next block. +* *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. Example: @@ -145,11 +150,11 @@ Submit a mined block to the network. Inputs: -* Block blob data +* Block blob data - string Outputs: -* *status* - Block submit status. +* *status* - string; Block submit status. ### getlastblockheader @@ -161,18 +166,18 @@ Inputs: *None*. 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. -* *status* - General RPC error code. "OK" means everything looks good. + * *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. + * *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. + * *reward* - unsigned int; The amount of new atomic units generated in this block and rewarded to the miner. Note: 1 XMR = 1e12 atomic units. + * *timestamp* - unsigned int; The time the block was recorded into the blockchain. +* *status* - string; General RPC error code. "OK" means everything looks good. In this example, the most recent block (990793 at the time) is returned: @@ -206,7 +211,7 @@ Block header information can be retrieved using either a block's hash or height. Inputs: -* *hash* - The block's sha256 hash. +* *hash* - string; The block's sha256 hash. Outputs: @@ -244,7 +249,7 @@ Similar to `getblockheaderbyhash` above, this method includes a block's height a Inputs: -* *height* - The block's height. +* *height* - unsigned int; The block's height. Outputs: @@ -282,14 +287,14 @@ Full block information can be retrieved by either block height or hash, like wit Inputs (pick one of the following): -* *height* - The block's height. -* *hash* - The block's hash. +* *height* - unsigned int; The block's height. +* *hash* - string; The block's hash. Outputs: -* *blob* - +* *blob* - string; Hexadecimal blob of block information. * *block_header* - A structure containing block header information. See [getlastblockheader](#getlastblockheader). -* *json* - JSON formatted block details: +* *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. @@ -308,7 +313,7 @@ Outputs: * *extra* - Usually called the "transaction ID" but can be used to include any random 32 bytes. * *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* - General RPC error code. "OK" means everything looks good. +* *status* - string; General RPC error code. "OK" means everything looks good. **Look up by height:** @@ -379,22 +384,22 @@ Inputs: *None*. Outputs: * *connections* - List of all connections and their info: - * *avg_download* - Average bytes of data downloaded by node. - * *avg_upload* - Average bytes of data uploaded by node. - * *current_download* - Current bytes downloaded by node. - * *current_upload* - Current bytes uploaded by node. - * *incoming* - Boolean, is the node getting information from your node? - * *ip* - The node's IP address - * *live_time* - - * *local_ip* - Boolean - * *localhost* - Boolean - * *peer_id* - The node's ID on the network. - * *port* - The port that the node is using to connect to the network. - * *recv_count* - - * *recv_idle_time* - - * *send_count* - - * *send_idle_time* - - * *state* - + * *avg_download* - unsigned int; Average bytes of data downloaded by node. + * *avg_upload* - unsigned int; Average bytes of data uploaded by node. + * *current_download* - unsigned int; Current bytes downloaded by node. + * *current_upload* - unsigned int; Current bytes uploaded by node. + * *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. + * *port* - stringl The port that the node is using to connect to the network. + * *recv_count* - unsigned int + * *recv_idle_time* - unsigned int + * *send_count* - unsigned int + * *send_idle_time* - unsigned int + * *state* - string Following is an example of `get_connections` and it's return: @@ -437,20 +442,20 @@ Inputs: *None*. Outputs: -* *alt_blocks_count* - Number of alternative blocks to main chain. -* *difficulty* - Network difficulty (analogous to the strength of the network) -* *grey_peerlist_size* - -* *height* - Current length of longest chain known to daemon. -* *incoming_connections_count* - Number of peers connected to and pulling from your node. -* *outgoing_connections_count* - Number of peers that you are connected to and getting information from. -* *status* - General RPC error code. "OK" means everything looks good. -* *target* - Current target for next proof of work. -* *target_height* - The height of the next block in the chain. -* *testnet* - A Boolean operator stating if the node is on the testnet (true) or mainnet (false). -* *top_block_hash* - Hash of the highest block in the chain. -* *tx_count* - Total number of non-coinbase transaction in the chain. -* *tx_pool_siz* - Number of transactions that have been broadcast but not included in a block. -* *white_peerlist_size* - +* *alt_blocks_count* - unsigned int; Number of alternative blocks to main chain. +* *difficulty* - unsigned int; Network difficulty (analogous to the strength of the network) +* *grey_peerlist_size* - unsigned int; Grey Peerlist Size +* *height* - unsigned int; Current length of longest chain known to daemon. +* *incoming_connections_count* - unsigned int; Number of peers connected to and pulling from your node. +* *outgoing_connections_count* - unsigned int; Number of peers that you are connected to and getting information from. +* *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. +* *testnet* - boolean; States if the node is on the testnet (true) or mainnet (false). +* *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. +* *tx_pool_siz* - unsigned int; Number of transactions that have been broadcast but not included in a block. +* *white_peerlist_size* - unsigned int; White Peerlist Size Following is an example `get_info` call and its return: @@ -486,15 +491,15 @@ Inputs: *None*. Outputs: -* *earliest_height* - Block height at which hard fork would be enabled if voted in. -* *enabled* - Tells if hard fork is enforced. -* *state* - 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* - General RPC error code. "OK" means everything looks good. -* *threshold* - Minimum percent of votes to trigger hard fork. Default is 80. -* *version* - The major block version for the fork. -* *votes* - Number of votes towards hard fork. -* *voting* - Hard fork voting status. -* *window* - Number of blocks over which current votes are cast. Default is 10080 blocks. +* *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: @@ -524,13 +529,13 @@ Ban another node by IP. Inputs: * *bans* - A list of nodes to ban: - * *ip* - IP address to ban, in Int format. - * *ban* - Set `true` to ban. - * *seconds* - Number of seconds to ban node. + * *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. Outputs: -* *status* - General RPC error code. "OK" means everything looks good. +* *status* - string; General RPC error code. "OK" means everything looks good. Example: @@ -552,9 +557,9 @@ Inputs: *None*. Outputs: * *bans* - List of banned nodes: - * *ip* - Banned IP address, in Int format. - * *seconds* - Local Unix time that IP is banned until. -* *status* - General RPC error code. "OK" means everything looks good. + * *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: @@ -573,7 +578,9 @@ Example: } -## Other Daemon RPC Calls +--- + +# Other Daemon RPC Calls Not all daemon RPC calls use the JSON_RPC interface. This section gives examples of these calls. @@ -591,7 +598,7 @@ The data structure for these calls is different than the JSON RPC calls. Whereas Note: It is recommended to use JSON RPC where such alternatives exist, rather than the following methods. For example, the recommended way to get a node's height is via the JSON RPC methods [get_info](#get_info) or [getlastblockheader](#getlastblockheader), rather than [getheight](#getheight) below. -### getheight +### /getheight Get the node's current height. @@ -599,7 +606,7 @@ Inputs: *None*. Outputs: -* *height* - Current length of longest chain known to daemon. +* *height* - unsigned int; Current length of longest chain known to daemon. {:.cli-code} [ monero->~ ]$ curl -X POST http://127.0.0.1:18081/getheight -H 'Content-Type: application/json' @@ -609,20 +616,20 @@ Outputs: } -### gettransactions +### /gettransactions Look up one or more transactions by hash. Inputs: -* *txs_hashes* - List of transaction hashes to look up. -* *decode_as_json* - Optional. If set `true`, the returned transaction information will be decoded rather than binary. +* *txs_hashes* - string list; List of transaction hashes to look up. +* *decode_as_json* - boolean; Optional. If set `true`, the returned transaction information will be decoded rather than binary. Outputs: * *status* - General RPC error code. "OK" means everything looks good. -* *txs_as_hex* - Full transaction information as a hex string. -* *txs_as_json* - (Optional - returned if set in inputs.) List of transaction info: +* *txs_as_hex* - string; Full transaction information as a hex string. +* *txs_as_json* - json string; (Optional - returned if set in inputs.) List of transaction info: * *version* - Transaction version * *unlock_time* - If not 0, this tells when a transaction output is spendable. * *vin* - List of inputs into transaction: @@ -656,18 +663,18 @@ Example 2: Decode returned transaction information in JSON format. Note: the "vo } -### is_key_image_spent +### /is_key_image_spent Check if outputs have been spent using the key image associated with the output. Inputs: -* *key_images* - List of key image hex strings to check. +* *key_images* - string list; List of key image hex strings to check. Outputs: -* *spent_status* - List of statuses for each image checked. Statuses are follows: 0 = unspent, 1 = spent in blockchain, 2 = spent in transaction pool -* *status* - General RPC error code. "OK" means everything looks good. +* *spent_status* - unsigned int list; List of statuses for each image checked. Statuses are follows: 0 = unspent, 1 = spent in blockchain, 2 = spent in transaction pool +* *status* - string; General RPC error code. "OK" means everything looks good. Example: @@ -678,17 +685,18 @@ Example: "status": "OK" } -### sendrawtransaction + +### /sendrawtransaction Broadcast a raw transaction to the network. Inputs: -* *tx_as_hex* - Full transaction information as hexidecimal string. +* *tx_as_hex* - string; Full transaction information as hexidecimal string. Outputs: -* *status* - General RPC error code. "OK" means everything looks good. +* *status* - string; General RPC error code. "OK" means everything looks good. Example (No return information included here.): @@ -696,7 +704,7 @@ Example (No return information included here.): [ monero->~ ]$ curl -X POST http://127.0.0.1:18081/sendrawtransaction -d '{"tx_as_hex":"de6a3..."}' -H 'Content-Type: application/json' -### get_transaction_pool +### /get_transaction_pool Show information about valid transactions seen by the node but not yet mined into a block, as well as spent key image information in the node's memory. @@ -705,20 +713,20 @@ Inputs: *None*. Outputs: * *spent_key_images* - List of spent output key images: - * *id_hash* - Key image ID hash. - * *txs_hashes* - Key image transaction hashes. -* *status* - General RPC error code. "OK" means everything looks good. + * *id_hash* - string; Key image ID hash. + * *txs_hashes* - string list; Key image transaction hashes. +* *status* - string; General RPC error code. "OK" means everything looks good. * *transactions* - List of transactions in the mempool that have not been included in a block: - * *blob_size* - The size of the full transaction blob. - * *fee* - The amount of the mining fee included in the transaction, in atomic units. - * *id_hash* - The transaction ID hash. - * *kept_by_block* - Boolean, we do not accept transactions that timed out before, unless set `true`. - * *last_failed_height* - If the transaction has previously timed out, this tells at what height that occured. - * *last_failed_id_hash* - Like the previous, this tells the previous transaction ID hash. - * *max_used_block_height* - Tells the height of the most recent block with an output used in this transaction. - * *max_used_block_hash* - Tells the hash of the most recent block with an output used in this transaction. - * *receive_time* - The Unix time that the transaction was first seen on the network by the node. - * *tx_json* - JSON structure of all information in the transaction: + * *blob_size* - unsigned int; The size of the full transaction blob. + * *fee* - unsigned int; The amount of the mining fee included in the transaction, in atomic units. + * *id_hash* - string; The transaction ID hash. + * *kept_by_block* - boolean; We do not accept transactions that timed out before, unless set `true`. + * *last_failed_height* - unsigned int; If the transaction has previously timed out, this tells at what height that occured. + * *last_failed_id_hash* - string; Like the previous, this tells the previous transaction ID hash. + * *max_used_block_height* - unsigned int; Tells the height of the most recent block with an output used in this transaction. + * *max_used_block_hash* - string; Tells the hash of the most recent block with an output used in this transaction. + * *receive_time* - unsigned int; The Unix time that the transaction was first seen on the network by the node. + * *tx_json* - json string; JSON structure of all information in the transaction: * *version* - Transaction version * *unlock_time* - If not 0, this tells when a transaction output is spendable. * *vin* - List of inputs into transaction: @@ -763,7 +771,7 @@ Example (Note: Some lists in the returned information have been truncated for di } -### stop_daemon +### /stop_daemon Send a command to the daemon to safely disconnect and shut down. @@ -771,7 +779,7 @@ Inputs: *None*. Outputs: -* *status* - General RPC error code. "OK" means everything looks good. +* *status* - string; General RPC error code. "OK" means everything looks good. Example: From 88e0abfd10b28eb16d60b78caff8c981ac1f980f Mon Sep 17 00:00:00 2001 From: Mike C Date: Fri, 11 Mar 2016 21:33:52 -0700 Subject: [PATCH 07/14] developer guide updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove “How to “ texts from index page and update wallet-roc header. --- knowledge-base/developer-guides/index.md | 4 ++-- knowledge-base/developer-guides/wallet-rpc.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/knowledge-base/developer-guides/index.md b/knowledge-base/developer-guides/index.md index ff00601..58e2e04 100644 --- a/knowledge-base/developer-guides/index.md +++ b/knowledge-base/developer-guides/index.md @@ -11,5 +11,5 @@ attribution: "" --- -# General Remarks +## Introduction -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. +This is a list of the bitmonerod daemon RPC calls, their inputs and outputs, and examples of each. -On this page, you will find examples of these RPC calls. +Many RPC calls use the daemon's JSON RPC interface while others use their own interfaces, as demonstrated below. - ---- - -# Index - -## JSON RPC Methods: +### [JSON RPC Methods](#json-rpc-methods): * [getblockcount](#getblockcount) * [on_getblockhash](#on_getblockhash) @@ -36,7 +31,7 @@ On this page, you will find examples of these RPC calls. * [setbans](#setbans) * [getbans](#getbans) -## Other RPC Methods: +### [Other RPC Methods](#other-daemon-rpc-calls): * [/getheight](#getheight) * [/gettransactions](#gettransactions) @@ -48,7 +43,7 @@ On this page, you will find examples of these RPC calls. --- -# JSON RPC Methods +## 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: @@ -580,7 +575,7 @@ Example: --- -# Other Daemon RPC Calls +## Other Daemon RPC Calls Not all daemon RPC calls use the JSON_RPC interface. This section gives examples of these calls. From dd5897bba168be4dd5f8ba3462f459d0c4afb743 Mon Sep 17 00:00:00 2001 From: Mike C Date: Fri, 11 Mar 2016 22:17:09 -0700 Subject: [PATCH 09/14] Re-style wallet-rpc dev guide; prep for examples --- knowledge-base/developer-guides/wallet-rpc.md | 374 +++++++++++------- 1 file changed, 240 insertions(+), 134 deletions(-) diff --git a/knowledge-base/developer-guides/wallet-rpc.md b/knowledge-base/developer-guides/wallet-rpc.md index d2e7739..4ae61a6 100644 --- a/knowledge-base/developer-guides/wallet-rpc.md +++ b/knowledge-base/developer-guides/wallet-rpc.md @@ -9,156 +9,262 @@ icon: "icon_client" attribution: "" --- -### This is a list of the daemon and wallet RPC calls, along with their inputs and outputs. +## Introduction -bitmonerod +This is a list of the simplewallet RPC calls, their inputs and outputs, and examples of each. - TODO +All simplewallet methods use the same JSON RPC interface. For example: -simplewallet + 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' - Wallet RPC commands are in JSON format, and can be accessed like this: +### JSON RPC Methods: - 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' +* [getbalance](#getbalance) +* [getaddress](#getaddress) +* [getheight](#getheight) +* [transfer](#transfer) +* [transfer_split](#transfer_split) +* [sweep_dust](#sweep_dust) +* [store](#store) +* [get_payments](#get_payments) +* [get_bulk_payments](#get_bulk_payments) +* [incoming_transfers](#incoming_transfers) +* [query_key](#query_key) +* [make_integrated_address](#make_integrated_address) +* [split_integrated_address](#split_integrated_address) +* [stop_wallet](#stop_wallet) - getbalance - return the wallet's balance - outputs: - balance: unsigned int - unlocked_balance: unsigned int +--- - getaddress - return the wallet's address - outputs: - address: string - - getheight - returns the current block height - outputs: - height: string +### getbalance - transfer - send monero to a number of recipients - inputs: - destinations: array of: - amount: unsigned int - address: string - 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) - payment_id: string - outputs: - tx_hash: array of: - string +Return the wallet's balance. - transfer_split - same as transfer, but can split into more than one tx if necessary - inputs: - destinations: array of: - amount: unsigned int - address: string - 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) - payment_id: string - new_algorithm: boolean - true to use the new transaction construction algorithm, defaults to false - outputs: - tx_hash: array of: - string +Inputs: *None*. - sweep_dust - send all dust outputs back to the wallet's, to make them easier to spend (and mix) - outputs: - tx_hash_list: list of: - string +Outputs: - store - save the blockchain +* *balance* - unsigned int +* *unlocked_balance* - unsigned int - 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: - get_bulk_payments - get a list of incoming payments using a given payment id, or a list of payments ids, from a given height - 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 - 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 - "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 +### getaddress - query_key - return the spend or view private key - inputs: - key_type: string - which key to retrieve: - "mnemonic": the mnemonic seed (older wallets do not have one) - "view_key": the view key - outputs: - key: string - the view key will be hex encoded +Return the wallet's address. - 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 +Inputs: *None*. - 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 +Outputs: + +* *address* - string + +Example: + + +### getheight + +Returns the wallet's current block height. + +Inputs: *None*. + +Outputs: + +* *height* - string + +Example: + + +### transfer + +Send monero to a number of recipients. + +Inputs: + +* *destinations* - array of: + * *amount* - unsigned int + * *address* - string +* *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). +* *payment_id* - string + +Outputs: + +* *tx_hash* - array of: string + +Example: + + +### transfer_split + +Same as transfer, but can split into more than one tx if necessary. + +Inputs: + +* *destinations* - array of: + * *amount* - unsigned int + * *address* - string +* *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). +* *payment_id* - string +* *new_algorithm* - boolean; True to use the new transaction construction algorithm, defaults to false. + +Outputs: + +* *tx_hash* - array of: string + +Example: + + +### 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 + +Example: + + +### store + +Save the blockchain. + +Inputs: *None*. + +Outputs: + +Example: + + +### 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: + + +### get_bulk_payments + +Get a list of incoming payments using a given payment id, or a list of payments ids, from a given height. + +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: + + +### 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 + +Example: + + +### query_key + +Return the spend or view private key. + +Inputs: + +* *key_type* - string; which key to retrieve: "mnemonic" - the mnemonic seed (older wallets do not have one) OR "view_key" - the view key + +Outputs: + +* *key* - string; the view key will be hex encoded + +Example: + + +### 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 + +Example: + + +### 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: + + +### stop_wallet + +Stops the wallet, storing the current state. + +Inputs: *None*. + +Outputs: + +Example: - stop_wallet - stops the wallet, storing the current state From 91af71a2b9292e24ef67a6129bd06c41878fb163 Mon Sep 17 00:00:00 2001 From: Mike C Date: Sat, 12 Mar 2016 10:30:13 -0700 Subject: [PATCH 10/14] fix broken links within daemon-rpc guide --- knowledge-base/developer-guides/daemon-rpc.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/knowledge-base/developer-guides/daemon-rpc.md b/knowledge-base/developer-guides/daemon-rpc.md index d0f0d45..6cc9537 100644 --- a/knowledge-base/developer-guides/daemon-rpc.md +++ b/knowledge-base/developer-guides/daemon-rpc.md @@ -18,16 +18,16 @@ Many RPC calls use the daemon's JSON RPC interface while others use their own in ### [JSON RPC Methods](#json-rpc-methods): * [getblockcount](#getblockcount) -* [on_getblockhash](#on_getblockhash) +* [on_getblockhash](#ongetblockhash) * [getblocktemplate](#getblocktemplate) * [submitblock](#submitblock) * [getlastblockheader](#getlastblockheader) * [getblockheaderbyhash](#getblockheaderbyhash) * [getblockheaderbyheight](#getblockheaderbyheight) * [getblock](#getblock) -* [get_connections](#get_connections) -* [get_info](#get_info) -* [hard_fork_info](#hard_fork_info) +* [get_connections](#getconnections) +* [get_info](#getinfo) +* [hard_fork_info](#hardforkinfo) * [setbans](#setbans) * [getbans](#getbans) @@ -35,10 +35,10 @@ Many RPC calls use the daemon's JSON RPC interface while others use their own in * [/getheight](#getheight) * [/gettransactions](#gettransactions) -* [/is_key_image_spent](#is_key_image_spent) +* [/is_key_image_spent](#iskeyimagespent) * [/sendrawtransaction](#sendrawtransaction) -* [/get_transaction_pool](#get_transaction_pool) -* [/stop_daemon](#stop_daemon) +* [/get_transaction_pool](#gettransactionpool) +* [/stop_daemon](#stopdaemon) --- @@ -305,7 +305,7 @@ Outputs: * *amount* - The amount of the output, in atomic units. * *target* - * *key* - - * *extra* - Usually called the "transaction ID" but can be used to include any random 32 bytes. + * *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. @@ -590,7 +590,7 @@ The data structure for these calls is different than the JSON RPC calls. Whereas -d $PARAMS \ -H 'Content-Type: application/json' -Note: It is recommended to use JSON RPC where such alternatives exist, rather than the following methods. For example, the recommended way to get a node's height is via the JSON RPC methods [get_info](#get_info) or [getlastblockheader](#getlastblockheader), rather than [getheight](#getheight) below. +Note: It is recommended to use JSON RPC where such alternatives exist, rather than the following methods. For example, the recommended way to get a node's height is via the JSON RPC methods [get_info](#getinfo) or [getlastblockheader](#getlastblockheader), rather than [getheight](#getheight) below. ### /getheight From 32ba7ea352e8d1f14125b1bfa7979c1c39bb8167 Mon Sep 17 00:00:00 2001 From: Mike C Date: Sat, 12 Mar 2016 10:54:04 -0700 Subject: [PATCH 11/14] revamped wallet-rpc dev guide --- knowledge-base/developer-guides/wallet-rpc.md | 294 ++++++++++++++++-- 1 file changed, 261 insertions(+), 33 deletions(-) diff --git a/knowledge-base/developer-guides/wallet-rpc.md b/knowledge-base/developer-guides/wallet-rpc.md index 4ae61a6..fde78b3 100644 --- a/knowledge-base/developer-guides/wallet-rpc.md +++ b/knowledge-base/developer-guides/wallet-rpc.md @@ -24,25 +24,28 @@ All simplewallet methods use the same JSON RPC interface. For example: -d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}' \ -H 'Content-Type: application/json' -### JSON RPC Methods: + +### Index of JSON RPC Methods: * [getbalance](#getbalance) * [getaddress](#getaddress) * [getheight](#getheight) * [transfer](#transfer) -* [transfer_split](#transfer_split) -* [sweep_dust](#sweep_dust) +* [transfer_split](#transfersplit) +* [sweep_dust](#sweepdust) * [store](#store) -* [get_payments](#get_payments) -* [get_bulk_payments](#get_bulk_payments) -* [incoming_transfers](#incoming_transfers) -* [query_key](#query_key) -* [make_integrated_address](#make_integrated_address) -* [split_integrated_address](#split_integrated_address) -* [stop_wallet](#stop_wallet) +* [get_payments](#getpayments) +* [get_bulk_payments](#getbulkpayments) +* [incoming_transfers](#incomingtransfers) +* [query_key](#querykey) +* [make_integrated_address](#makeintegratedaddress) +* [split_integrated_address](#splitintegratedaddress) +* [stop_wallet](#stopwallet) --- +## JSON RPC Methods: + ### getbalance Return the wallet's balance. @@ -51,11 +54,22 @@ Inputs: *None*. Outputs: -* *balance* - unsigned int -* *unlocked_balance* - unsigned int +* *balance* - unsigned int; The total balance of the current simplewallet in session. +* *unlocked_balance* - unsigned int; Unlocked funds are those funds that are sufficiently deep enough in the Monero blockchain to be considered safe to spend. Example: +{:.cli-code} +[ monero->~ ]$ 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 + } +} + ### getaddress @@ -65,10 +79,20 @@ Inputs: *None*. Outputs: -* *address* - string +* *address* - string; The 95-character hex address string of the simplewallet in session. Example: +{:.cli-code} +[ monero->~ ]$ 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" + } +} + ### getheight @@ -78,10 +102,20 @@ Inputs: *None*. Outputs: -* *height* - string +* *height* - string; The current simplewallet's blockchain height. If the wallet has been offline for a long time, it may need to catch up with the daemon. Example: +{:.cli-code} +[ monero->~ ]$ 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 + } +} + ### transfer @@ -89,20 +123,32 @@ Send monero to a number of recipients. Inputs: -* *destinations* - array of: - * *amount* - unsigned int - * *address* - string +* *destinations* - array of destinations to receive XMR: + * *amount* - unsigned int; Amount to send to each destination, in atomic units. + * *address* - string; Destination public address. * *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). -* *payment_id* - string - +* *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. Outputs: * *tx_hash* - array of: string +* *tx_key* - Example: +{:.cli-code} +[ monero->~ ]$ 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": "<29d933789db5483fa63694ed2560d3829dbf0b945fdea3c42fbfa4d381e7ac22>", + "tx_key": "<c228dff7aa455d770f8cf71b9d319d2055a125cfbac1ca9485aeb1a107604d0d>" + } +} + ### transfer_split @@ -110,21 +156,32 @@ Same as transfer, but can split into more than one tx if necessary. Inputs: -* *destinations* - array of: - * *amount* - unsigned int - * *address* - string +* *destinations* - array of destinations to receive XMR: + * *amount* - unsigned int; Amount to send to each destination, in atomic units. + * *address* - string; Destination public address. * *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). -* *payment_id* - string +* *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. * *new_algorithm* - boolean; True to use the new transaction construction algorithm, defaults to false. Outputs: -* *tx_hash* - array of: string +* *tx_hash_list* - array of: string Example: +{:.cli-code} +[ monero->~ ]$ 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": ["<fb39c42cb5ff231ee9e8b381bb8734fd655b6ca28a23cbd82aa9422aa870e91b>"] + } +} + ### sweep_dust @@ -136,8 +193,18 @@ Outputs: * *tx_hash_list* - list of: string -Example: +Example (In this example, `sweep_dust` returns an error due to insufficient funds to sweep): +{:.cli-code} +[ monero->~ ]$ 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" +} ### store @@ -145,10 +212,19 @@ Save the blockchain. Inputs: *None*. -Outputs: +Outputs: *None*. Example: +{:.cli-code} +[ monero->~ ]$ 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": { + } +} + ### get_payments @@ -169,10 +245,26 @@ Outputs: Example: +{:.cli-code} +[ monero->~ ]$ 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 + }] + } +} + ### get_bulk_payments -Get a list of incoming payments using a given payment id, or a list of payments ids, from a given height. +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. Inputs: @@ -190,6 +282,22 @@ Outputs: Example: +{:.cli-code} +[ monero->~ ]$ 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 + }] + } +} + ### incoming_transfers @@ -208,7 +316,76 @@ Outputs: * *tx_hash* - string; Several incoming transfers may share the same hash if they were in the same transaction. * *tx_size* - unsigned int -Example: +Example (Return "all" transaction types): + +{:.cli-code} +[ monero->~ ]$ 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": "<c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1>", + "tx_size": 5870 + },{ + "amount": 300000000000, + "global_index": 794232, + "spent": false, + "tx_hash": "<c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1>", + "tx_size": 5870 + },{ + "amount": 50000000000, + "global_index": 213659, + "spent": false, + "tx_hash": "<c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1>", + "tx_size": 5870 + }] + } +} + +Example (Return "available" transactions): + +{:.cli-code} +[ monero->~ ]$ 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": "<c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1>", + "tx_size": 5870 + },{ + "amount": 300000000000, + "global_index": 794232, + "spent": false, + "tx_hash": "<c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1>", + "tx_size": 5870 + },{ + "amount": 50000000000, + "global_index": 213659, + "spent": false, + "tx_hash": "<c391089f5b1b02067acc15294e3629a463412af1f1ed0f354113dd4467e4f6c1>", + "tx_size": 5870 + }] + } +} + +Example (Return "unavailable" transaction. Note that this particular example returns 0 unavailable transactions): + +{:.cli-code} +[ monero->~ ]$ 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": { + } +} ### query_key @@ -217,13 +394,35 @@ Return the spend or view private key. Inputs: -* *key_type* - string; which key to retrieve: "mnemonic" - the mnemonic seed (older wallets do not have one) OR "view_key" - the view key +* *key_type* - string; Which key to retrieve: "mnemonic" - the mnemonic seed (older wallets do not have one) OR "view_key" - the view key Outputs: -* *key* - string; the view key will be hex encoded +* *key* - string; The view key will be hex encoded, while the mnemonic will be a string of words. -Example: +Example (Query view key): + +{:.cli-code} +[ monero->~ ]$ 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} +[ monero->~ ]$ 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 ..." + } +} ### make_integrated_address @@ -238,7 +437,17 @@ Outputs: * *integrated_address* - string -Example: +Example (Payment ID is empty, use a random ID): + +{:.cli-code} +[ monero->~ ]$ 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" + } +} ### split_integrated_address @@ -256,6 +465,17 @@ Outputs: Example: +{:.cli-code} +[ monero->~ ]$ 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": "<420fa29b2d9a49f5>", + "standard_address": "427ZuEhNJQRXoyJAeEoBaNW56ScQaLXyyQWgxeRL9KgAUhVzkvfiELZV7fCPBuuB2CGuJiWFQjhnhhwiH1FsHYGQGaDsaBA" + } +} + ### stop_wallet @@ -263,8 +483,16 @@ Stops the wallet, storing the current state. Inputs: *None*. -Outputs: +Outputs: *None*. Example: +{:.cli-code} +[ monero->~ ]$ 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": { + } +} From 261718e003e73dcf321cf5e7905bc3093e565e28 Mon Sep 17 00:00:00 2001 From: Mike C Date: Sat, 12 Mar 2016 10:54:33 -0700 Subject: [PATCH 12/14] Add note about "atomic units" to dev guides --- knowledge-base/developer-guides/daemon-rpc.md | 2 ++ knowledge-base/developer-guides/wallet-rpc.md | 1 + 2 files changed, 3 insertions(+) diff --git a/knowledge-base/developer-guides/daemon-rpc.md b/knowledge-base/developer-guides/daemon-rpc.md index 6cc9537..9bdb5a6 100644 --- a/knowledge-base/developer-guides/daemon-rpc.md +++ b/knowledge-base/developer-guides/daemon-rpc.md @@ -15,6 +15,8 @@ This is a list of the bitmonerod daemon RPC calls, their inputs and outputs, and Many RPC calls use the daemon's JSON RPC interface while others use their own interfaces, as demonstrated below. +Note: In the following guide, "atomic units" refer to the smallest fraction of 1 Monero according to the bitmonerod and simplewallet implementation. **1 XMR = 1e12 atomic units.** + ### [JSON RPC Methods](#json-rpc-methods): * [getblockcount](#getblockcount) diff --git a/knowledge-base/developer-guides/wallet-rpc.md b/knowledge-base/developer-guides/wallet-rpc.md index fde78b3..77148d3 100644 --- a/knowledge-base/developer-guides/wallet-rpc.md +++ b/knowledge-base/developer-guides/wallet-rpc.md @@ -24,6 +24,7 @@ All simplewallet methods use the same JSON RPC interface. For example: -d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}' \ -H 'Content-Type: application/json' +Note: In the following guide, "atomic units" refer to the smallest fraction of 1 Monero according to the bitmonerod and simplewallet implementation. **1 XMR = 1e12 atomic units.** ### Index of JSON RPC Methods: From 9cbf059d03464c139a7d75549917c18cce7ba0d5 Mon Sep 17 00:00:00 2001 From: Mike C Date: Sat, 12 Mar 2016 11:13:59 -0700 Subject: [PATCH 13/14] a couple more dev guide changes. --- knowledge-base/developer-guides/daemon-rpc.md | 2 +- knowledge-base/developer-guides/wallet-rpc.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/knowledge-base/developer-guides/daemon-rpc.md b/knowledge-base/developer-guides/daemon-rpc.md index 9bdb5a6..641263c 100644 --- a/knowledge-base/developer-guides/daemon-rpc.md +++ b/knowledge-base/developer-guides/daemon-rpc.md @@ -15,7 +15,7 @@ This is a list of the bitmonerod daemon RPC calls, their inputs and outputs, and Many RPC calls use the daemon's JSON RPC interface while others use their own interfaces, as demonstrated below. -Note: In the following guide, "atomic units" refer to the smallest fraction of 1 Monero according to the bitmonerod and simplewallet implementation. **1 XMR = 1e12 atomic units.** +Note: "atomic units" refer to the smallest fraction of 1 XMR according to the bitmonerod implementation. **1 XMR = 1e12 atomic units.** ### [JSON RPC Methods](#json-rpc-methods): diff --git a/knowledge-base/developer-guides/wallet-rpc.md b/knowledge-base/developer-guides/wallet-rpc.md index 77148d3..3a2d0d4 100644 --- a/knowledge-base/developer-guides/wallet-rpc.md +++ b/knowledge-base/developer-guides/wallet-rpc.md @@ -24,7 +24,7 @@ All simplewallet methods use the same JSON RPC interface. For example: -d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}' \ -H 'Content-Type: application/json' -Note: In the following guide, "atomic units" refer to the smallest fraction of 1 Monero according to the bitmonerod and simplewallet implementation. **1 XMR = 1e12 atomic units.** +Note: "atomic units" refer to the smallest fraction of 1 XMR according to the bitmonerod implementation. **1 XMR = 1e12 atomic units.** ### Index of JSON RPC Methods: From 4c5e5ae848f0817c6c862ae9eaec93035be77691 Mon Sep 17 00:00:00 2001 From: Mike C Date: Sat, 12 Mar 2016 12:48:43 -0700 Subject: [PATCH 14/14] Add additional instructions for deploying Since it is good practice to test changes locally before pushing to git, instructions are added to help newcomers to comfortably do just that. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 978e54b..b3b299d 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,14 @@ Deploying this website requires Jekyll (3.0+) and the following ruby gems: build Multiple language support will be added soon. +To test changes locally before pushing to git, make sure you have ruby installed on your system, then: + +1. Make sure you have the necessary ruby gems: `gem install builder rubysl-rexml jekyll-paginate jekyll` +2. Navigate to the your local `monero-site` repository. +3. Serve the website: `jekyll serve` +4. Open a browser and go to [http://127.0.0.1:4000](http://127.0.0.1:4000). +5. A basic page list will appear. Click on the part of the site you are working on (ex: `design_goals`) and see your work! + ## License Copyright (c) 2014-2016, The Monero Project