Added Testing POW Check
@@ -2532,7 +2532,54 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c
} else {
if(fDebug) { printf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", pindexBest->nHeight+1, GetHash().ToString().c_str()); }
}
+ }else if(IsProofOfWork() && pindex != NULL){
+ if(pindex->GetBlockHash() == hashPrevBlock){
+ CAmount masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, 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;
+
+ CScript payee;
+ if(!masternodePayments.GetBlockPayee(pindexBest->nHeight+1, payee) || payee == CScript()){
+ foundPayee = true; //doesn't require a specific payee
+ foundPaymentAmount = true;
+ foundPaymentAndPayee = true;
+ if(fDebug) { printf("CheckBlock() : Using non-specific masternode payments %d\n", pindexBest->nHeight+1); }
+ }
+
+ for (unsigned int i = 0; i < vtx[0].vout.size(); i++) {
+ if(vtx[0].vout[i].nValue == masternodePaymentAmount )
+ foundPaymentAmount = true;
+ if(vtx[0].vout[i].scriptPubKey == payee )
+ foundPayee = true;
+ if(vtx[0].vout[i].nValue == masternodePaymentAmount && vtx[0].vout[i].scriptPubKey == payee)
+ foundPaymentAndPayee = true;
+ }
+
+ if(!foundPaymentAndPayee) {
+ CTxDestination address1;
+ ExtractDestination(payee, address1);
+ CBitcoinAddress address2(address1);
+
+ if(fDebug) { printf("CheckBlock() : Couldn't find masternode payment(%d|%ld) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), pindexBest->nHeight+1); }
+ return DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
+ } else {
+ if(fDebug) { printf("CheckBlock() : Found masternode payment %d\n", pindexBest->nHeight+1); }
+ }
+ } else {
+ if(fDebug) { printf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", pindexBest->nHeight+1); }
+ }
} else {
+ if(fDebug) { printf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", pindexBest->nHeight+1, GetHash().ToString().c_str()); }
+ }
+ }
+
+ else {
if(fDebug) { printf("CheckBlock() : pindex is null, skipping masternode payment check\n"); }
}
} else {
