diff --git a/src/governance-classes.cpp b/src/governance-classes.cpp index 5c54fb78e7..ee7a10e583 100644 --- a/src/governance-classes.cpp +++ b/src/governance-classes.cpp @@ -350,6 +350,10 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight) bool CSuperblockManager::GetBestSuperblock(CSuperblock_sptr& pBlock, int nBlockHeight) { + if(!CSuperblock::IsValidBlockHeight(nBlockHeight)) { + return false; + } + AssertLockHeld(governance.cs); std::vector vecTriggers = triggerman.GetActiveTriggers(); int nYesCount = 0; @@ -633,6 +637,10 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b // internal to *this and since CSuperblock's are accessed only through // shared pointers there's no way our object can get deleted while this // code is running. + if(!IsValidBlockHeight(nBlockHeight)) { + LogPrintf("CSuperblock::IsValid -- ERROR: Block invalid, incorrect block height\n"); + return false; + } std::string strPayeesPossible = ""; diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index d4d6e81673..5b2ca644c7 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -185,9 +185,9 @@ bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount bloc void FillBlockPayee(CMutableTransaction& txNew, CAmount blockReward, int nBlockHeight) { - // only create superblocks after hardfork block AND if spork is enabled AND if superblock is actually triggered - if(nBlockHeight > Params().GetConsensus().nSuperblockStartBlock && - sporkManager.IsSporkActive(SPORK_9_MASTERNODE_SUPERBLOCK_ENFORCEMENT) && + // only create superblocks if spork is enabled AND if superblock is actually triggered + // (height should be validated inside) + if(sporkManager.IsSporkActive(SPORK_9_MASTERNODE_SUPERBLOCK_ENFORCEMENT) && CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { LogPrint("gobject", "FillBlockPayee -- triggered superblock creation at height %d\n", nBlockHeight); CSuperblockManager::CreateSuperblock(txNew, nBlockHeight); @@ -200,15 +200,12 @@ void FillBlockPayee(CMutableTransaction& txNew, CAmount blockReward, int nBlockH std::string GetRequiredPaymentsString(int nBlockHeight) { - // IF THIS HEIGHT IS A SUPERBLOCK, GET THE REQUIRED PAYEES - + // IF WE HAVE A ACTIVATED TRIGGER FOR THIS HEIGHT - IT IS A SUPERBLOCK, GET THE REQUIRED PAYEES if(CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { - // IF WE HAVE A ACTIVATED TRIGGER return CSuperblockManager::GetRequiredPaymentsString(nBlockHeight); } // OTHERWISE, PAY MASTERNODE - return mnpayments.GetRequiredPaymentsString(nBlockHeight); }