Bail out from GetBlockTxOuts in case nBlockHeight is above tip+1 (#2523)

In the future, we should make sure that this method is only called for the
currently mined block or for old blocks, but never for non-existing blocks
further in the future.
This commit is contained in:
Alexander Block 2018-12-06 08:05:57 +01:00 committed by GitHub
parent 3a6bd8d235
commit 7037f7c999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -595,6 +595,13 @@ bool CMasternodePayments::GetBlockTxOuts(int nBlockHeight, CAmount blockReward,
uint256 blockHash;
{
LOCK(cs_main);
if (nBlockHeight - 1 > chainActive.Height()) {
// there are some cases (e.g. IsScheduled) where legacy/compatibility code runs into this method with
// block heights above the chain tip. Return false in this case
// TODO remove this when removing the compatibility code and make sure this method is only called with
// correct block height
return false;
}
blockHash = chainActive[nBlockHeight - 1]->GetBlockHash();
}
uint256 proTxHash;