diff --git a/src/budget/budgetmanager.cpp b/src/budget/budgetmanager.cpp index d04bb2e29ed7..87228855a354 100644 --- a/src/budget/budgetmanager.cpp +++ b/src/budget/budgetmanager.cpp @@ -401,17 +401,12 @@ int CBudgetManager::GetHighestVoteCount(int chainHeight) const bool CBudgetManager::GetPayeeAndAmount(int chainHeight, CScript& payeeRet, CAmount& nAmountRet) const { - const CFinalizedBudget* pfb = GetBudgetWithHighestVoteCount(chainHeight); - if (!pfb) return false; - - // Check that there are enough votes - int mnCount = mnodeman.CountEnabled(ActiveProtocol()); - int nFivePercent = mnCount / 20; - if ((nFivePercent == 0 && !(Params().IsRegTestNet() && mnCount > 0) ) || - pfb->GetVoteCount() < nFivePercent) + int nCountThreshold; + if (!IsBudgetPaymentBlock(chainHeight, nCountThreshold)) return false; - return pfb->GetPayeeAndAmount(chainHeight, payeeRet, nAmountRet); + const CFinalizedBudget* pfb = GetBudgetWithHighestVoteCount(chainHeight); + return pfb && pfb->GetPayeeAndAmount(chainHeight, payeeRet, nAmountRet) && pfb->GetVoteCount() > nCountThreshold; } bool CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, const int nHeight, bool fProofOfStake) const diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 5c283ece3c80..f084a967615c 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -295,10 +295,9 @@ void FillBlockPayee(CMutableTransaction& txNew, const int nHeight, bool fProofOf { if (nHeight == 0) return; - if (!sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled - !g_budgetman.IsBudgetPaymentBlock(nHeight) || // or this is not a superblock - !g_budgetman.FillBlockPayee(txNew, nHeight, fProofOfStake) ) { // or there's no budget with enough votes - // pay a masternode + if (!sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled + !g_budgetman.FillBlockPayee(txNew, nHeight, fProofOfStake) ) { // or this is not a superblock, + // ... or there's no budget with enough votes, then pay a masternode masternodePayments.FillBlockPayee(txNew, nHeight, fProofOfStake); } }