Blockchain

Blockchain consensus-related functions.

You can use mvc-cli help command to view the usage of specific commands. The JsonRpc call method is in the example.

Commands

== Blockchain ==
checkjournal
getbestblockhash
getblock "blockhash" ( verbosity )
getblockbyheight height ( verbosity )
getblockchaininfo
getblockcount
getblockhash height
getblockheader "hash" ( verbose )
getblockstats blockhash ( stats )
getblockstatsbyheight height ( stats )
getchaintips
getchaintxstats ( nblocks blockhash )
getdifficulty
getmempoolancestors txid (verbose)
getmempooldescendants txid (verbose)
getmempoolentry txid
getmempoolinfo
getrawmempool ( verbose )
getrawnonfinalmempool
gettxout "txid" n ( include_mempool )
gettxoutproof ["txid",...] ( blockhash )
gettxoutsetinfo
preciousblock "blockhash"
pruneblockchain
rebuildjournal
verifychain ( checklevel nblocks )
verifytxoutproof "proof"

checkjournal

The node builds the blockchain using journaling by default. This command checks the integrity and consistency between the journal and the TX memory pool. Miners use this command to check the integrity of the blocks.

getbestblockhash

Returns the hash of the best (tip) block in the longest blockchain.

getblock

According to the verbosityParam, return the block information of the specified hash value.

Param

  • blockhash: block hash

  • verbosity: 0, 1, 2, 3ใ€‚or "RAW_BLOCK", "DECODE_HEADER", "DECODE_TRANSACTIONS", "DECODE_HEADER_AND_COINBASE"

If verbosity is 0 or RAW_BLOCK, returns a string that is serialized, hex-encoded data for block 'hash'. If verbosity is 1 or DECODE_HEADER, returns an Object with information about block <hash>. If verbosity is 2 or DECODE_TRANSACTIONS, returns an Object with information about block <hash> and information about each transaction. If verbosity is 3 or DECODE_HEADER_AND_COINBASE, returns a json object with block information and the coinbase transaction.

getblockbyheight

Return block information based on block height. The result is the same as getblock. It should be noted that if the block height is not on the main chain, the confirmations in the returned result will be -1. Additionally, due to block reorganizations, the block corresponding to a particular height may change.

Param

  • height: Block height

  • verbosity: 0, 1, 2, 3. Can also be the strings "RAW_BLOCK", "DECODE_HEADER", "DECODE_TRANSACTIONS", " DECODE_HEADER_AND_COINBASE"

The corresponding results for the values of verbosity are as follows:

  • 0 or "RAW_BLOCK": Returns the HEX serialized data of the block, used for fetching complete data.

  • 1 or "DECODE_HEADER": Returns the block header information.

  • 2 or "DECODE_TRANSACTIONS": Returns both the block header and transaction information.

  • 3 or "DECODE_HEADER_AND_COINBASE": Returns the block header and coinbase transaction information.

getblockchaininfo

Returns an object containing various state info regarding blockchain processing.

getblockcount

Returns the number of blocks in the longest blockchain.

getblockhash

Get the hash of the block at the specified height in the local best block chain.

Param๏ผš

  • height: height

getblockheader

If verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'. If verbose is true, returns an Object with information about blockheader <hash>.

Param๏ผš

  • hash: block hash

  • verbose:(boolean, optional, default=true) true for a json object, false for the hex encoded data

getblockstats

Return block statistics based on the block hash value. You can specify statsParam to return different statistical information. Statistics include fee rates, number of inputs, number of outputs, number of UTXOs, etc.

Param:

  • blockhash: Block hash value

  • stats: Options include "minmaxfee", "minmaxfeerate", "avgfee", "avgfeerate", "avgtxsize", "blockhash", " utxo_size_inc", etc. See the example below for details.

getblockstatsbyheight

Compute per block statistics for a given window. All amounts are in SPACE.

Param๏ผš

  • height: height

  • stats: "minmaxfee", "minmaxfeerate", "avgfee", "avgfeerate", "avgtxsize", "blockhash", "utxo_size_inc"

getchaintips

Return information about all known tips in the block tree, including the main chain as well as orphaned branches.

getchaintxstats

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

Param๏ผš

  • nblocks

  • blockhash

getdifficulty

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

getmempoolancestors

If txid is in the mempool, returns all in-mempool ancestors.

Param๏ผš

  • txid

  • verbose: true, false

getmempooldescendants

If txid is in the mempool, returns all in-mempool descendants.

Param๏ผš

  • txid

  • verbose: true, falseใ€‚

getmempoolentry

Returns mempool data for given transaction

Param๏ผš

  • txid

getmempoolinfo

Returns details on the active state of the TX memory pool.

getrawmempool

Returns all transaction ids in memory pool as a json array of string transaction ids.

Param๏ผš

  • verbose: true, falseใ€‚

getrawnonfinalmempool

Returns all transaction ids in the non-final memory pool as a json array of string transaction ids.

gettxout

Returns details about an unspent transaction output.

Param๏ผš

  • txid

  • n

  • include_mempool: true, false

gettxoutproof

Returns a hex-encoded proof that "txid" was included in a block.

Param๏ผš

  • txids

  • blockhash

gettxoutsetinfo

Returns statistics about the unspent transaction output set.

preciousblock

Treats a block as if it were received before others with the same work.

Param๏ผš

  • blockhash

pruneblockchain

Prune up to specified height.

Param๏ผš

  • height

rebuildjournal

Forces the block assembly journal and the TX mempool to be rebuilt to make them consistent with each other.

verifytxoutproof

Verifies that a proof points to a transaction in a block, returning the transaction it commits to and throwing an RPC error if the block is not in our best chain

Param๏ผš

  • proof