diff options
author | Gregory Maxwell <greg@xiph.org> | 2017-04-02 21:39:32 +0000 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-04 09:01:03 +0200 |
commit | a44a6a15f94a6223a71790c5a65eb2b8a5b35dd2 (patch) | |
tree | 805306e240f12da3627f82857d064c68aa813aba /src | |
parent | 2fea10ad03c22d3299c56a45370598501d7ee7cf (diff) | |
download | bitcoin-a44a6a15f94a6223a71790c5a65eb2b8a5b35dd2.tar.xz |
Check transaction count early in submitblock.
There is no point in even hashing a submitted block which doesn't have
a coinbase transaction.
This also results in more useful error reporting on corrupted input.
Thanks to rawodb for the bug report.
Github-Pull: #10146
Rebased-From: 4f15ea102d15eb237b63464725508dc509e98819
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/mining.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 38d7b1eb1e..33e234a95e 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -748,6 +748,10 @@ 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"); + } + uint256 hash = block.GetHash(); bool fBlockPresent = false; { |