diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index ddb2a69091..6fd3f5bf5e 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -56,6 +56,7 @@ namespace Checkpoints ( 137993, uint256("0x00000000000cf69ce152b1bffdeddc59188d7a80879210d6e5c9503011929c3c")) ( 167996, uint256("0x000000000009486020a80f7f2cc065342b0c2fb59af5e090cd813dba68ab0fed")) ( 207992, uint256("0x00000000000d85c22be098f74576ef00b7aa00c05777e966aff68a270f1e01a5")) + ( 217752, uint256("0x00000000000a7baeb2148272a7e14edf5af99a64af456c0afc23d15a0918b704")) ; static const CCheckpointData data = { &mapCheckpoints, diff --git a/src/main.cpp b/src/main.cpp index 07e184cc7e..a0785c7f02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2867,60 +2867,64 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo if(fDebug) LogPrintf("CheckBlock() : Masternode payment enforcement is off\n"); } - if(MasternodePayments && !fLargeWorkForkFound && !fLargeWorkInvalidChainFound) - { - LOCK2(cs_main, mempool.cs); + if(!fLargeWorkForkFound && !fLargeWorkInvalidChainFound){ + if(MasternodePayments) + { + LOCK2(cs_main, mempool.cs); - CBlockIndex *pindex = chainActive.Tip(); - if(pindex != NULL){ - if(pindex->GetBlockHash() == block.hashPrevBlock){ - int64_t masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, block.vtx[0].GetValueOut()); - bool fIsInitialDownload = IsInitialBlockDownload(); + CBlockIndex *pindex = chainActive.Tip(); + if(pindex != NULL){ + if(pindex->GetBlockHash() == block.hashPrevBlock){ + int64_t masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, block.vtx[0].GetValueOut()); + bool fIsInitialDownload = IsInitialBlockDownload(); - // If we don't already have its previous block, skip masternode payment step - if (!fIsInitialDownload && pindex != NULL) - { - bool foundPaymentAmount = false; - bool foundPayee = false; - bool foundPaymentAndPayee = false; + // If we don't already have its previous block, skip masternode payment step + if (!fIsInitialDownload && pindex != NULL) + { + bool foundPaymentAmount = false; + bool foundPayee = false; + bool foundPaymentAndPayee = false; - CScript payee; - if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){ - foundPayee = true; //doesn't require a specific payee - foundPaymentAmount = true; - foundPaymentAndPayee = true; - LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", chainActive.Tip()->nHeight+1); - } - - for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) { - if(block.vtx[0].vout[i].nValue == masternodePaymentAmount ) + CScript payee; + if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){ + foundPayee = true; //doesn't require a specific payee foundPaymentAmount = true; - if(block.vtx[0].vout[i].scriptPubKey == payee ) - foundPayee = true; - if(block.vtx[0].vout[i].nValue == masternodePaymentAmount && block.vtx[0].vout[i].scriptPubKey == payee) foundPaymentAndPayee = true; - } + LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", chainActive.Tip()->nHeight+1); + } - if(!foundPaymentAndPayee) { - CTxDestination address1; - ExtractDestination(payee, address1); - CBitcoinAddress address2(address1); + for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) { + if(block.vtx[0].vout[i].nValue == masternodePaymentAmount ) + foundPaymentAmount = true; + if(block.vtx[0].vout[i].scriptPubKey == payee ) + foundPayee = true; + if(block.vtx[0].vout[i].nValue == masternodePaymentAmount && block.vtx[0].vout[i].scriptPubKey == payee) + foundPaymentAndPayee = true; + } - LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1); - if(!RegTest()) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee")); + if(!foundPaymentAndPayee) { + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); + + LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1); + if(!RegTest()) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee")); + } else { + LogPrintf("CheckBlock() : Found masternode payment %d\n", chainActive.Tip()->nHeight+1); + } } else { - LogPrintf("CheckBlock() : Found masternode payment %d\n", chainActive.Tip()->nHeight+1); + LogPrintf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", chainActive.Tip()->nHeight+1); } } else { - LogPrintf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", chainActive.Tip()->nHeight+1); + LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str()); } } else { - LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str()); + LogPrintf("CheckBlock() : pindex is null, skipping masternode payment check\n"); } } else { - LogPrintf("CheckBlock() : pindex is null, skipping masternode payment check\n"); + LogPrintf("CheckBlock() : skipping masternode payment checks\n"); } - } else { + } else { LogPrintf("CheckBlock() : fork detected, skipping masternode payment checks\n"); }