From 792c5b822a0e85d224b3d1292455141e35c4fbf8 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 7 Sep 2015 20:39:34 +0300 Subject: [PATCH] fix: GetRemainingPaymentCount was off by 1 --- src/masternode-budget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index b764cf24c11e..303413cd982e 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -1487,10 +1487,9 @@ int CBudgetProposal::GetTotalPaymentCount() int CBudgetProposal::GetRemainingPaymentCount() { // If this budget starts in the future, this value will be wrong - int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / GetBudgetPaymentCycleBlocks(); - int nTotal = (GetBlockEndCycle() - GetBlockStartCycle()) / GetBudgetPaymentCycleBlocks(); + int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / GetBudgetPaymentCycleBlocks() - 1; // Take the lowest value - return (nPayments <= nTotal ? nPayments : nTotal); + return std::min(nPayments, GetTotalPaymentCount()); } CBudgetProposalBroadcast::CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn)