Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4004,16 +4004,6 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
}
}

// Check masternode payments
if (nHeight > GetSporkValue(SPORK_17_MASTERNODE_PAYMENT_CHECK) && block.IsProofOfStake()) {
const CTransaction& tx = block.vtx[1];
const unsigned int outs = tx.vout.size();
if (outs < 3)
return state.DoS(100, error("CheckBlock() : no payment for masternode found"));
if (!masternodePayments.ValidateMasternodeWinner(tx.vout[outs-1], nHeight))
return state.DoS(100, error("CheckBlock() : wrong masternode address"));
}

// Check transactions
bool fZerocoinActive = true;
vector<CBigNum> vBlockSerials;
Expand Down
25 changes: 2 additions & 23 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight)
return true;
LogPrint("masternode","Invalid mn payment detected %s\n", txNew.ToString().c_str());

if (IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))
if (IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) ||
(nHeight > GetSporkValue(SPORK_17_MASTERNODE_PAYMENT_CHECK))
return false;
LogPrint("masternode","Masternode payment enforcement is disabled, accepting block\n");

Expand Down Expand Up @@ -777,28 +778,6 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
return false;
}

bool CMasternodePayments::ValidateMasternodeWinner(const CTxOut& mnPaymentOut, int nBlockHeight)
{
int nCount = 0;
CScript payee;
if (!masternodePayments.GetBlockPayee(nBlockHeight, payee)) {
//no masternode detected

CMasternode* pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount);
if (pmn != nullptr) {
payee == GetScriptForDestination(pmn->pubKeyCollateralAddress.GetID());
}
}

CAmount nReward = GetBlockValue(nBlockHeight);
CAmount masternodePayment = GetMasternodePayment(nBlockHeight, nReward, nCount);
if (mnPaymentOut.scriptPubKey != payee)
LogPrintf("CMasternodePayments::ValidateMasternodeWinner() - script pubkey did not match\n");
if (mnPaymentOut.nValue < masternodePayment)
LogPrintf("CMasternodePayments::ValidateMasternodeWinner() - masternodePayment did not match\n");
return mnPaymentOut.nValue >= masternodePayment; // TODO: check mnpaymentOut.scriptPubKey == payee
}

void CMasternodePaymentWinner::Relay()
{
CInv inv(MSG_MASTERNODE_WINNER, GetHash());
Expand Down
2 changes: 0 additions & 2 deletions src/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ class CMasternodePayments
bool AddWinningMasternode(CMasternodePaymentWinner& winner);
bool ProcessBlock(int nBlockHeight);

bool ValidateMasternodeWinner(const CTxOut& mnPaymentOut, int nBlockHeight);

void Sync(CNode* node, int nCountNeeded);
void CleanPaymentList();
int LastPayment(CMasternode& mn);
Expand Down