Skip to main content

RPC reference

1. Why this chapter exists

zcash-cli help enumerates the RPC surface at runtime, but it is not searchable without a running daemon and gives no source pointers. This chapter is the flat list: every command, the file that registers it, and a one-line role. Use it as a lookup table.

The list is pinned to upstream tag v5.5.0-rc1. After NU6 the upstream tree gained a small number of additional commands; check git log src/rpc/ src/wallet/rpc*.cpp since the pin for the delta.

2. Definitions

Definition 14.1 (RPC command). A function exported via the JSON-RPC server at 127.0.0.1:8232 (mainnet) / :18232 (testnet) / :18232 (regtest). Each command is registered as a CRPCCommand record in a static array, then merged into the global tableRPC at daemon startup.

Definition 14.2 (Category). A string tag that groups related commands. The categories present in v5.5.0-rc1 are blockchain, mining, generating, util, network, rawtransactions, control, addressindex, disclosure, wallet, and hidden (commands that exist but are not listed by help).

Definition 14.3 (Safe-mode flag). Each CRPCCommand carries a boolean okSafeMode. When the node enters safe mode (alert condition), only commands marked true are callable. Most read-only commands are safe-mode OK; commands that mutate state typically are not.

Definition 14.4 (Hidden command). A command registered with category "hidden". It exists and can be invoked, but is omitted from the help output. Used for test hooks (setmocktime, invalidateblock) and seldom-used maintenance operations.

3. The code

The static registration arrays are at the bottom of each RPC file:

src/rpc/blockchain.cpp (CRPCCommand array)
loading...
src/rpc/register.h (the five core Register* functions)
loading...

Each function appends its commands to CRPCTable& tableRPC; the table is the single dispatch surface used by both httprpc.cpp (the HTTP front end) and rpc/client.cpp (the zcash-cli client).

Tables, by category

Conventions in the tables below:

  • "Safe?" is the okSafeMode flag.
  • The "Source" column links the file where the command's handler lives at v5.5.0-rc1.
  • Hidden commands are marked in their own row near the bottom.
  • Wallet commands are unavailable when the node is started with -disablewallet.

control (6 commands)

Daemon lifecycle, introspection, and the help dispatcher.

CommandSafe?SourceRole
helpyesserver.cppList or describe RPC commands.
stopyesserver.cppShut down the daemon.
setlogfilteryesserver.cppReconfigure the tracing log filter at runtime (Rust side).
getinfoyesrpc/misc.cppDeprecated single-call summary. Prefer getblockchaininfo / getnetworkinfo / getwalletinfo.
getmemoryinfoyesrpc/misc.cppMemory allocator stats.
getexperimentalfeaturesyesrpc/misc.cppList -experimentalfeatures= toggles enabled at startup.

blockchain (17 commands)

Read-only chain and mempool inspection.

CommandSafe?SourceRole
getblockchaininfoyesrpc/blockchain.cppChain state summary: height, NU activation, pool balances.
getbestblockhashyesrpc/blockchain.cppHash of the current chain tip.
getblockcountyesrpc/blockchain.cppHeight of the current chain tip.
getblockyesrpc/blockchain.cppBlock by hash or height. Verbosity controls raw vs JSON.
getblockhashyesrpc/blockchain.cppHash of the block at given height on the active chain.
getblockheaderyesrpc/blockchain.cppHeader-only view of a block.
getchaintipsyesrpc/blockchain.cppAll known tips (active, valid-fork, headers-only).
getdifficultyyesrpc/blockchain.cppCurrent PoW difficulty.
getmempoolinfoyesrpc/blockchain.cppMempool summary (count, size, fee).
getrawmempoolyesrpc/blockchain.cppMempool txids or full mempool-entry JSON.
gettxoutyesrpc/blockchain.cppUTXO lookup by outpoint (transparent only).
gettxoutsetinfoyesrpc/blockchain.cppIterate the full UTXO set; slow on mainnet.
verifychainyesrpc/blockchain.cppRe-verify the last N blocks.
z_gettreestateyesrpc/blockchain.cppSprout, Sapling, Orchard tree state at a given block.
getblockdeltasnorpc/blockchain.cppInsight explorer; requires -insightexplorer.
getblockhashesyesrpc/blockchain.cppInsight explorer; block hashes in a timestamp window.
gettxoutproofyesrpc/rawtransaction.cppHex Merkle proof for a transaction.
verifytxoutproofyesrpc/rawtransaction.cppVerify a gettxoutproof blob.
getspentinfonorpc/misc.cppInsight; which tx spent a given outpoint. Requires -spentindex.

network (12 commands)

Peer table, banlist, and connection control.

CommandSafe?SourceRole
getconnectioncountyesrpc/net.cppNumber of connected peers.
getdeprecationinfoyesrpc/net.cppBuild's DEPRECATION_HEIGHT and -allowdeprecated state.
pingyesrpc/net.cppSend ping to every peer (round-trip times read via getpeerinfo).
getpeerinfoyesrpc/net.cppPer-peer status: addr, services, bytes, latency, subversion.
addnodeyesrpc/net.cppAdd/remove/onetry a manual peer (-addnode=).
disconnectnodeyesrpc/net.cppDrop a peer by address or node id.
getaddednodeinfoyesrpc/net.cppStatus of -addnode peers.
getnettotalsyesrpc/net.cppLifetime byte counters.
getnetworkinfoyesrpc/net.cppProtocol version, subversion, local addresses, service flags.
setbanyesrpc/net.cppAdd or remove a manual ban.
listbannedyesrpc/net.cppAll current bans (manual + automatic).
clearbannedyesrpc/net.cppWipe the banlist.

mining (8 commands)

Miner-facing template construction and PoW utilities.

CommandSafe?SourceRole
getmininginfoyesrpc/mining.cppMining-related state: difficulty, mempool, networkhashps.
getlocalsolpsyesrpc/mining.cppLocal Equihash solutions per second.
getnetworksolpsyesrpc/mining.cppNetwork-wide estimated solutions per second.
getnetworkhashpsyesrpc/mining.cppAlias for getnetworksolps.
getblocktemplateyesrpc/mining.cppBuild a candidate block for external miners; includes coinbase template with funding streams.
submitblockyesrpc/mining.cppSubmit a mined block.
getblocksubsidyyesrpc/mining.cppBlock subsidy and funding-stream allocations at a height.
prioritisetransactionyesrpc/mining.cppBias the in-memory fee on a tx for template selection.

generating (3 commands)

Built-in CPU miner; off by default.

CommandSafe?SourceRole
getgenerateyesrpc/mining.cppIs the in-process miner running?
setgenerateyesrpc/mining.cppStart/stop the in-process miner.
generateyesrpc/mining.cppMine N blocks immediately (regtest convenience).

util (5 commands)

Stateless helpers.

CommandSafe?SourceRole
estimatefeeyesrpc/mining.cppFee per byte to land in N blocks (uses fee estimator).
validateaddressyesrpc/misc.cppDecode a transparent address.
z_validateaddressyesrpc/misc.cppDecode a Sprout / Sapling / unified / Orchard address.
createmultisigyesrpc/misc.cppBuild a transparent multisig address.
verifymessageyesrpc/misc.cppVerify a signmessage signature against an address.

rawtransactions (7 commands)

Transparent transaction surgery and proof verification.

CommandSafe?SourceRole
getrawtransactionyesrpc/rawtransaction.cppTransaction by id. Requires -txindex for arbitrary historical txes.
createrawtransactionyesrpc/rawtransaction.cppBuild a transparent transaction skeleton.
decoderawtransactionyesrpc/rawtransaction.cppParse a hex-serialised transaction.
decodescriptyesrpc/rawtransaction.cppDisassemble a redeem-script hex blob.
sendrawtransactionnorpc/rawtransaction.cppBroadcast a serialised transaction; mempool-checks first.
signrawtransactionnorpc/rawtransaction.cppSign a raw tx using keys from the wallet.
fundrawtransactionnowallet/rpcwallet.cppAdd wallet inputs + change to balance a raw tx.

addressindex (5 commands, Insight Explorer)

Off by default. Require -addressindex=1 (and sometimes -spentindex=1). Originated in the Bitcore / Insight explorer fork.

CommandSafe?SourceRole
getaddresstxidsnorpc/misc.cppAll txids touching one or more addresses.
getaddressbalancenorpc/misc.cppNet balance across an address set.
getaddressdeltasnorpc/misc.cppPer-transaction balance deltas per address.
getaddressutxosnorpc/misc.cppUnspent outputs paying to an address set.
getaddressmempoolyesrpc/misc.cppMempool entries touching an address.

wallet, transparent (33 commands)

Require the wallet (-disablewallet=0). Most match Bitcoin Core's legacy wallet.

CommandSafe?SourceRole
addmultisigaddressyeswallet/rpcwallet.cppRegister a transparent multisig address.
backupwalletyeswallet/rpcwallet.cppTransactional copy of wallet.dat.
dumpprivkeyyeswallet/rpcdump.cppWIF private key for a transparent address.
encryptwalletyeswallet/rpcwallet.cppFirst-time passphrase encryption.
getbalancenowallet/rpcwallet.cppConfirmed wallet balance, transparent.
getnewaddressyeswallet/rpcwallet.cppDerive a new transparent receive address.
getrawchangeaddressyeswallet/rpcwallet.cppInternal change address (transparent).
getreceivedbyaddressnowallet/rpcwallet.cppSum received at one address.
gettransactionnowallet/rpcwallet.cppWallet-side view of a tx by id.
getunconfirmedbalancenowallet/rpcwallet.cppMempool-only balance.
getwalletinfonowallet/rpcwallet.cppWallet state summary.
importprivkeyyeswallet/rpcdump.cppImport a WIF transparent key.
importwalletyeswallet/rpcdump.cppReplay a dumpwallet text export.
importaddressyeswallet/rpcdump.cppWatch-only transparent address.
importpubkeyyeswallet/rpcdump.cppWatch-only public key.
keypoolrefillyeswallet/rpcwallet.cppPre-derive transparent keys.
listaddressesyeswallet/rpcwallet.cppEvery address (all pools) the wallet knows.
listaddressgroupingsnowallet/rpcwallet.cppHeuristic clustering of transparent addresses.
listlockunspentnowallet/rpcwallet.cppOutpoints temporarily locked from spending.
listreceivedbyaddressnowallet/rpcwallet.cppPer-address received totals.
listsinceblocknowallet/rpcwallet.cppAll wallet txes since a given block.
listtransactionsnowallet/rpcwallet.cppRecent wallet transactions.
listunspentnowallet/rpcwallet.cppTransparent UTXOs available to the wallet.
lockunspentyeswallet/rpcwallet.cppLock/unlock specific outpoints.
sendmanynowallet/rpcwallet.cppTransparent multi-output send.
sendtoaddressnowallet/rpcwallet.cppTransparent single-output send.
settxfeeyeswallet/rpcwallet.cppDefault fee per kB for legacy commands.
signmessageyeswallet/rpcwallet.cppSign a message with a transparent address's key.
walletlockyeswallet/rpcwallet.cppForget the unlocked passphrase.
walletpassphraseyeswallet/rpcwallet.cppDecrypt the wallet for a timeout.
walletpassphrasechangeyeswallet/rpcwallet.cppChange the passphrase.
walletconfirmbackupyeswallet/rpcwallet.cppAcknowledge that a wallet backup has been taken.
zcbenchmarkyeswallet/rpcwallet.cppRun a built-in cryptographic microbenchmark.
zcsamplejoinsplityeswallet/rpcwallet.cppConstruct one Sprout JoinSplit; sample / debug only.

wallet, shielded z_* (28 commands)

Zcash-specific shielded operations. All wallet RPC; most are async (return an opid from z_getoperationstatus).

CommandSafe?SourceRole
z_getbalancenowallet/rpcwallet.cppBalance for a transparent or shielded address.
z_getbalanceforaccountnowallet/rpcwallet.cppBalance for a unified-account number.
z_getbalanceforviewingkeynowallet/rpcwallet.cppWatch-only balance for a UFVK / extended viewing key.
z_gettotalbalancenowallet/rpcwallet.cppSum across pools.
z_listunspentnowallet/rpcwallet.cppUnspent notes per shielded address.
z_listreceivedbyaddressnowallet/rpcwallet.cppReceived notes for one address.
z_sendmanynowallet/rpcwallet.cppAsync build + send a shielded transaction.
z_mergetoaddressnowallet/rpcwallet.cppAsync consolidate notes into one output.
z_shieldcoinbasenowallet/rpcwallet.cppAsync shield coinbase outputs.
z_setmigrationnowallet/rpcwallet.cppToggle Sprout-to-Sapling migration.
z_getmigrationstatusnowallet/rpcwallet.cppRead migration progress.
z_getoperationstatusyeswallet/rpcwallet.cppPoll one or more async operation IDs.
z_getoperationresultyeswallet/rpcwallet.cppDrain finished async operation results.
z_listoperationidsyeswallet/rpcwallet.cppEnumerate async operation IDs.
z_getnewaddressyeswallet/rpcwallet.cppSapling / Sprout new address (legacy path).
z_getnewaccountyeswallet/rpcwallet.cppCreate a ZIP-316 unified account.
z_listaccountsyeswallet/rpcwallet.cppEnumerate unified accounts.
z_listaddressesyeswallet/rpcwallet.cppEnumerate shielded / unified addresses.
z_listunifiedreceiversyeswallet/rpcwallet.cppDecompose a unified address.
z_getaddressforaccountyeswallet/rpcwallet.cppDerive a unified address for an account.
z_exportkeyyeswallet/rpcdump.cppExport the spending key for a shielded address.
z_importkeyyeswallet/rpcdump.cppImport a spending key.
z_exportviewingkeyyeswallet/rpcdump.cppExport a viewing key.
z_importviewingkeyyeswallet/rpcdump.cppImport a viewing key (watch-only).
z_exportwalletyeswallet/rpcdump.cppText export including shielded keys.
z_importwalletyeswallet/rpcdump.cppText import of a z_exportwallet blob.
z_viewtransactionnowallet/rpcwallet.cppDecrypt the wallet's view of every shielded item in a tx.
z_getnotescountnowallet/rpcwallet.cppCount of Sprout / Sapling / Orchard notes.

disclosure (2 commands)

ZIP-308: selective payment disclosure. Off by default; require -experimentalfeatures -paymentdisclosure.

CommandSafe?SourceRole
z_getpaymentdisclosureyeswallet/rpcdisclosure.cppProduce a ZIP-308 disclosure for one output.
z_validatepaymentdisclosureyeswallet/rpcdisclosure.cppVerify a ZIP-308 disclosure blob.

hidden (6 commands)

Not listed by help. Useful for tests and incident response.

CommandSafe?SourceRole
invalidateblockyesrpc/blockchain.cppMark a block invalid; forces reorg to the next-best tip.
reconsiderblockyesrpc/blockchain.cppUndo invalidateblock.
setmocktimeyesrpc/misc.cppOverride GetTime(); regtest only.
resendwallettransactionsyeswallet/rpcwallet.cppRe-broadcast wallet txes that are still in the mempool.
dumpwalletyeswallet/rpcdump.cppText export, transparent half only. Hidden because z_exportwallet is preferred.

Counts at v5.5.0-rc1: 123 commands in 11 categories.

How a call is served

HTTP POST / -> httprpc.cpp::HTTPReq_JSONRPC
-> JSONRPCRequest
-> tableRPC.execute(jreq)
-> CRPCCommand::actor(params)
-> handler function in the category file
-> wallet lock / cs_main lock as needed
-> returns UniValue
-> serialised back to the HTTP body

Authentication is HTTP Basic, either via the auto-generated ~/.zcash/.cookie file (default) or via -rpcuser= / -rpcpassword= / -rpcauth=. The server is bound to 127.0.0.1 by default; binding to a public interface requires -rpcbind= AND a password, or a TLS-terminating reverse proxy.

Deprecation

A small set of commands and behaviours are gated by -allowdeprecated=<feature>. The list of allowable features is in src/deprecation.cpp; the names match the strings used in getdeprecationinfo.

Adding a new RPC

Pattern (in any of the per-category files):

UniValue mycommand(const UniValue& params, bool fHelp) {
if (fHelp || params.size() != N) {
throw runtime_error(R"(usage and docstring)");
}
LOCK(cs_main); // or whatever locks apply
// ... do work
return result;
}

static const CRPCCommand commands[] = {
{ "mycategory", "mycommand", &mycommand, true, {"arg1", "arg2"} },
};

void RegisterMyRPCCommands(CRPCTable& t) {
for (auto& cmd : commands) t.appendCommand(cmd.name, &cmd);
}

Then hook RegisterMyRPCCommands into src/rpc/register.h or, for wallet RPCs, into wallet/wallet.cpp::RegisterWalletRPCCommands.

4. Failure modes

  • Calling a wallet RPC under -disablewallet. Returns "Method not found" because the wallet's registration was skipped. Caught at first call.
  • Calling getrawtransaction for a historical tx without -txindex. Returns an error; the index does not exist. Caught by the RPC returning -5.
  • Insight RPCs without -addressindex / -spentindex. The command exists but returns an error. Caught by the RPC layer.
  • Async RPC without polling. z_sendmany returns an operation ID, not the result. Forgetting to call z_getoperationresult strands the work; the operation completes but its result is held until drained. Drained on shutdown.
  • Using the getinfo legacy summary. Deprecated; some fields are misleading once shielded pools dominate. Use getblockchaininfo / getnetworkinfo / getwalletinfo instead. Caught by the deprecation warning in the result.
  • Binding RPC to a public IP without TLS. The protocol is HTTP Basic; credentials cross the wire in clear. Caught by audit only.

5. Spec pointers

RPC is implementation-specific and not consensus. Authoritative references:

6. Exercises

  1. Count, by category. Run zcash-cli help | grep -c '^==' || zcash-cli help to enumerate commands by category and compare to the totals above. A delta here often signals a hidden command, or a feature gated behind -experimentalfeatures.

  2. Trace a call. Run zcash-cli getinfo against a regtest node. Inspect debug.log with -debug=rpc and identify each step of the dispatch: HTTP receive, JSON parse, table lookup, handler invocation, lock acquisition, return.

  3. Find an undocumented response field. Pick one command (e.g. getblockchaininfo) and find a field of the response that is not documented in its help string. The fix is a one-line docstring update in the handler.

  4. Modification exercise. Add a getrpcstats RPC that returns per-command invocation counts since startup. The pattern lives in src/rpc/server.cpp; the count can be added to CRPCCommand or kept in a separate std::map.

  5. Audit safe-mode flags. Sort the table above by Safe?. Are there commands marked true that mutate state? Treat any you find as findings; safe-mode is intended for read-only commands.

7. Further reading