Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show All 14 Lines | |||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/activation.h> | #include <consensus/activation.h> | ||||
#include <consensus/merkle.h> | #include <consensus/merkle.h> | ||||
#include <consensus/tx_check.h> | #include <consensus/tx_check.h> | ||||
#include <consensus/tx_verify.h> | #include <consensus/tx_verify.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <hash.h> | #include <hash.h> | ||||
#include <index/txindex.h> | #include <index/txindex.h> | ||||
#include <minerfund.h> | |||||
#include <policy/fees.h> | #include <policy/fees.h> | ||||
#include <policy/mempool.h> | #include <policy/mempool.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <random.h> | #include <random.h> | ||||
▲ Show 20 Lines • Show All 1,770 Lines • ▼ Show 20 Lines | bool CChainState::ConnectBlock(const CBlock &block, BlockValidationState &state, | ||||
if (block.vtx[0]->GetValueOut() > blockReward) { | if (block.vtx[0]->GetValueOut() > blockReward) { | ||||
LogPrintf("ERROR: ConnectBlock(): coinbase pays too much (actual=%d vs " | LogPrintf("ERROR: ConnectBlock(): coinbase pays too much (actual=%d vs " | ||||
"limit=%d)\n", | "limit=%d)\n", | ||||
block.vtx[0]->GetValueOut(), blockReward); | block.vtx[0]->GetValueOut(), blockReward); | ||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | ||||
REJECT_INVALID, "bad-cb-amount"); | REJECT_INVALID, "bad-cb-amount"); | ||||
} | } | ||||
const std::vector<CTxDestination> whitelist = | |||||
GetMinerFundWhitelist(consensusParams, pindex->pprev); | |||||
if (!whitelist.empty()) { | |||||
const Amount required = blockReward / MINER_FUND_RATIO; | |||||
for (auto &o : block.vtx[0]->vout) { | |||||
if (o.nValue < required) { | |||||
// This output doesn't qualify because its amount is too low. | |||||
continue; | |||||
} | |||||
CTxDestination address; | |||||
if (!ExtractDestination(o.scriptPubKey, address)) { | |||||
// Cannot decode address. | |||||
continue; | |||||
} | |||||
if (std::find(whitelist.begin(), whitelist.end(), address) != | |||||
whitelist.end()) { | |||||
goto MinerFundSuccess; | |||||
} | |||||
} | |||||
// We did not find an output that match the miner fund requirements. | |||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | |||||
REJECT_INVALID, "bad-cb-minerfund"); | |||||
} | |||||
MinerFundSuccess: | |||||
if (!control.Wait()) { | if (!control.Wait()) { | ||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | ||||
REJECT_INVALID, "blk-bad-inputs", | REJECT_INVALID, "blk-bad-inputs", | ||||
"parallel script check failed"); | "parallel script check failed"); | ||||
} | } | ||||
int64_t nTime4 = GetTimeMicros(); | int64_t nTime4 = GetTimeMicros(); | ||||
nTimeVerify += nTime4 - nTime2; | nTimeVerify += nTime4 - nTime2; | ||||
▲ Show 20 Lines • Show All 3,813 Lines • Show Last 20 Lines |