mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-12 01:42:01 +02:00
rpc: getdeploymentinfo: allow specifying a blockhash other than tip
This commit is contained in:
parent
fd826130a0
commit
7f15c1841b
@ -1590,7 +1590,9 @@ static RPCHelpMan getdeploymentinfo()
|
|||||||
{
|
{
|
||||||
return RPCHelpMan{"getdeploymentinfo",
|
return RPCHelpMan{"getdeploymentinfo",
|
||||||
"Returns an object containing various state info regarding soft-forks.",
|
"Returns an object containing various state info regarding soft-forks.",
|
||||||
{},
|
{
|
||||||
|
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Default{"chain tip"}, "The block hash at which to query fork state"},
|
||||||
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
RPCResult::Type::OBJ, "", "", {
|
RPCResult::Type::OBJ, "", "", {
|
||||||
{RPCResult::Type::OBJ, "deployments", "", {
|
{RPCResult::Type::OBJ, "deployments", "", {
|
||||||
@ -1605,8 +1607,18 @@ static RPCHelpMan getdeploymentinfo()
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
CChainState& active_chainstate = chainman.ActiveChainstate();
|
||||||
|
|
||||||
const CBlockIndex* tip = active_chainstate.m_chain.Tip();
|
const CBlockIndex* tip;
|
||||||
CHECK_NONFATAL(tip);
|
if (request.params[0].isNull()) {
|
||||||
|
tip = active_chainstate.m_chain.Tip();
|
||||||
|
CHECK_NONFATAL(tip);
|
||||||
|
} else {
|
||||||
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
||||||
|
tip = chainman.m_blockman.LookupBlockIndex(hash);
|
||||||
|
if (!tip) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||||
|
|
||||||
UniValue deploymentinfo(UniValue::VOBJ);
|
UniValue deploymentinfo(UniValue::VOBJ);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user