|
|
|
@ -1577,28 +1577,12 @@ static RPCHelpMan preciousblock()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static RPCHelpMan invalidateblock()
|
|
|
|
|
{
|
|
|
|
|
return RPCHelpMan{"invalidateblock",
|
|
|
|
|
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n",
|
|
|
|
|
{
|
|
|
|
|
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as invalid"},
|
|
|
|
|
},
|
|
|
|
|
RPCResult{RPCResult::Type::NONE, "", ""},
|
|
|
|
|
RPCExamples{
|
|
|
|
|
HelpExampleCli("invalidateblock", "\"blockhash\"")
|
|
|
|
|
+ HelpExampleRpc("invalidateblock", "\"blockhash\"")
|
|
|
|
|
},
|
|
|
|
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
|
|
|
|
{
|
|
|
|
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
|
|
|
|
void InvalidateBlock(ChainstateManager& chainman, const uint256 block_hash) {
|
|
|
|
|
BlockValidationState state;
|
|
|
|
|
|
|
|
|
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
|
|
|
|
CBlockIndex* pblockindex;
|
|
|
|
|
{
|
|
|
|
|
LOCK(cs_main);
|
|
|
|
|
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
|
|
|
|
LOCK(chainman.GetMutex());
|
|
|
|
|
pblockindex = chainman.m_blockman.LookupBlockIndex(block_hash);
|
|
|
|
|
if (!pblockindex) {
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
|
|
|
|
}
|
|
|
|
@ -1612,6 +1596,26 @@ static RPCHelpMan invalidateblock()
|
|
|
|
|
if (!state.IsValid()) {
|
|
|
|
|
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static RPCHelpMan invalidateblock()
|
|
|
|
|
{
|
|
|
|
|
return RPCHelpMan{"invalidateblock",
|
|
|
|
|
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n",
|
|
|
|
|
{
|
|
|
|
|
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as invalid"},
|
|
|
|
|
},
|
|
|
|
|
RPCResult{RPCResult::Type::NONE, "", ""},
|
|
|
|
|
RPCExamples{
|
|
|
|
|
HelpExampleCli("invalidateblock", "\"blockhash\"")
|
|
|
|
|
+ HelpExampleRpc("invalidateblock", "\"blockhash\"")
|
|
|
|
|
},
|
|
|
|
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
|
|
|
|
{
|
|
|
|
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
|
|
|
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
|
|
|
|
|
|
|
|
|
InvalidateBlock(chainman, hash);
|
|
|
|
|
|
|
|
|
|
return UniValue::VNULL;
|
|
|
|
|
},
|
|
|
|
|