Skip to content
This repository was archived by the owner on Jul 23, 2021. It is now read-only.
Merged
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
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2656,6 +2656,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c
// Check PoW or PoS payments for current block
for (unsigned int i=0; i < vtx[isProofOfStake].vout.size(); i++) {
// Define values
CScript rawPayee = vtx[isProofOfStake].vout[i].scriptPubKey;
CTxDestination address;
ExtractDestination(vtx[isProofOfStake].vout[i].scriptPubKey, address);
CBitcoinAddress addressOut(address);
Expand All@@ -2667,7 +2668,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c
if (isProofOfStake) {
// Check for PoS masternode payment
if (i == nProofOfIndexMasternode) {
if (addressOut.ToString() == loggedpayee) {
if (mnodeman.IsPayeeAValidMasternode(rawPayee)) {
LogPrintf("CheckBlock() : PoS Recipient masternode address validity succesfully verified\n");
} else {
LogPrintf("CheckBlock() : PoS Recipient masternode address validity could not be verified\n");
Expand DownExpand Up@@ -2700,7 +2701,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c
else if (!isProofOfStake) {
// Check for PoW masternode payment
if (i == nProofOfIndexMasternode) {
if (addressOut.ToString() == loggedpayee) {
if (mnodeman.IsPayeeAValidMasternode(rawPayee)) {
LogPrintf("CheckBlock() : PoW Recipient masternode address validity succesfully verified\n");
} else {
LogPrintf("CheckBlock() : PoW Recipient masternode address validity could not be verified\n");
Expand Down
20 changes: 20 additions & 0 deletions src/masternodeman.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -459,6 +459,26 @@ CMasternode* CMasternodeMan::GetCurrentMasterNode(int mod, int64_t nBlockHeight,
return winner;
}

bool CMasternodeMan::IsPayeeAValidMasternode(CScript payee)
{
if(!mnEnginePool.IsBlockchainSynced()) return true;

int mnCount = 0;
bool fValid = false;
BOOST_FOREACH(CMasternode& mn, vMasternodes) {

mn.Check();
mnCount++;
if(!mn.IsEnabled()) continue;

CScript currentMasternode = GetScriptForDestination(mn.pubkey.GetID());
LogPrintf("* Masternode %d - testing %s\n", mnCount, currentMasternode.ToString().c_str());
if(payee == currentMasternode)
fValid = true;
}
return fValid;
}

int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, int minProtocol, bool fOnlyActive)
{
std::vector<pair<unsigned int, CTxIn> > vecMasternodeScores;
Expand Down
2 changes: 2 additions & 0 deletions src/masternodeman.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,6 +126,8 @@ class CMasternodeMan
// Get the current winner for this block
CMasternode* GetCurrentMasterNode(int mod=1, int64_t nBlockHeight=0, int minProtocol=0);

bool IsPayeeAValidMasternode(CScript payee);

std::vector<CMasternode> GetFullMasternodeVector() { Check(); return vMasternodes; }

std::vector<pair<int, CMasternode> > GetMasternodeRanks(int64_t nBlockHeight, int minProtocol=0);
Expand Down
53 changes: 24 additions & 29 deletions src/rpcmining.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -674,35 +674,30 @@ Value getblocktemplate(const Array& params, bool fHelp)
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
result.push_back(Pair("votes", aVotes));

// TODO: Verify upgrade
if (nLiveForkToggle > 0)
{
if (pindexBest->nHeight > nLiveForkToggle)
{
// Include DevOps payments
CAmount devopsSplit = devopsPayment;
Object devopsReward;
devopsReward.push_back(Pair("devopspayee", Params().DevOpsAddress()));
devopsReward.push_back(Pair("amount", devopsSplit));
result.push_back(Pair("devopsreward", devopsReward));
result.push_back(Pair("devops_reward_enforced", true));

// Include Masternode payments
CAmount masternodeSplit = masternodePayment;
CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1);

if (winningNode) {
CScript payee = GetScriptForDestination(winningNode->pubkey.GetID());
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
result.push_back(Pair("payee", address2.ToString().c_str()));
result.push_back(Pair("payee_amount", (int64_t)masternodeSplit));
result.push_back(Pair("masternode_payments", true));
result.push_back(Pair("enforce_masternode_payments", true));
}
}
}
// Include DevOps payments
CAmount devopsSplit = devopsPayment;
Object devopsReward;
devopsReward.push_back(Pair("devopspayee", Params().DevOpsAddress()));
devopsReward.push_back(Pair("amount", devopsSplit));
result.push_back(Pair("devopsreward", devopsReward));
result.push_back(Pair("devops_reward_enforced", true));

// Include Masternode payments
CAmount masternodeSplit = masternodePayment;
CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1);

if (winningNode) {
CScript payee = GetScriptForDestination(winningNode->pubkey.GetID());
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
result.push_back(Pair("payee", address2.ToString().c_str()));
} else {
result.push_back(Pair("payee", Params().DevOpsAddress().c_str()));
}
result.push_back(Pair("payee_amount", (int64_t)masternodeSplit));
result.push_back(Pair("masternode_payments", true));
result.push_back(Pair("enforce_masternode_payments", true));

return result;
}
Expand Down
6 changes: 5 additions & 1 deletion src/wallet.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2889,6 +2889,10 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
txNew.vin.clear();
txNew.vout.clear();

// Determine our payment script for devops
CScript devopsScript;
devopsScript << OP_DUP << OP_HASH160 << ParseHex(Params().DevOpsPubKey()) << OP_EQUALVERIFY << OP_CHECKSIG;

// Mark coin stake transaction
CScript scriptEmpty;
scriptEmpty.clear();
Expand DownExpand Up@@ -3079,7 +3083,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
if(winningNode){
payee = GetScriptForDestination(winningNode->pubkey.GetID());
} else {
return error("CreateCoinStake: Failed to detect masternode to pay\n");
payee = devopsScript;
}
}
} else {
Expand Down