@@ -2881,39 +2881,42 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
28812881 {
28822882 LOCK2 (cs_main, mempool.cs );
28832883
2884- if (chainActive.Tip ()->GetBlockHash () == block.hashPrevBlock ){
2885- int64_t masternodePaymentAmount = GetMasternodePayment (chainActive.Tip ()->nHeight +1 , block.vtx [0 ].GetValueOut ());
2886- bool fIsInitialDownload = IsInitialBlockDownload ();
2887-
2888- // If we don't already have its previous block, skip masternode payment step
2889- if (!fIsInitialDownload && chainActive.Tip () != NULL )
2890- {
2891- bool foundPaymentAmount = false ;
2892- bool foundPayee = false ;
2884+ CBlockIndex *pindex = chainActive.Tip ();
2885+ if (pindex != NULL ){
2886+ if (pindex->GetBlockHash () == block.hashPrevBlock ){
2887+ int64_t masternodePaymentAmount = GetMasternodePayment (pindex->nHeight +1 , block.vtx [0 ].GetValueOut ());
2888+ bool fIsInitialDownload = IsInitialBlockDownload ();
2889+
2890+ // If we don't already have its previous block, skip masternode payment step
2891+ if (!fIsInitialDownload && pindex != NULL )
2892+ {
2893+ bool foundPaymentAmount = false ;
2894+ bool foundPayee = false ;
28932895
2894- CScript payee;
2895- if (!masternodePayments.GetBlockPayee (chainActive.Tip ()->nHeight +1 , payee) || payee == CScript ()){
2896- foundPayee = true ; // doesn't require a specific payee
2897- }
2896+ CScript payee;
2897+ if (!masternodePayments.GetBlockPayee (chainActive.Tip ()->nHeight +1 , payee) || payee == CScript ()){
2898+ foundPayee = true ; // doesn't require a specific payee
2899+ }
28982900
2899- for (unsigned int i = 0 ; i < block.vtx [0 ].vout .size (); i++) {
2900- if (block.vtx [0 ].vout [i].nValue == masternodePaymentAmount )
2901- foundPaymentAmount = true ;
2902- if (block.vtx [0 ].vout [i].scriptPubKey == payee )
2903- foundPayee = true ;
2904- }
2901+ for (unsigned int i = 0 ; i < block.vtx [0 ].vout .size (); i++) {
2902+ if (block.vtx [0 ].vout [i].nValue == masternodePaymentAmount )
2903+ foundPaymentAmount = true ;
2904+ if (block.vtx [0 ].vout [i].scriptPubKey == payee )
2905+ foundPayee = true ;
2906+ }
29052907
2906- if (!foundPaymentAmount || !foundPayee) {
2907- CTxDestination address1;
2908- ExtractDestination (payee, address1);
2909- CBitcoinAddress address2 (address1);
2908+ if (!foundPaymentAmount || !foundPayee) {
2909+ CTxDestination address1;
2910+ ExtractDestination (payee, address1);
2911+ CBitcoinAddress address2 (address1);
29102912
2911- 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 );
2912- return state.DoS (100 , error (" CheckBlock() : Couldn't find masternode payment or payee" ));
2913+ 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 );
2914+ return state.DoS (100 , error (" CheckBlock() : Couldn't find masternode payment or payee" ));
2915+ }
29132916 }
2917+ } else {
2918+ LogPrintf (" CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n " , chainActive.Tip ()->nHeight +1 , block.GetHash ().ToString ().c_str ());
29142919 }
2915- } else {
2916- LogPrintf (" CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n " , chainActive.Tip ()->nHeight +1 , block.GetHash ().ToString ().c_str ());
29172920 }
29182921 }
29192922
0 commit comments