Requant documentation
JSON-RPC reference
Every requantd serves JSON-RPC over HTTP on --rpc (default 127.0.0.1:19334 on the test network). It is the full interface to a node: chain data, the mempool, sending, mining and administration. For a read-mostly interface that is safe to expose publicly, see the public API.
Requests
POST /with a JSON body; parameters are positional.- JSON-RPC 2.0: requests with
"jsonrpc": "2.0"get standard responses; batches of up to 100 requests; requests without anidare notifications and get no response. - Error codes:
-32700parse error,-32600invalid request,-32601unknown method,-32602invalid parameters,-32000node error (the message says why). - Legacy form: a request without
"jsonrpc"gets{"result": …, "error": …, "id": …}, which miners and older tools use. - Request bodies up to 4 MiB.
curl -s 127.0.0.1:19334 -d '{"jsonrpc":"2.0","id":1,"method":"getblockhash","params":[100]}'
curl -s 127.0.0.1:19334 -d '[{"jsonrpc":"2.0","id":1,"method":"getinfo","params":[]},
{"jsonrpc":"2.0","id":2,"method":"estimatefee","params":[3]}]'
Authentication
- Keep the RPC on localhost. Anyone who can reach it can send transactions you give it and stop the node from localhost.
- With
--rpc-token-file FILEor--rpc-cookie, every request needsAuthorization: Bearer <token>; requests without it get HTTP 401. --rpc-cookiewrites a random token to<datadir>/<network>/.cookieat start and removes it at shutdown. Tools read it from the file named inREQUANT_RPC_COOKIE, or take a token fromREQUANT_RPC_TOKEN.
Conventions
- Amounts are integer atoms: 1 RQT = 100,000,000 atoms.
- Hashes (block ids, txids, key hashes) are 64 lowercase hex characters.
- Owners. Methods that take an owner take a key hash (hex), not an address; convert with
validateaddress.utxosandhistoryalso take a list of up to 200 key hashes, and every entry in the answer then names itsowner. - Blocks are given as a height or a block id.
Chain
| Method | Parameters | Result |
|---|---|---|
getinfo | version, agent, network, height, headers, tip, chainwork, issued_atoms, peers, outbound, mempool, mempool_bytes, indexed_txs, snapshot_height, update_available, load, uptime_s | |
getblockhash | height | block id on the best chain |
getblock | height or id | id, height, time, target, prev, best_chain, txs (count), txids, hex |
getblockheader | height or id | header fields, next, confirmations, header hex |
getchaintips | known tips: id, height, status, branch_length | |
auditsupply | whether the UTXO set holds no more than the emission allows, and the UTXO set hash |
Transactions and addresses
| Method | Parameters | Result |
|---|---|---|
gettx | txid | from the index or the mempool: inputs with the value and owner they spend, outputs, fee, height |
decodetx | hex | the same view for a raw transaction |
sendtx | hex | txid, after the transaction is accepted to the mempool |
utxos | key hash, or list of ≤ 200 | txid, vout, value, height, coinbase, confirmed, spendable (and owner for lists) |
getbalance | key hash | confirmed, unconfirmed, immature |
history | key hash or list, [limit = 100] | txid, height, confirmations, time, received, sent (newest first; pending entries have no height) |
validateaddress | address | valid, address, key_hash; or valid: false and an error |
conditionaddress | "multi2", pubkey_a, pubkey_b; "htlc", sha256, claim, refund, timeout; "delayed", owner, revoke, delay; "htlc-revocable", sha256, claim, refund, revoke, timeout, claim_delay, refund_delay | key_hash and address of the condition (spending conditions) |
Mempool and fees
| Method | Parameters | Result |
|---|---|---|
getrawmempool | [verbose] | txids; verbose entries add fee, size and feerate |
getmempoolinfo | size, bytes, max_bytes, min_feerate, max_tx_bytes | |
estimatefee | [blocks = 3], 1–100 | feerate in atoms per byte that keeps a new transaction within that many blocks of the queue; also min_feerate and pool_bytes |
Mining
| Method | Parameters | Result |
|---|---|---|
getwork | payee key hash, [longpollid] | height, longpollid, header, header_digest, epoch_seed, target and the TNet parameters; with a longpollid the call waits up to 60 s for a new block |
submitwork | header_digest, nonce, i, c, piece hex | accepted: true and the result, or accepted: false and a reason |
See mining protocol for the full exchange and the pool's extensions.
Network and administration
| Method | Parameters | Result |
|---|---|---|
getnetworkinfo | protocol, min_protocol, listen_port, peer counts by direction, uploaded bytes | |
getpeerinfo (alias peers) | addr, outbound, listen, agent, height, connected_s | |
addpeer | "host:port" | connects to a peer |
getevents | recent watchman events: time, level, text | |
getrelease | the newest verified release manifest | |
submitrelease | manifest, signature | announce a signed release to the network |
stop | saves state and exits; from localhost only |
Example: send a payment from your own code
- Find the coins of your key hash with
utxos. - Build and sign a kind-1 transfer (transactions); the fee is the size times
estimatefee. - Submit the hex with
sendtx; follow it withgettxuntil it has the confirmations you need.
Or let requant-wallet build and sign, and use RPC only to watch the chain.