5
5
6
6
#include " masternode-payments.h"
7
7
8
+ #include " budget/budgetmanager.h"
8
9
#include " chainparams.h"
9
10
#include " evo/deterministicmns.h"
10
11
#include " fs.h"
11
- #include " budget/budgetmanager.h"
12
12
#include " masternodeman.h"
13
13
#include " netmessagemaker.h"
14
- #include " tiertwo/netfulfilledman.h"
15
14
#include " spork.h"
15
+ #include " sporkid.h"
16
16
#include " sync.h"
17
+ #include " tiertwo/netfulfilledman.h"
17
18
#include " tiertwo/tiertwo_sync_state.h"
18
19
#include " util/system.h"
19
20
#include " utilmoneystr.h"
@@ -228,16 +229,25 @@ bool IsBlockPayeeValid(const CBlock& block, const CBlockIndex* pindexPrev)
228
229
{
229
230
int nBlockHeight = pindexPrev->nHeight + 1 ;
230
231
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
+ }
231
245
232
246
if (!g_tiertwo_sync_state.IsSynced ()) { // there is no budget data to use to check anything -- find the longest chain
233
247
LogPrint (BCLog::MASTERNODE, " Client not synced, skipping block payee checks\n " );
234
248
return true ;
235
249
}
236
250
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
-
241
251
// check if it's a budget block
242
252
if (sporkManager.IsSporkActive (SPORK_13_ENABLE_SUPERBLOCKS)) {
243
253
if (g_budgetman.IsBudgetPaymentBlock (nBlockHeight)) {
@@ -262,17 +272,21 @@ bool IsBlockPayeeValid(const CBlock& block, const CBlockIndex* pindexPrev)
262
272
// In all cases a masternode will get the payment for this block
263
273
264
274
// check for masternode payee
275
+ return CheckMasternodePayee (txNew, pindexPrev);
276
+ }
277
+
278
+ bool CheckMasternodePayee (const CTransaction& txNew, const CBlockIndex* pindexPrev)
279
+ {
265
280
if (masternodePayments.IsTransactionValid (txNew, pindexPrev))
266
281
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 ());
268
283
269
284
if (sporkManager.IsSporkActive (SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))
270
285
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 " );
272
287
return true ;
273
288
}
274
289
275
-
276
290
void FillBlockPayee (CMutableTransaction& txCoinbase, CMutableTransaction& txCoinstake, const CBlockIndex* pindexPrev, bool fProofOfStake )
277
291
{
278
292
if (!sporkManager.IsSporkActive (SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled
0 commit comments