Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3974,28 +3974,20 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state,

bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW, bool fCheckMerkleRoot, bool fDBCheck)
{
// These are checks that are independent of context.

// MODIFICATION: Early return
if (block.fChecked)
return true;

// MODIFICATION: Verification of the minimal size in first (fast)
if (block.vtx.empty()) {
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", false, "no transactions");
}

// Check that the header is valid (particularly PoW). This is mostly
// redundant with the call in AcceptBlockHeader.
if (!CheckBlockHeader(block, state, consensusParams, fCheckPOW))
return error("%s: Consensus::CheckBlockHeader: %s", __func__, FormatStateMessage(state));

// Check the merkle root.
if (fCheckMerkleRoot) {
bool mutated;
uint256 hashMerkleRoot2 = BlockMerkleRoot(block, &mutated);
if (block.hashMerkleRoot != hashMerkleRoot2)
return state.DoS(100, false, REJECT_INVALID, "bad-txnmrklroot", true, "hashMerkleRoot mismatch");

// Check for merkle tree malleability (CVE-2012-2459): repeating sequences
// of transactions in a block without affecting the merkle root of a block,
// while still invalidating it.
if (mutated)
return state.DoS(100, false, REJECT_INVALID, "bad-txns-duplicate", true, "duplicate transaction");
}

// All potential-corruption validation must be done before we do any
Expand Down