MCPcopy Create free account
hub / github.com/ElementsProject/elements / getblockchaininfo

Function getblockchaininfo

src/rpc/blockchain.cpp:1666–1801  ·  view source on GitHub ↗

used by rest.cpp:rest_chaininfo, so cannot be static

Source from the content-addressed store, hash-verified

1664
1665// used by rest.cpp:rest_chaininfo, so cannot be static
1666RPCHelpMan getblockchaininfo()
1667{
1668 /* TODO: from v24, remove -deprecatedrpc=softforks */
1669 return RPCHelpMan{"getblockchaininfo",
1670 "Returns an object containing various state info regarding blockchain processing.\n",
1671 {},
1672 RPCResult{
1673 RPCResult::Type::OBJ, "", "",
1674 {
1675 {RPCResult::Type::STR, "chain", "current network name (main, test, signet, regtest, liquidv1, liquidv1test, liquidtestnet)"},
1676 {RPCResult::Type::NUM, "blocks", "the height of the most-work fully-validated chain. The genesis block has height 0"},
1677 {RPCResult::Type::NUM, "headers", "the current number of headers we have validated"},
1678 {RPCResult::Type::STR, "bestblockhash", "the hash of the currently best block"},
1679 {RPCResult::Type::NUM, "difficulty", "the current difficulty"},
1680 {RPCResult::Type::NUM_TIME, "time", "The block time expressed in " + UNIX_EPOCH_TIME},
1681 {RPCResult::Type::NUM_TIME, "mediantime", "The median block time expressed in " + UNIX_EPOCH_TIME},
1682 {RPCResult::Type::NUM, "verificationprogress", "estimate of verification progress [0..1]"},
1683 {RPCResult::Type::BOOL, "initialblockdownload", "(debug information) estimate of whether this node is in Initial Block Download mode"},
1684 {RPCResult::Type::STR_HEX, "chainwork", "total amount of work in active chain, in hexadecimal"},
1685 {RPCResult::Type::NUM, "size_on_disk", "the estimated size of the block and undo files on disk"},
1686 {RPCResult::Type::BOOL, "pruned", "if the blocks are subject to pruning"},
1687 {RPCResult::Type::STR_HEX, "current_params_root", "the root of the currently active dynafed params"},
1688 {RPCResult::Type::STR, "signblock_asm", "ASM of sign block challenge data from genesis block"},
1689 {RPCResult::Type::STR_HEX, "signblock_hex", "Hex of sign block challenge data from genesis block"},
1690 {RPCResult::Type::STR, "current_signblock_asm", "ASM of sign block challenge data enforced on the next block"},
1691 {RPCResult::Type::STR_HEX, "current_signblock_hex", "Hex of sign block challenge data enforced on the next block"},
1692 {RPCResult::Type::NUM, "max_block_witness", "maximum sized block witness serialized size for the next block"},
1693 {RPCResult::Type::NUM, "epoch_length", "length of dynamic federations epoch, or signaling period"},
1694 {RPCResult::Type::NUM, "total_valid_epochs", "number of epochs a given fedpscript is valid for, defined per chain"},
1695 {RPCResult::Type::NUM, "epoch_age", "number of blocks into a dynamic federation epoch chain tip is. This number is between 0 to epoch_length-1"},
1696 {RPCResult::Type::ARR, "extension_space", "array of extension fields in dynamic blockheader",
1697 {
1698 {RPCResult::Type::ELISION, "", ""}
1699 }},
1700 {RPCResult::Type::NUM, "pruneheight", /*optional=*/true, "lowest-height complete block stored (only present if pruning is enabled)"},
1701 {RPCResult::Type::BOOL, "automatic_pruning", /*optional=*/true, "whether automatic pruning is enabled (only present if pruning is enabled)"},
1702 {RPCResult::Type::NUM, "prune_target_size", /*optional=*/true, "the target size used by pruning (only present if automatic pruning is enabled)"},
1703 {RPCResult::Type::OBJ_DYN, "softforks", "(DEPRECATED, returned only if config option -deprecatedrpc=softforks is passed) status of softforks",
1704 {
1705 {RPCResult::Type::OBJ, "xxxx", "name of the softfork",
1706 RPCHelpForDeployment
1707 },
1708 }},
1709 {RPCResult::Type::STR, "warnings", "any network and blockchain warnings"},
1710 }},
1711 RPCExamples{
1712 HelpExampleCli("getblockchaininfo", "")
1713 + HelpExampleRpc("getblockchaininfo", "")
1714 },
1715 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1716{
1717 const ArgsManager& args{EnsureAnyArgsman(request.context)};
1718 ChainstateManager& chainman = EnsureAnyChainman(request.context);
1719 LOCK(cs_main);
1720 CChainState& active_chainstate = chainman.ActiveChainstate();
1721
1722 const CChainParams& chainparams = Params();
1723 const CBlockIndex* tip = active_chainstate.m_chain.Tip();

Callers 1

rest_chaininfoFunction · 0.85

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
GetDifficultyFunction · 0.85
DeploymentActiveAfterFunction · 0.85
ScriptToAsmStrFunction · 0.85
IsDeprecatedRPCEnabledFunction · 0.85
DeploymentInfoFunction · 0.85
GetWarningsFunction · 0.85
NetworkIDStringMethod · 0.80
GetMedianTimePastMethod · 0.80

Tested by

no test coverage detected