Skip to content
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
29 changes: 16 additions & 13 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "sync.h"
#include "spork.h"
#include "addrman.h"
#include "utilmoneystr.h"
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>

Expand Down Expand Up @@ -313,31 +314,36 @@ 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)
{
/**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
{
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;
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());
}
}

Expand Down Expand Up @@ -519,14 +525,10 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew)
int nMaxSignatures = 0;
std::string strPayeesPossible = "";

uint64_t nReward;
uint64_t 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;
Expand All @@ -537,8 +539,9 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew)
BOOST_FOREACH(CMasternodePayee& payee, vecPayments)
{
bool found = false;
BOOST_FOREACH(CTxOut out, txNew.vout){
if(payee.scriptPubKey == out.scriptPubKey && masternodePayment == out.nValue){
BOOST_FOREACH(CTxOut out, txNew.vout)
{
if(payee.scriptPubKey == out.scriptPubKey && out.nValue >= requiredMasternodePayment){
found = true;
}
}
Expand All @@ -559,7 +562,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(requiredMasternodePayment).c_str(),strPayeesPossible.c_str());
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down