The majority of daemon RPC calls use the daemon's json_rpc interface to request various bits of information. These methods all follow a similar structure, for example:
Some methods include parameters, while others do not. Examples of each JSON RPC method follow.
getblockcount
Look up how many blocks are in the longest chain known to the node.
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:
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 - string; The block's sha256 hash. Outputs:
block_header - A structure containing block header information. See getlastblockheader.
In this example, block 912345 is looked up by its hash:
Similar to getblockheaderbyhash above, this method includes a block's height as an input parameter to retrieve basic information about the block.
Inputs:
height - unsigned int; The block's height. Outputs:
block_header - A structure containing block header information. See getlastblockheader. In this example, block 912345 is looked up by its height (notice that the returned information is the save as in the previous example):
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.
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.
block_header - A structure containing block header information. See getlastblockheader.
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:
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 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.
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):
Look up information regarding hard fork voting and readiness.
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.
Not all daemon RPC calls use the JSON_RPC interface. This section gives examples of these calls.
The data structure for these calls is different than the JSON RPC calls. Whereas the JSON RPC methods were called using the /json_rpc extension and specifying a method, these methods are called at their own extensions. For example:
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 or getlastblockheader, rather than getheight below.
/getheight
Get the node's current height.
Inputs: None.
Outputs:
height - unsigned int; Current length of longest chain known to daemon.
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 - 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:
key - The public key of the previous output spent in this transaction.
amount - The amount of the input, in atomic units.
key_offsets - A list of integer offets to the input.
k_image - The key image for the given input
vout - List of outputs from transaction:
amount - Amount of transaction output, in atomic units.
target - Output destination information:
key - The stealth public key of the receiver. Whoever owns the private key associated with this key controls this transaction output.
extra - Usually called the "payment ID" but can be used to include any random 32 bytes.
signatures - List of ignatures used in ring signature to hide the true origin of the transaction. Example 1: Return transaction information in binary format.
Example 2: Decode returned transaction information in JSON format. Note: the "vout" list has been truncated in the displayed return for space considerations.
Check if outputs have been spent using the key image associated with the output.
Inputs:
key_images - string list; List of key image hex strings to check.
Outputs:
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.
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.
Inputs: None.
Outputs:
spent_key_images - List of spent output key images: