From c15622b995c8413c1d265a691340eb9e6907f60d Mon Sep 17 00:00:00 2001 From: presstab Date: Wed, 4 Jan 2017 16:16:44 -0700 Subject: [PATCH 1/6] undo bad assignment of mn payment from 0084cc8 --- src/masternode-payments.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 2ce807b29674..839d8a3f9dd1 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -313,8 +313,6 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe CAmount blockValue = GetBlockValue(pindexPrev->nHeight); CAmount masternodePayment = GetMasternodePayment(pindexPrev->nHeight, blockValue); - txNew.vout[0].nValue = blockValue; - if(hasPayment) { if(fProofOfStake) @@ -330,7 +328,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe txNew.vout.resize(2); txNew.vout[1].scriptPubKey = payee; txNew.vout[1].nValue = masternodePayment; - txNew.vout[0].nValue -= masternodePayment; + txNew.vout[0].nValue = blockValue - masternodePayment; } CTxDestination address1; From cfea2cd0b0e20e094783fe2211dbb01d6447de54 Mon Sep 17 00:00:00 2001 From: presstab Date: Thu, 5 Jan 2017 10:26:47 -0700 Subject: [PATCH 2/6] use correct datatypes to fix Missing Required Payment error --- src/masternode-payments.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 839d8a3f9dd1..48fe51b71b51 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -12,6 +12,7 @@ #include "sync.h" #include "spork.h" #include "addrman.h" +#include "utilmoneystr.h" #include #include @@ -517,8 +518,8 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) int nMaxSignatures = 0; std::string strPayeesPossible = ""; - uint64_t nReward; - uint64_t masternodePayment; + CAmount nReward; + CAmount masternodePayment; nReward = GetBlockValue(nBlockHeight); masternodePayment = GetMasternodePayment(nBlockHeight, nReward); @@ -535,7 +536,8 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) BOOST_FOREACH(CMasternodePayee& payee, vecPayments) { bool found = false; - BOOST_FOREACH(CTxOut out, txNew.vout){ + BOOST_FOREACH(CTxOut out, txNew.vout) + { if(payee.scriptPubKey == out.scriptPubKey && masternodePayment == out.nValue){ found = true; } @@ -557,7 +559,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) } - LogPrintf("CMasternodePayments::IsTransactionValid - Missing required payment - %s\n", strPayeesPossible.c_str()); + LogPrintf("CMasternodePayments::IsTransactionValid - Missing required payment of %s to %s\n", FormatMoney(masternodePayment).c_str(),strPayeesPossible.c_str()); return false; } From e569b6fcfaf8e2e94d6e6420cd4586e8bc209eac Mon Sep 17 00:00:00 2001 From: presstab Date: Thu, 5 Jan 2017 10:28:08 -0700 Subject: [PATCH 3/6] undo testnet only miner code --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index cbdf21d60048..0dd86d3be049 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -494,7 +494,7 @@ void BitcoinMiner(CWallet *pwallet, bool fProofOfStake) continue; } - while (chainActive.Tip()->nTime < 1471482000 /*|| vNodes.empty()*/ || pwallet->IsLocked() || !fMintableCoins || nReserveBalance >= pwallet->GetBalance() /*|| !masternodeSync.IsSynced()*/) + while (chainActive.Tip()->nTime < 1471482000 || vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || nReserveBalance >= pwallet->GetBalance() || !masternodeSync.IsSynced()) { nLastCoinStakeSearchInterval = 0; MilliSleep(5000); From 826c1a6554d77cefeb92f3df7420e228203edcdd Mon Sep 17 00:00:00 2001 From: presstab Date: Thu, 5 Jan 2017 11:00:42 -0700 Subject: [PATCH 4/6] if masternode is overpaid it is still valid pmt --- src/masternode-payments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 48fe51b71b51..a94b9509d7bc 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -538,7 +538,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) bool found = false; BOOST_FOREACH(CTxOut out, txNew.vout) { - if(payee.scriptPubKey == out.scriptPubKey && masternodePayment == out.nValue){ + if(payee.scriptPubKey == out.scriptPubKey && masternodePayment >= out.nValue){ found = true; } } From d90326b296a56937ebc93e918cab0e3befeac84a Mon Sep 17 00:00:00 2001 From: presstab Date: Thu, 5 Jan 2017 11:18:16 -0700 Subject: [PATCH 5/6] if masternode is overpaid it is still valid pmt --- src/masternode-payments.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index a94b9509d7bc..ba02b39d1743 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -518,14 +518,10 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) int nMaxSignatures = 0; std::string strPayeesPossible = ""; - CAmount nReward; - CAmount masternodePayment; - - nReward = GetBlockValue(nBlockHeight); - masternodePayment = GetMasternodePayment(nBlockHeight, nReward); + CAmount nReward = GetBlockValue(nBlockHeight); + CAmount requiredMasternodePayment = GetMasternodePayment(nBlockHeight, nReward); //require at least 6 signatures - BOOST_FOREACH(CMasternodePayee& payee, vecPayments) if(payee.nVotes >= nMaxSignatures && payee.nVotes >= MNPAYMENTS_SIGNATURES_REQUIRED) nMaxSignatures = payee.nVotes; @@ -538,7 +534,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) bool found = false; BOOST_FOREACH(CTxOut out, txNew.vout) { - if(payee.scriptPubKey == out.scriptPubKey && masternodePayment >= out.nValue){ + if(payee.scriptPubKey == out.scriptPubKey && out.nValue >= requiredMasternodePayment){ found = true; } } @@ -559,7 +555,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) } - LogPrintf("CMasternodePayments::IsTransactionValid - Missing required payment of %s to %s\n", FormatMoney(masternodePayment).c_str(),strPayeesPossible.c_str()); + LogPrintf("CMasternodePayments::IsTransactionValid - Missing required payment of %s to %s\n", FormatMoney(requiredMasternodePayment).c_str(),strPayeesPossible.c_str()); return false; } From 2bcb5a8345a570efcef503c93d81685ad3132b63 Mon Sep 17 00:00:00 2001 From: presstab Date: Thu, 5 Jan 2017 20:36:50 -0700 Subject: [PATCH 6/6] add comments to FillBlockPayee --- src/masternode-payments.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index ba02b39d1743..37ac64f21108 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -318,10 +318,17 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe { if(fProofOfStake) { + /**For Proof Of Stake vout[0] must be null + * Stake reward can be split into many different outputs, so we must + * use vout.size() to align with several different cases. + * An additional output is appended as the masternode payment + */ unsigned int i = txNew.vout.size(); txNew.vout.resize(i + 1); txNew.vout[i].scriptPubKey = payee; txNew.vout[i].nValue = masternodePayment; + + //subtract mn payment from the stake reward txNew.vout[i - 1].nValue -= masternodePayment; } else @@ -336,7 +343,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe ExtractDestination(payee, address1); CBitcoinAddress address2(address1); - LogPrintf("Masternode payment to %s\n", address2.ToString().c_str()); + LogPrintf("Masternode payment of %s to %s\n", FormatMoney(masternodePayment).c_str(), address2.ToString().c_str()); } }