55
66#include " masternode-payments.h"
77
8+ #include " budget/budgetmanager.h"
89#include " chainparams.h"
910#include " evo/deterministicmns.h"
1011#include " fs.h"
11- #include " budget/budgetmanager.h"
1212#include " masternodeman.h"
1313#include " netmessagemaker.h"
14- #include " tiertwo/netfulfilledman.h"
1514#include " spork.h"
15+ #include " sporkid.h"
1616#include " sync.h"
17+ #include " tiertwo/netfulfilledman.h"
1718#include " tiertwo/tiertwo_sync_state.h"
1819#include " util/system.h"
1920#include " utilmoneystr.h"
@@ -228,16 +229,25 @@ bool IsBlockPayeeValid(const CBlock& block, const CBlockIndex* pindexPrev)
228229{
229230 int nBlockHeight = pindexPrev->nHeight + 1 ;
230231 TrxValidationStatus transactionStatus = TrxValidationStatus::InValid;
232+ const bool isV6UpgradeEnforced = Params ().GetConsensus ().NetworkUpgradeActive (nBlockHeight, Consensus::UPGRADE_V6_0);
233+ const bool isLegacyObsolete = deterministicMNManager->LegacyMNObsolete (nBlockHeight);
234+
235+ const bool fPayCoinstake = Params ().GetConsensus ().NetworkUpgradeActive (nBlockHeight, Consensus::UPGRADE_POS) &&
236+ !isV6UpgradeEnforced;
237+ const CTransaction& txNew = *(fPayCoinstake ? block.vtx [1 ] : block.vtx [0 ]);
238+
239+ // If v6 is enforced and legacy mns are obsolete even not-synced nodes can check dmns reward
240+ if (!g_tiertwo_sync_state.IsSynced () && isV6UpgradeEnforced && isLegacyObsolete) {
241+ // This is a possible superblock cannot check anything: (TODO: update for single superblock payment)
242+ if (nBlockHeight % Params ().GetConsensus ().nBudgetCycleBlocks < 100 ) return true ;
243+ return CheckMasternodePayee (txNew, pindexPrev);
244+ }
231245
232246 if (!g_tiertwo_sync_state.IsSynced ()) { // there is no budget data to use to check anything -- find the longest chain
233247 LogPrint (BCLog::MASTERNODE, " Client not synced, skipping block payee checks\n " );
234248 return true ;
235249 }
236250
237- const bool fPayCoinstake = Params ().GetConsensus ().NetworkUpgradeActive (nBlockHeight, Consensus::UPGRADE_POS) &&
238- !Params ().GetConsensus ().NetworkUpgradeActive (nBlockHeight, Consensus::UPGRADE_V6_0);
239- const CTransaction& txNew = *(fPayCoinstake ? block.vtx [1 ] : block.vtx [0 ]);
240-
241251 // check if it's a budget block
242252 if (sporkManager.IsSporkActive (SPORK_13_ENABLE_SUPERBLOCKS)) {
243253 if (g_budgetman.IsBudgetPaymentBlock (nBlockHeight)) {
@@ -262,17 +272,21 @@ bool IsBlockPayeeValid(const CBlock& block, const CBlockIndex* pindexPrev)
262272 // In all cases a masternode will get the payment for this block
263273
264274 // check for masternode payee
275+ return CheckMasternodePayee (txNew, pindexPrev);
276+ }
277+
278+ bool CheckMasternodePayee (const CTransaction& txNew, const CBlockIndex* pindexPrev)
279+ {
265280 if (masternodePayments.IsTransactionValid (txNew, pindexPrev))
266281 return true ;
267- LogPrint (BCLog::MASTERNODE," Invalid mn payment detected %s\n " , txNew.ToString ().c_str ());
282+ LogPrint (BCLog::MASTERNODE, " Invalid mn payment detected %s\n " , txNew.ToString ().c_str ());
268283
269284 if (sporkManager.IsSporkActive (SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))
270285 return false ;
271- LogPrint (BCLog::MASTERNODE," Masternode payment enforcement is disabled, accepting block\n " );
286+ LogPrint (BCLog::MASTERNODE, " Masternode payment enforcement is disabled, accepting block\n " );
272287 return true ;
273288}
274289
275-
276290void FillBlockPayee (CMutableTransaction& txCoinbase, CMutableTransaction& txCoinstake, const CBlockIndex* pindexPrev, bool fProofOfStake )
277291{
278292 if (!sporkManager.IsSporkActive (SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled
0 commit comments