MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / getdeploymentinfo

Function getdeploymentinfo

src/rpc/blockchain.cpp:1520–1571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1518} // anon namespace
1519
1520RPCMethod getdeploymentinfo()
1521{
1522 return RPCMethod{"getdeploymentinfo",
1523 "Returns an object containing various state info regarding deployments of consensus changes.\n"
1524 "Consensus changes for which the new rules are enforced from genesis are not listed in \"deployments\".",
1525 {
1526 {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Default{"hash of current chain tip"}, "The block hash at which to query deployment state"},
1527 },
1528 RPCResult{
1529 RPCResult::Type::OBJ, "", "", {
1530 {RPCResult::Type::STR, "hash", "requested block hash (or tip)"},
1531 {RPCResult::Type::NUM, "height", "requested block height (or tip)"},
1532 {RPCResult::Type::ARR, "script_flags", "script verify flags for the block", {
1533 {RPCResult::Type::STR, "flag", "a script verify flag"},
1534 }},
1535 {RPCResult::Type::OBJ_DYN, "deployments", "", {
1536 {RPCResult::Type::OBJ, "xxxx", "name of the deployment", RPCHelpForDeployment}
1537 }},
1538 }
1539 },
1540 RPCExamples{ HelpExampleCli("getdeploymentinfo", "") + HelpExampleRpc("getdeploymentinfo", "") },
1541 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
1542 {
1543 const ChainstateManager& chainman = EnsureAnyChainman(request.context);
1544 LOCK(cs_main);
1545 const Chainstate& active_chainstate = chainman.ActiveChainstate();
1546
1547 const CBlockIndex* blockindex;
1548 if (request.params[0].isNull()) {
1549 blockindex = CHECK_NONFATAL(active_chainstate.m_chain.Tip());
1550 } else {
1551 const uint256 hash(ParseHashV(request.params[0], "blockhash"));
1552 blockindex = chainman.m_blockman.LookupBlockIndex(hash);
1553 if (!blockindex) {
1554 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
1555 }
1556 }
1557
1558 UniValue deploymentinfo(UniValue::VOBJ);
1559 deploymentinfo.pushKV("hash", blockindex->GetBlockHash().ToString());
1560 deploymentinfo.pushKV("height", blockindex->nHeight);
1561 {
1562 const auto flagnames = GetScriptFlagNames(GetBlockScriptFlags(*blockindex, chainman));
1563 UniValue uv_flagnames(UniValue::VARR);
1564 uv_flagnames.push_backV(flagnames.begin(), flagnames.end());
1565 deploymentinfo.pushKV("script_flags", uv_flagnames);
1566 }
1567 deploymentinfo.pushKV("deployments", DeploymentInfo(blockindex, chainman));
1568 return deploymentinfo;
1569 },
1570 };
1571}
1572
1573/** Comparison function for sorting the getchaintips heads. */
1574struct CompareBlocksByHeight

Callers 1

rest_deploymentinfoFunction · 0.85

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ParseHashVFunction · 0.85
JSONRPCErrorFunction · 0.85
GetScriptFlagNamesFunction · 0.85
GetBlockScriptFlagsFunction · 0.85
DeploymentInfoFunction · 0.85
isNullMethod · 0.80
LookupBlockIndexMethod · 0.80
pushKVMethod · 0.80
TipMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected