aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorGregory Maxwell <[email protected]>2017-04-02 21:39:32 +0000
committerGregory Maxwell <[email protected]>2017-04-03 07:15:36 +0000
commit4f15ea102d15eb237b63464725508dc509e98819 (patch)
treeed68b29e42f3cf9bf79e741203aca1b0e7e54a89 /src/rpc/mining.cpp
parentMake GetWitnessCommitmentIndex callable on blocks without a coinbase txn. (diff)
downloaddiscoin-4f15ea102d15eb237b63464725508dc509e98819.tar.xz
discoin-4f15ea102d15eb237b63464725508dc509e98819.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.
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 b823c159d..cfa6edae1 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -744,6 +744,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;
{