| 2089 | } |
| 2090 | |
| 2091 | static RPCHelpMan invalidateblock() |
| 2092 | { |
| 2093 | return RPCHelpMan{"invalidateblock", |
| 2094 | "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n", |
| 2095 | { |
| 2096 | {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as invalid"}, |
| 2097 | }, |
| 2098 | RPCResult{RPCResult::Type::NONE, "", ""}, |
| 2099 | RPCExamples{ |
| 2100 | HelpExampleCli("invalidateblock", "\"blockhash\"") |
| 2101 | + HelpExampleRpc("invalidateblock", "\"blockhash\"") |
| 2102 | }, |
| 2103 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 2104 | { |
| 2105 | uint256 hash(ParseHashV(request.params[0], "blockhash")); |
| 2106 | BlockValidationState state; |
| 2107 | |
| 2108 | ChainstateManager& chainman = EnsureAnyChainman(request.context); |
| 2109 | CBlockIndex* pblockindex; |
| 2110 | { |
| 2111 | LOCK(cs_main); |
| 2112 | pblockindex = chainman.m_blockman.LookupBlockIndex(hash); |
| 2113 | if (!pblockindex) { |
| 2114 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
| 2115 | } |
| 2116 | } |
| 2117 | chainman.ActiveChainstate().InvalidateBlock(state, pblockindex); |
| 2118 | |
| 2119 | if (state.IsValid()) { |
| 2120 | chainman.ActiveChainstate().ActivateBestChain(state); |
| 2121 | } |
| 2122 | |
| 2123 | if (!state.IsValid()) { |
| 2124 | throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString()); |
| 2125 | } |
| 2126 | |
| 2127 | return NullUniValue; |
| 2128 | }, |
| 2129 | }; |
| 2130 | } |
| 2131 | |
| 2132 | static RPCHelpMan reconsiderblock() |
| 2133 | { |
nothing calls this directly
no test coverage detected