Merge pull request #2653 from xanimo/1.14.5-submitblock-error

rpc: improve error message in submitblock
This commit is contained in:
Ross Nicoll 2021-11-01 17:08:08 +00:00 committed by GitHub
commit 5df1b6af3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -787,8 +787,14 @@ UniValue submitblock(const JSONRPCRequest& request)
if (!DecodeHexBlk(block, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
if (block.vtx.empty() || !block.vtx[0]->IsCoinBase()) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block does not start with a coinbase");
if (block.vtx.empty())
{
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block does not contain a coinbase transaction");
}
if (!block.vtx[0]->IsCoinBase())
{
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block does not start with a valid coinbase transaction");
}
uint256 hash = block.GetHash();