MCPcopy Create free account
hub / github.com/LUX-Core/lux / CheckForMasternodePayment

Function CheckForMasternodePayment

src/main.cpp:4306–4442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4304}
4305
4306bool CheckForMasternodePayment(const CTransaction& tx, const CBlockHeader& header) {
4307 // Regular transactions don't have to share anything with masternodes
4308 if (!tx.IsCoinGenerated())
4309 return true;
4310
4311 const CChainParams& chainParams = Params();
4312
4313 // Special check for genesis block, which is guaranteed to not have a masternode payment
4314 if (header.GetHash() == chainParams.HashGenesisBlock())
4315 return true;
4316
4317 // Not required for testnet - only optional
4318 if (chainParams.NetworkID() == CBaseChainParams::TESTNET)
4319 return true;
4320
4321 const CBlockIndex* pindexPrev = LookupBlockIndex(header.hashPrevBlock);
4322 const int nHeight = pindexPrev ? pindexPrev->nHeight + 1 : 0;
4323
4324 //Skip for mint
4325
4326 if (nHeight == chainParams.PreminePayment()) {
4327 return true;
4328 }
4329
4330 // Check if a block is already accepted. These blocks cannot be checked for masternode payments,
4331 // because we don't know, which masternodes is active at that moment of accepting this block,
4332 // so that why we can't verify if tx from this block was actually rewards the masternode and doesn't
4333 // simply split the block subsidy which AFAIK and some pools do.
4334 // So, if we found a block in the block index, then return true as if this tx has a valid masternode payment.
4335 const CBlockIndex* pindex = LookupBlockIndex(header.GetHash(nHeight));
4336 if (pindex)
4337 return true;
4338
4339 uint32_t mnPaymentsStartDate = 0;
4340
4341 // Give us 8k blocks to start a MN
4342 if (Params().NetworkID() == CBaseChainParams::REGTEST) {
4343 if (nHeight <= 8000) return true;
4344 }
4345
4346
4347 if (chainParams.NetworkID() == CBaseChainParams::TESTNET/*|| chainParams.NetworkID() == CBaseChainParams::REGTEST*/) {
4348 mnPaymentsStartDate = START_MASTERNODE_PAYMENTS_TESTNET;
4349 // avoid the few testnet blocks without reward due to temporary lack of online MN
4350 if (nHeight == 3241 || nHeight == 3777 || nHeight == 5072) return true;
4351 if (nHeight >= 7494 && nHeight <= 7660) return true;
4352 } else {
4353 mnPaymentsStartDate = START_MASTERNODE_PAYMENTS;
4354 }
4355 // If masternode payments haven't started yet, then everything is OK
4356 if (header.nTime < mnPaymentsStartDate)
4357 return true;
4358
4359 // Calculate total reward and find masternode payment txout
4360 CAmount totalReward = 0, masternodePayment = 0;
4361 if (tx.IsCoinStake()) {
4362 totalReward = GetProofOfStakeReward(0, nHeight);
4363 } else {

Callers 1

CheckBlockFunction · 0.85

Calls 15

LookupBlockIndexFunction · 0.85
GetProofOfStakeRewardFunction · 0.85
GetProofOfWorkRewardFunction · 0.85
GetTimeFunction · 0.85
GetScriptForDestinationFunction · 0.85
GetMasternodePosRewardFunction · 0.85
NetworkIDMethod · 0.80
PreminePaymentMethod · 0.80
FirstSplitRewardBlockMethod · 0.80
FirstSCBlockMethod · 0.80
StartDevfeeBlockMethod · 0.80
ParamsClass · 0.70

Tested by

no test coverage detected