Unverified Commit 18582bdf authored by squbs's avatar squbs

ignore initialdownload for validation

parent 1130a88a
......@@ -2198,86 +2198,84 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
//Masternode Payment Assurance (MPA)
if(pindex->nHeight > chainparams.GetConsensus().MasternodePaymentStartHeight + 7475)
{
if (!IsInitialBlockDownload()) {
bool missingMNPayment = true;
bool incorrectMNPayment = false;
bool nonSpecific = false;
CScript payee;
if(!masternodePayments.GetBlockPayee(pindex->nHeight, payee)
|| payee == CScript()) {
nonSpecific = true;
}
else
{
CTxDestination txdestaddr;
ExtractDestination(payee, txdestaddr);
CStraksAddress address(txdestaddr);
bool missingMNPayment = true;
bool incorrectMNPayment = false;
bool nonSpecific = false;
CScript payee;
LogPrintf("MPA: block Masternode payee %s\n", address.ToString());
const CTransaction &tx = *(block.vtx[0]);
BOOST_FOREACH(const CTxOut& output, tx.vout) {
if (output.scriptPubKey == payee) {
LogPrintf("MPA: block Masternode payment %d\n", output.nValue);
//allow for fees as buffer over max mn payment
if(output.nValue == 0 || output.nValue > 620000000) {
incorrectMNPayment = true;
break;
} else {
missingMNPayment = false;
break;
}
if(!masternodePayments.GetBlockPayee(pindex->nHeight, payee)
|| payee == CScript()) {
nonSpecific = true;
}
else
{
CTxDestination txdestaddr;
ExtractDestination(payee, txdestaddr);
CStraksAddress address(txdestaddr);
LogPrintf("MPA: block Masternode payee %s\n", address.ToString());
const CTransaction &tx = *(block.vtx[0]);
BOOST_FOREACH(const CTxOut& output, tx.vout) {
if (output.scriptPubKey == payee) {
LogPrintf("MPA: block Masternode payment %d\n", output.nValue);
//allow for fees as buffer over max mn payment
if(output.nValue == 0 || output.nValue > 620000000) {
incorrectMNPayment = true;
break;
} else {
missingMNPayment = false;
break;
}
}
}
}
if(nonSpecific) {
const CTransaction &tx = *(block.vtx[0]);
if(nonSpecific) {
const CTransaction &tx = *(block.vtx[0]);
CAmount tVal =
GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) * 0.05;
CAmount nValue = block.vtx[0]->GetValueOut() - tVal;
CAmount tVal =
GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) * 0.05;
CAmount nValue = block.vtx[0]->GetValueOut() - tVal;
CAmount masternodeValue =
GetMasternodePayment(pindex->nHeight, nValue, chainparams.GetConsensus());
CAmount masternodeValue =
GetMasternodePayment(pindex->nHeight, nValue, chainparams.GetConsensus());
CAmount minerValue = nValue - masternodeValue;
missingMNPayment = false;
CAmount minerValue = nValue - masternodeValue;
//no registered nodes
if(masternodeValue == 0)
missingMNPayment = false;
else if(tx.vout.size() <3) {
LogPrintf("MPA: block coinbase transaction malformed: vouts=%d!\n", tx.vout.size());
missingMNPayment = true;
}
else
{
unsigned int blockRewardTargetCount = 0;
missingMNPayment = false;
BOOST_FOREACH(const CTxOut& output, tx.vout) {
if (output.scriptPubKey !=
Params().GetTreasuryRewardScriptAtHeight(pindex->nHeight) && output.scriptPubKey != CScript())
{
if (output.nValue >= minerValue
|| output.nValue >= masternodeValue)
++blockRewardTargetCount;
}
}
//no registered nodes
if(masternodeValue == 0)
missingMNPayment = false;
else if(tx.vout.size() <3) {
LogPrintf("MPA: block coinbase transaction malformed: vouts=%d!\n", tx.vout.size());
missingMNPayment = true;
}
else
{
unsigned int blockRewardTargetCount = 0;
if(blockRewardTargetCount != 2) {
LogPrintf("MPA: block coinbase transaction invalid non-zero vouts: %d\n", blockRewardTargetCount);
missingMNPayment = true;
BOOST_FOREACH(const CTxOut& output, tx.vout) {
if (output.scriptPubKey !=
Params().GetTreasuryRewardScriptAtHeight(pindex->nHeight) && output.scriptPubKey != CScript())
{
if (output.nValue >= minerValue
|| output.nValue >= masternodeValue)
++blockRewardTargetCount;
}
}
}
if (missingMNPayment || incorrectMNPayment) {
return state.DoS(100, error("%s: missing(%d) and/or incorrect(%d) masternode payment", __func__, missingMNPayment, incorrectMNPayment), REJECT_INVALID, "cb-missing-mn-payment");
if(blockRewardTargetCount != 2) {
LogPrintf("MPA: block coinbase transaction invalid non-zero vouts: %d\n", blockRewardTargetCount);
missingMNPayment = true;
}
}
}
if (missingMNPayment || incorrectMNPayment) {
return state.DoS(100, error("%s: missing(%d) and/or incorrect(%d) masternode payment", __func__, missingMNPayment, incorrectMNPayment), REJECT_INVALID, "cb-missing-mn-payment");
}
}
int64_t nTime2 = GetTimeMicros();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment