Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,139 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, | ||||
"bad-cb-amount"); | "bad-cb-amount"); | ||||
} | } | ||||
const auto whitelist = | if (!CheckMinerFund(consensusParams, pindex->pprev, block.vtx[0]->vout, | ||||
GetMinerFundWhitelist(consensusParams, pindex->pprev); | blockReward)) { | ||||
if (!whitelist.empty()) { | |||||
const Amount required = GetMinerFundAmount(blockReward); | |||||
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, | return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | ||||
"bad-cb-minerfund"); | "bad-cb-minerfund"); | ||||
} | } | ||||
MinerFundSuccess: | |||||
if (!control.Wait()) { | if (!control.Wait()) { | ||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, | ||||
"blk-bad-inputs", "parallel script check failed"); | "blk-bad-inputs", "parallel script check failed"); | ||||
} | } | ||||
int64_t nTime4 = GetTimeMicros(); | int64_t nTime4 = GetTimeMicros(); | ||||
nTimeVerify += nTime4 - nTime2; | nTimeVerify += nTime4 - nTime2; | ||||
LogPrint( | LogPrint( | ||||
▲ Show 20 Lines • Show All 3,915 Lines • Show Last 20 Lines |