aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorGregory Maxwell <[email protected]>2017-04-02 21:39:32 +0000
committerWladimir J. van der Laan <[email protected]>2017-04-04 09:01:03 +0200
commita44a6a15f94a6223a71790c5a65eb2b8a5b35dd2 (patch)
tree805306e240f12da3627f82857d064c68aa813aba /src/rpc/mining.cpp
parentMake GetWitnessCommitmentIndex callable on blocks without a coinbase txn. (diff)
downloaddiscoin-a44a6a15f94a6223a71790c5a65eb2b8a5b35dd2.tar.xz
discoin-a44a6a15f94a6223a71790c5a65eb2b8a5b35dd2.zip
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/rpc/mining.cpp')
-rw-r--r--src/rpc/mining.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 38d7b1eb1..33e234a95 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;
{