Skip to content

Commit

Permalink
Fix: add MASTERNODE_COLLATERAL_AMOUNT
Browse files Browse the repository at this point in the history
  • Loading branch information
cevap authored and ckti committed Mar 29, 2021
1 parent 0001101 commit a231420
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ vector<COutput> CActiveMasternode::SelectCoinsMasternode()

// Filter
BOOST_FOREACH (const COutput& out, vCoins) {
if (out.tx->vout[out.i].nValue == 20000 * COIN) { //exactly
if (out.tx->vout[out.i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) { //exactly
filteredCoins.push_back(out);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "libzerocoin/Params.h"
#include <vector>

#define MASTERNODE_COLLATERAL_AMOUNT 20000

typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];

struct CDNSSeedData {
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ CAmount GetSeeSaw(const CAmount& blockValue, int nMasternodeCount, int nHeight)
}

int64_t nMoneySupply = chainActive.Tip()->nMoneySupply;
int64_t mNodeCoins = nMasternodeCount * 20000 * COIN;
int64_t mNodeCoins = nMasternodeCount * MASTERNODE_COLLATERAL_AMOUNT * COIN;

// Use this log to compare the masternode count for different clients
//LogPrintf("Adjusting seesaw at height %d with %d masternodes (without drift: %d) at %ld\n", nHeight, nMasternodeCount, nMasternodeCount - Params().MasternodeCountDrift(), GetTime());
Expand Down Expand Up @@ -2053,7 +2053,7 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCou
nMasternodeCount = mnodeman.size();
}

int64_t mNodeCoins = nMasternodeCount * 20000 * COIN;
int64_t mNodeCoins = nMasternodeCount * MASTERNODE_COLLATERAL_AMOUNT * COIN;

// Use this log to compare the masternode count for different clients
LogPrintf("Adjusting seesaw at height %d with %d masternodes (without drift: %d) at %ld\n", nHeight, nMasternodeCount, nMasternodeCount - Params().MasternodeCountDrift(), GetTime());
Expand Down
2 changes: 1 addition & 1 deletion src/obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ bool CObfuScationSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey)
uint256 hash;
if (GetTransaction(vin.prevout.hash, txVin, hash, true)) {
BOOST_FOREACH (CTxOut out, txVin.vout) {
if (out.nValue == 20000 * COIN) {
if (out.nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) {
if (out.scriptPubKey == payee2) return true;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ CAmount CWalletTx::GetAnonymizableCredit(bool fUseCache) const
const CTxIn vin = CTxIn(hashTx, i);

if (pwallet->IsSpent(hashTx, i) || pwallet->IsLockedCoin(hashTx, i)) continue;
if (fMasterNode && vout[i].nValue == 20000 * COIN) continue; // do not count MN-like outputs
if (fMasterNode && vout[i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) continue; // do not count MN-like outputs

const int rounds = pwallet->GetInputObfuscationRounds(vin);
if (rounds >= -2 && rounds < nZeromintPercentage) {
Expand Down Expand Up @@ -1179,7 +1179,7 @@ CAmount CWalletTx::GetUnlockedCredit() const
const CTxOut& txout = vout[i];

if (pwallet->IsSpent(hashTx, i) || pwallet->IsLockedCoin(hashTx, i)) continue;
if (fMasterNode && vout[i].nValue == 20000 * COIN) continue; // do not count MN-like outputs
if (fMasterNode && vout[i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) continue; // do not count MN-like outputs

nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
if (!MoneyRange(nCredit))
Expand Down Expand Up @@ -1213,7 +1213,7 @@ CAmount CWalletTx::GetLockedCredit() const
}

// Add masternode collaterals which are handled likc locked coins
else if (fMasterNode && vout[i].nValue == 20000 * COIN) {
else if (fMasterNode && vout[i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) {
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
}

Expand Down Expand Up @@ -1332,7 +1332,7 @@ CAmount CWalletTx::GetLockedWatchOnlyCredit() const
}

// Add masternode collaterals which are handled likc locked coins
else if (fMasterNode && vout[i].nValue == 20000 * COIN) {
else if (fMasterNode && vout[i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) {
nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY);
}

Expand Down Expand Up @@ -1965,13 +1965,13 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
if (nCoinType == ONLY_DENOMINATED) {
found = IsDenominatedAmount(pcoin->vout[i].nValue);
} else if (nCoinType == ONLY_NOT20000IFMN) {
found = !(fMasterNode && pcoin->vout[i].nValue == 20000 * COIN);
found = !(fMasterNode && pcoin->vout[i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN);
} else if (nCoinType == ONLY_NONDENOMINATED_NOT20000IFMN) {
if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts
found = !IsDenominatedAmount(pcoin->vout[i].nValue);
if (found && fMasterNode) found = pcoin->vout[i].nValue != 20000 * COIN; // do not use Hot MN funds
if (found && fMasterNode) found = pcoin->vout[i].nValue != MASTERNODE_COLLATERAL_AMOUNT * COIN; // do not use Hot MN funds
} else if (nCoinType == ONLY_20000) {
found = pcoin->vout[i].nValue == 20000 * COIN;
found = pcoin->vout[i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN;
} else {
found = true;
}
Expand Down Expand Up @@ -2443,7 +2443,7 @@ bool CWallet::SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount

BOOST_FOREACH (const COutput& out, vCoins) {
// masternode-like input should not be selected by AvailableCoins now anyway
//if(out.tx->vout[out.i].nValue == 10000*COIN) continue;
//if(out.tx->vout[out.i].nValue == MASTERNODE_COLLATERAL_AMOUNT*COIN) continue;
if (nValueRet + out.tx->vout[out.i].nValue <= nValueMax) {
bool fAccepted = false;

Expand Down Expand Up @@ -2539,7 +2539,7 @@ bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector<
if (out.tx->vout[out.i].nValue < CENT) continue;
//do not allow collaterals to be selected
if (IsCollateralAmount(out.tx->vout[out.i].nValue)) continue;
if (fMasterNode && out.tx->vout[out.i].nValue == 20000 * COIN) continue; //masternode input
if (fMasterNode && out.tx->vout[out.i].nValue == MASTERNODE_COLLATERAL_AMOUNT * COIN) continue; //masternode input

if (nValueRet + out.tx->vout[out.i].nValue <= nValueMax) {
CTxIn vin = CTxIn(out.tx->GetHash(), out.i);
Expand Down

0 comments on commit a231420

Please sign in to comment.