@@ -664,10 +664,11 @@ bool CBudgetManager::IsBudgetPaymentBlock(int nBlockHeight)
664664 return false ;
665665}
666666
667- bool CBudgetManager::IsTransactionValid (const CTransaction& txNew, int nBlockHeight)
667+ TrxValidationStatus CBudgetManager::IsTransactionValid (const CTransaction& txNew, int nBlockHeight)
668668{
669669 LOCK (cs);
670670
671+ TrxValidationStatus transactionStatus = TrxValidationStatus::InValid;
671672 int nHighestCount = 0 ;
672673 int nFivePercent = mnodeman.CountEnabled (ActiveProtocol ()) / 20 ;
673674 std::vector<CFinalizedBudget*> ret;
@@ -694,7 +695,7 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
694695 /*
695696 If budget doesn't have 5% of the network votes, then we should pay a masternode instead
696697 */
697- if (nHighestCount < nFivePercent) return false ;
698+ if (nHighestCount < nFivePercent) return TrxValidationStatus::InValid ;
698699
699700 // check the highest finalized budgets (+/- 10% to assist in consensus)
700701
@@ -713,9 +714,10 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
713714 LogPrint (" mnbudget" ," CBudgetManager::IsTransactionValid - GetVoteCount() > nCountThreshold passed\n " );
714715 if (nBlockHeight >= pfinalizedBudget->GetBlockStart () && nBlockHeight <= pfinalizedBudget->GetBlockEnd ()) {
715716 LogPrint (" mnbudget" ," CBudgetManager::IsTransactionValid - GetBlockStart() passed\n " );
716- if (pfinalizedBudget->IsTransactionValid (txNew, nBlockHeight)) {
717+ transactionStatus = pfinalizedBudget->IsTransactionValid (txNew, nBlockHeight);
718+ if (transactionStatus == TrxValidationStatus::Valid) {
717719 LogPrint (" mnbudget" ," CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() passed\n " );
718- return true ;
720+ return TrxValidationStatus::Valid ;
719721 }
720722 else {
721723 LogPrint (" mnbudget" ," CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() error\n " );
@@ -731,7 +733,7 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
731733 }
732734
733735 // we looked through all of the known budgets
734- return false ;
736+ return transactionStatus ;
735737}
736738
737739std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals ()
@@ -2107,20 +2109,20 @@ bool CFinalizedBudget::IsPaidAlready(uint256 nProposalHash, int nBlockHeight)
21072109 return true ;
21082110}
21092111
2110- bool CFinalizedBudget::IsTransactionValid (const CTransaction& txNew, int nBlockHeight)
2112+ TrxValidationStatus CFinalizedBudget::IsTransactionValid (const CTransaction& txNew, int nBlockHeight)
21112113{
2114+ TrxValidationStatus transactionStatus = TrxValidationStatus::InValid;
21122115 int nCurrentBudgetPayment = nBlockHeight - GetBlockStart ();
21132116 if (nCurrentBudgetPayment < 0 ) {
21142117 LogPrint (" mnbudget" ," CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n " , nBlockHeight, GetBlockStart ());
2115- return false ;
2118+ return TrxValidationStatus::InValid ;
21162119 }
21172120
21182121 if (nCurrentBudgetPayment > (int )vecBudgetPayments.size () - 1 ) {
21192122 LogPrint (" mnbudget" ," CFinalizedBudget::IsTransactionValid - Invalid last block - current budget payment: %d of %d\n " , nCurrentBudgetPayment + 1 , (int )vecBudgetPayments.size ());
2120- return false ;
2123+ return TrxValidationStatus::InValid ;
21212124 }
21222125
2123- bool found = false ;
21242126 bool paid = false ;
21252127
21262128 BOOST_FOREACH (CTxOut out, txNew.vout ) {
@@ -2136,18 +2138,18 @@ bool CFinalizedBudget::IsTransactionValid(const CTransaction& txNew, int nBlockH
21362138 vecBudgetPayments[nCurrentBudgetPayment].nAmount , vecBudgetPayments[nCurrentBudgetPayment].nProposalHash .Get32 ());
21372139 // No matter what we've found before, stop all checks here. In future releases there might be more than one budget payment
21382140 // per block, so even if the first one was not paid yet this one disables all budget payments for this block.
2139- found = false ;
2141+ transactionStatus = TrxValidationStatus::DoublePayment ;
21402142 break ;
21412143 }
21422144 else {
2143- found = true ;
2145+ transactionStatus = TrxValidationStatus::Valid ;
21442146 LogPrint (" mnbudget" ," CFinalizedBudget::IsTransactionValid - Found valid Budget Payment of %d for proposal %d\n " ,
21452147 vecBudgetPayments[nCurrentBudgetPayment].nAmount , vecBudgetPayments[nCurrentBudgetPayment].nProposalHash .Get32 ());
21462148 }
21472149 }
21482150 }
21492151
2150- if (!found ) {
2152+ if (transactionStatus == TrxValidationStatus::InValid ) {
21512153 CTxDestination address1;
21522154 ExtractDestination (vecBudgetPayments[nCurrentBudgetPayment].payee , address1);
21532155 CBitcoinAddress address2 (address1);
@@ -2156,7 +2158,7 @@ bool CFinalizedBudget::IsTransactionValid(const CTransaction& txNew, int nBlockH
21562158 address2.ToString (), vecBudgetPayments[nCurrentBudgetPayment].nAmount , nCurrentBudgetPayment);
21572159 }
21582160
2159- return found ;
2161+ return transactionStatus ;
21602162}
21612163
21622164void CFinalizedBudget::SubmitVote ()
0 commit comments