From 7037f7c999f199f1186249918201d95a6fb290d9 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Thu, 6 Dec 2018 08:05:57 +0100 Subject: [PATCH] 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. --- src/masternode-payments.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 3ec15f7c1b..2c14bc1eb5 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -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;