Skip to content

Commit 5049894

Browse files
committed
Break out finalizecomaptblock errors to be more helpful
1 parent 81fd79a commit 5049894

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rpc/mining.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,14 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
13821382

13831383
const std::vector<std::pair<uint256, CTransactionRef>> dummy;
13841384
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
1385-
if (partialBlock.InitData(cmpctblock, dummy) != READ_STATUS_OK || partialBlock.FillBlock(*pblock, found, false /* pow_check*/) != READ_STATUS_OK) {
1385+
if (partialBlock.InitData(cmpctblock, dummy) != READ_STATUS_OK) {
1386+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "compact_hex appears malformed.");
1387+
}
1388+
auto result = partialBlock.FillBlock(*pblock, found, false /* pow_check*/);
1389+
if (result == READ_STATUS_FAILED) {
13861390
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found. Could be random short ID collision; requires full block instead.");
1391+
} else if (result != READ_STATUS_OK) {
1392+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found.");
13871393
}
13881394

13891395
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);

0 commit comments

Comments
 (0)