Skip to main content

Blockchain RPCs

RPC commands for querying blocks, chain state, UTXO set, and chain validation on the BTX network.

getbestblockhash

Returns the hash of the best (tip) block in the most-work fully-validated chain.

btx-cli getbestblockhash

Returns a hex-encoded 256-bit block hash string. No parameters.

getblock

Returns data about a block given its hash. Verbosity controls the detail level.

ParameterTypeRequiredDescription
blockhashstring (hex)YesThe block hash
verbositynumberNo (default 1)0 = hex data, 1 = JSON object, 2 = JSON with tx details, 3 = JSON with tx details and prevout info
btx-cli getblock "00000000c937..." 1

Key response fields (verbosity 1+):

FieldDescription
hashThe block hash
confirmationsNumber of confirmations, or -1 if not on the main chain
heightBlock height
size, weightBlock size in bytes and BIP 141 weight units
merklerootMerkle root of all transactions
txArray of transaction ids (verbosity 1) or full tx objects (2+)
nonce6464-bit BTX nonce
matmul_digestMatMul transcript digest
matmul_dimMatMul matrix dimension (512 on mainnet)
seed_a, seed_bMatMul matrix seeds A and B
targetDifficulty target
difficultyFloating-point difficulty
chainworkCumulative chain work (hex)
previousblockhashHash of previous block
nextblockhashHash of next block (if available)

getblockcount

Returns the height of the most-work fully-validated chain. The genesis block has height 0.

btx-cli getblockcount

Returns a single integer. No parameters.

getblockhash

Returns the hash of the block at the given height in the best chain.

ParameterTypeRequiredDescription
heightnumberYesBlock height index
btx-cli getblockhash 1000

Returns the hex-encoded block hash at the specified height.

getblockheader

Returns header data for the given block hash. When verbose is false, returns serialized hex-encoded header data.

ParameterTypeRequiredDescription
blockhashstring (hex)YesThe block hash
verbosebooleanNo (default true)true for JSON object, false for hex-encoded data
btx-cli getblockheader "00000000c937..."

Verbose response includes all standard header fields plus BTX-specific MatMul fields (nonce64, matmul_digest, matmul_dim, seed_a, seed_b, target).

getblockstats

Compute per-block statistics for a given block. Works on blocks in the active chain only.

ParameterTypeRequiredDescription
hash_or_heightstring/numberYesBlock hash (hex) or height
statsarrayNoRestrict results to specific stat names
btx-cli getblockstats 1000

Response includes: avgfee, avgfeerate, avgtxsize, ins, outs, maxfee, maxfeerate, medianfee, minfee, subsidy, swtotal_size, swtotal_weight, swtxs, total_out, total_size, total_weight, totalfee, txs, utxo_increase, utxo_size_inc, and more.

getchaintips

Return information about all known chain tips, including the main chain and orphaned branches.

btx-cli getchaintips

Returns an array of objects, each containing:

  • height — tip height
  • hash — tip block hash
  • branchlen — branch length (0 for the active chain)
  • status — one of: active, valid-fork, valid-headers, headers-only, invalid

getchaintxstats

Compute statistics about the total number and rate of transactions in the chain.

ParameterTypeRequiredDescription
nblocksnumberNoNumber of blocks to average over (default: one month)
blockhashstring (hex)NoHash of the block that ends the window
btx-cli getchaintxstats 2016

Response includes txcount, txrate (tx/sec), window_final_block_hash, window_final_block_height, window_block_count, window_interval, and window_tx_count.

gettxout

Returns details about an unspent transaction output (UTXO).

ParameterTypeRequiredDescription
txidstring (hex)YesThe transaction id
nnumberYesThe output index (vout)
include_mempoolbooleanNo (default true)Whether to include the mempool
btx-cli gettxout "txid" 0

Returns bestblock, confirmations, value, scriptPubKey (with asm, hex, type, address), and coinbase flag. Returns null if the UTXO has been spent.

gettxoutsetinfo

Returns statistics about the unspent transaction output set. This call may take several minutes on large chains.

ParameterTypeRequiredDescription
hash_typestringNo (default "hash_serialized_3")Hash algorithm: hash_serialized_3, muhash, or none
hash_or_heightstring/numberNoBlock hash or height to compute stats at
use_indexbooleanNo (default true)Use coinstats index if available
btx-cli gettxoutsetinfo

Response includes height, bestblock, txouts, total_amount, bogosize, hash_serialized_3 or muhash, and disk_size.

verifychain

Verifies blockchain database integrity.

ParameterTypeRequiredDescription
checklevelnumberNo (default 3)Verification thoroughness (0-4)
nblocksnumberNo (default 6)Number of blocks to check (0 = all)
btx-cli verifychain 4 100

Returns true if verification succeeds.

getblockfilter

Retrieve a BIP 157 compact block filter for a particular block. Requires -blockfilterindex=basic.

ParameterTypeRequiredDescription
blockhashstring (hex)YesThe block hash
filtertypestringNo (default "basic")Filter type name
btx-cli getblockfilter "00000000c937..."

Returns filter (hex-encoded filter data) and header (hex-encoded filter header).

invalidateblock

Permanently marks a block as invalid, as if it violated a consensus rule. Use reconsiderblock to reverse.

ParameterTypeRequiredDescription
blockhashstring (hex)YesHash of the block to mark as invalid
btx-cli invalidateblock "00000000c937..."

Returns nothing on success. This will trigger a reorg if the invalidated block is in the active chain.

reconsiderblock

Removes invalidity status of a block and its descendants, then reconsiders them for the active chain.

ParameterTypeRequiredDescription
blockhashstring (hex)YesHash of the block to reconsider
btx-cli reconsiderblock "00000000c937..."

Returns nothing on success.

waitforblock

Waits for a specific block hash and returns its height. Make sure to use btx-cli -rpcclienttimeout=0.

ParameterTypeRequiredDescription
blockhashstring (hex)YesBlock hash to wait for
timeoutnumberNo (default 0)Timeout in milliseconds. 0 means no timeout.
btx-cli -rpcclienttimeout=0 waitforblock "00000000c937..." 60000

Returns hash and height of the current tip when the condition is met or on timeout.

waitfornewblock

Waits for any new block and returns info about it. Returns the current block on timeout or exit.

ParameterTypeRequiredDescription
timeoutnumberNo (default 0)Timeout in milliseconds. 0 means no timeout.
current_tipstring (hex)NoBlock hash; waits until the chain tip differs from this value
btx-cli -rpcclienttimeout=0 waitfornewblock 60000

Returns hash and height.

waitforblockheight

Waits until the chain reaches (at least) the specified block height, then returns the current tip.

ParameterTypeRequiredDescription
heightnumberYesBlock height to wait for
timeoutnumberNo (default 0)Timeout in milliseconds. 0 means no timeout.
btx-cli -rpcclienttimeout=0 waitforblockheight 50000 120000

Returns hash and height of the current tip when the condition is met or on timeout.