From 03ca097ec4ed0964cf69db7184ec1db1cac7f920 Mon Sep 17 00:00:00 2001 From: CryptoVote Date: Sat, 23 Jan 2016 22:21:14 -0600 Subject: [PATCH 1/6] Updates monetary variable int64_t types to CAmount in DarkSend. --- src/darksend.cpp | 60 ++++++++++++++++++++++++------------------------ src/darksend.h | 30 ++++++++++++------------ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/darksend.cpp b/src/darksend.cpp index 63c86522eeb3..93e83e6915a3 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -173,7 +173,7 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand } std::vector in; - int64_t nAmount; + CAmount nAmount; CTransaction txCollateral; std::vector out; vRecv >> in >> nAmount >> txCollateral >> out; @@ -197,8 +197,8 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand //check it like a transaction { - int64_t nValueIn = 0; - int64_t nValueOut = 0; + CAmount nValueIn = 0; + CAmount nValueOut = 0; bool missingTx = false; CValidationState state; @@ -936,8 +936,8 @@ bool CDarksendPool::IsCollateralValid(const CTransaction& txCollateral){ if(txCollateral.vout.size() < 1) return false; if(txCollateral.nLockTime != 0) return false; - int64_t nValueIn = 0; - int64_t nValueOut = 0; + CAmount nValueIn = 0; + CAmount nValueOut = 0; bool missingTx = false; BOOST_FOREACH(const CTxOut o, txCollateral.vout){ @@ -990,7 +990,7 @@ bool CDarksendPool::IsCollateralValid(const CTransaction& txCollateral){ // // Add a clients transaction to the pool // -bool CDarksendPool::AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, int& errorID){ +bool CDarksendPool::AddEntry(const std::vector& newInput, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, int& errorID){ if (!fMasterNode) return false; BOOST_FOREACH(CTxIn in, newInput) { @@ -1092,7 +1092,7 @@ bool CDarksendPool::SignaturesComplete(){ // Execute a Darksend denomination via a Masternode. // This is only ran from clients // -void CDarksendPool::SendDarksendDenominate(std::vector& vin, std::vector& vout, int64_t amount){ +void CDarksendPool::SendDarksendDenominate(std::vector& vin, std::vector& vout, CAmount amount){ if(fMasterNode) { LogPrintf("CDarksendPool::SendDarksendDenominate() - Darksend from a Masternode is not supported currently.\n"); @@ -1139,7 +1139,7 @@ void CDarksendPool::SendDarksendDenominate(std::vector& vin, std::vector< //check it against the memory pool to make sure it's valid { - int64_t nValueOut = 0; + CAmount nValueOut = 0; CValidationState state; CMutableTransaction tx; @@ -1652,8 +1652,8 @@ bool CDarksendPool::PrepareDarksendDenominate() bool CDarksendPool::SendRandomPaymentToSelf() { - int64_t nBalance = pwalletMain->GetBalance(); - int64_t nPayment = (nBalance*0.35) + (rand() % nBalance); + CAmount nBalance = pwalletMain->GetBalance(); + CAmount nPayment = (nBalance*0.35) + (rand() % nBalance); if(nPayment > nBalance) nPayment = nBalance-(0.1*COIN); @@ -1666,9 +1666,9 @@ bool CDarksendPool::SendRandomPaymentToSelf() scriptChange = GetScriptForDestination(vchPubKey.GetID()); CWalletTx wtx; - int64_t nFeeRet = 0; + CAmount nFeeRet = 0; std::string strFail = ""; - vector< pair > vecSend; + vector< pair > vecSend; // ****** Add fees ************ / vecSend.push_back(make_pair(scriptChange, nPayment)); @@ -1691,9 +1691,9 @@ bool CDarksendPool::SendRandomPaymentToSelf() bool CDarksendPool::MakeCollateralAmounts() { CWalletTx wtx; - int64_t nFeeRet = 0; + CAmount nFeeRet = 0; std::string strFail = ""; - vector< pair > vecSend; + vector< pair > vecSend; CCoinControl *coinControl = NULL; // make our collateral address @@ -1740,13 +1740,13 @@ bool CDarksendPool::MakeCollateralAmounts() } // Create denominations -bool CDarksendPool::CreateDenominated(int64_t nTotalValue) +bool CDarksendPool::CreateDenominated(CAmount nTotalValue) { CWalletTx wtx; - int64_t nFeeRet = 0; + CAmount nFeeRet = 0; std::string strFail = ""; - vector< pair > vecSend; - int64_t nValueLeft = nTotalValue; + vector< pair > vecSend; + CAmount nValueLeft = nTotalValue; // make our collateral address CReserveKey reservekeyCollateral(pwalletMain); @@ -1768,7 +1768,7 @@ bool CDarksendPool::CreateDenominated(int64_t nTotalValue) // ****** Add denoms ************ / - BOOST_REVERSE_FOREACH(int64_t v, darkSendDenominations){ + BOOST_REVERSE_FOREACH(CAmount v, darkSendDenominations){ // Note: denoms are skipped if there are already DENOMS_COUNT_MAX of them @@ -1852,7 +1852,7 @@ bool CDarksendPool::IsCompatibleWithEntries(std::vector& vout) return true; } -bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txCollateral, int& errorID) +bool CDarksendPool::IsCompatibleWithSession(CAmount nDenom, CTransaction txCollateral, int& errorID) { if(nDenom == 0) return false; @@ -1953,16 +1953,16 @@ int CDarksendPool::GetDenominations(const std::vector& vout){ // return a bitshifted integer representing the denominations in this list int CDarksendPool::GetDenominations(const std::vector& vout, bool fSingleRandomDenom){ - std::vector > denomUsed; + std::vector > denomUsed; // make a list of denominations, with zero uses - BOOST_FOREACH(int64_t d, darkSendDenominations) + BOOST_FOREACH(CAmount d, darkSendDenominations) denomUsed.push_back(make_pair(d, 0)); // look for denominations and update uses to 1 BOOST_FOREACH(CTxOut out, vout){ bool found = false; - BOOST_FOREACH (PAIRTYPE(int64_t, int)& s, denomUsed){ + BOOST_FOREACH (PAIRTYPE(CAmount, int)& s, denomUsed){ if (out.nValue == s.first){ s.second = 1; found = true; @@ -1975,7 +1975,7 @@ int CDarksendPool::GetDenominations(const std::vector& vout, bool fSingl int c = 0; // if the denomination is used, shift the bit on. // then move to the next - BOOST_FOREACH (PAIRTYPE(int64_t, int)& s, denomUsed) { + BOOST_FOREACH (PAIRTYPE(CAmount, int)& s, denomUsed) { int bit = (fSingleRandomDenom ? rand()%2 : 1) * s.second; denom |= bit << c++; if(fSingleRandomDenom && bit) break; // use just one random denomination @@ -1992,12 +1992,12 @@ int CDarksendPool::GetDenominations(const std::vector& vout, bool fSingl } -int CDarksendPool::GetDenominationsByAmounts(std::vector& vecAmount){ +int CDarksendPool::GetDenominationsByAmounts(std::vector& vecAmount){ CScript e = CScript(); std::vector vout1; // Make outputs by looping through denominations, from small to large - BOOST_REVERSE_FOREACH(int64_t v, vecAmount){ + BOOST_REVERSE_FOREACH(CAmount v, vecAmount){ CTxOut o(v, e); vout1.push_back(o); } @@ -2005,14 +2005,14 @@ int CDarksendPool::GetDenominationsByAmounts(std::vector& vecAmount){ return GetDenominations(vout1, true); } -int CDarksendPool::GetDenominationsByAmount(int64_t nAmount, int nDenomTarget){ +int CDarksendPool::GetDenominationsByAmount(CAmount nAmount, int nDenomTarget){ CScript e = CScript(); - int64_t nValueLeft = nAmount; + CAmount nValueLeft = nAmount; std::vector vout1; // Make outputs by looping through denominations, from small to large - BOOST_REVERSE_FOREACH(int64_t v, darkSendDenominations){ + BOOST_REVERSE_FOREACH(CAmount v, darkSendDenominations){ if(nDenomTarget != 0){ bool fAccepted = false; if((nDenomTarget & (1 << 0)) && v == ((100*COIN)+100000)) {fAccepted = true;} @@ -2200,7 +2200,7 @@ void CDarksendPool::RelayFinalTransaction(const int sessionID, const CTransactio } } -void CDarksendPool::RelayIn(const std::vector& vin, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& vout) +void CDarksendPool::RelayIn(const std::vector& vin, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector& vout) { if(!pSubmittedToMasternode) return; diff --git a/src/darksend.h b/src/darksend.h index 5f6eabe417c9..eb1640d82e08 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -46,9 +46,9 @@ class CActiveMasternode; #define DARKSEND_RELAY_OUT 2 #define DARKSEND_RELAY_SIG 3 -static const int64_t DARKSEND_COLLATERAL = (0.01*COIN); -static const int64_t DARKSEND_POOL_MAX = (999.99*COIN); -static const int64_t DENOMS_COUNT_MAX = 100; +static const CAmount DARKSEND_COLLATERAL = (0.01*COIN); +static const CAmount DARKSEND_POOL_MAX = (999.99*COIN); +static const CAmount DENOMS_COUNT_MAX = 100; extern CDarksendPool darkSendPool; extern CDarkSendSigner darkSendSigner; @@ -99,7 +99,7 @@ class CDarkSendEntry bool isSet; std::vector sev; std::vector vout; - int64_t amount; + CAmount amount; CTransaction collateral; CTransaction txSupporting; int64_t addedTime; // time in UTC milliseconds @@ -112,7 +112,7 @@ class CDarkSendEntry } /// Add entries to use for Darksend - bool Add(const std::vector vinIn, int64_t amountIn, const CTransaction collateralIn, const std::vector voutIn) + bool Add(const std::vector vinIn, CAmount amountIn, const CTransaction collateralIn, const std::vector voutIn) { if(isSet){return false;} @@ -291,7 +291,7 @@ class CDarksendPool int64_t lastNewBlock; - std::vector darkSendDenominationsSkipped; + std::vector darkSendDenominationsSkipped; //debugging data std::string strAutoDenomResult; @@ -369,8 +369,8 @@ class CDarksendPool darkSendDenominationsSkipped.clear(); } - bool IsDenomSkipped(int64_t denom) { - BOOST_FOREACH(int64_t d, darkSendDenominationsSkipped) { + bool IsDenomSkipped(CAmount denom) { + BOOST_FOREACH(CAmount d, darkSendDenominationsSkipped) { if (d == denom) { return true; } @@ -450,7 +450,7 @@ class CDarksendPool bool IsCompatibleWithEntries(std::vector& vout); /// Is this amount compatible with other client in the pool? - bool IsCompatibleWithSession(int64_t nAmount, CTransaction txCollateral, int &errorID); + bool IsCompatibleWithSession(CAmount nAmount, CTransaction txCollateral, int &errorID); /// Passively run Darksend in the background according to the configuration in settings (only for QT) bool DoAutomaticDenominating(bool fDryRun=false); @@ -470,13 +470,13 @@ class CDarksendPool /// If the collateral is valid given by a client bool IsCollateralValid(const CTransaction& txCollateral); /// Add a clients entry to the pool - bool AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, int& errorID); + bool AddEntry(const std::vector& newInput, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, int& errorID); /// Add signature to a vin bool AddScriptSig(const CTxIn& newVin); /// Check that all inputs are signed. (Are all inputs signed?) bool SignaturesComplete(); /// As a client, send a transaction to a Masternode to start the denomination process - void SendDarksendDenominate(std::vector& vin, std::vector& vout, int64_t amount); + void SendDarksendDenominate(std::vector& vin, std::vector& vout, CAmount amount); /// Get Masternode updates about the progress of Darksend bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, int &errorID, int newSessionID=0); @@ -494,7 +494,7 @@ class CDarksendPool /// Split up large inputs or make fee sized inputs bool MakeCollateralAmounts(); - bool CreateDenominated(int64_t nTotalValue); + bool CreateDenominated(CAmount nTotalValue); /// Get the denominations for a list of outputs (returns a bitshifted integer) int GetDenominations(const std::vector& vout, bool fSingleRandomDenom = false); @@ -503,8 +503,8 @@ class CDarksendPool void GetDenominationsToString(int nDenom, std::string& strDenom); /// Get the denominations for a specific amount of dash. - int GetDenominationsByAmount(int64_t nAmount, int nDenomTarget=0); // is not used anymore? - int GetDenominationsByAmounts(std::vector& vecAmount); + int GetDenominationsByAmount(CAmount nAmount, int nDenomTarget=0); // is not used anymore? + int GetDenominationsByAmounts(std::vector& vecAmount); std::string GetMessageByID(int messageID); @@ -515,7 +515,7 @@ class CDarksendPool void RelayFinalTransaction(const int sessionID, const CTransaction& txNew); void RelaySignaturesAnon(std::vector& vin); void RelayInAnon(std::vector& vin, std::vector& vout); - void RelayIn(const std::vector& vin, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& vout); + void RelayIn(const std::vector& vin, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector& vout); void RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const int errorID=MSG_NOERR); void RelayCompletedTransaction(const int sessionID, const bool error, const int errorID); }; From af1c1e6731531729915c9e03db1b78f3920e8e18 Mon Sep 17 00:00:00 2001 From: CryptoVote Date: Sat, 23 Jan 2016 22:24:08 -0600 Subject: [PATCH 2/6] Updates monetary variable int64_t types to CAmount in masternode- --- src/masternode-payments.cpp | 6 +++--- src/masternode-payments.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 5e756cf97ea2..c498db9afac9 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -182,7 +182,7 @@ void DumpMasternodePayments() LogPrintf("Budget dump finished %dms\n", GetTimeMillis() - nStart); } -bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue){ +bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue){ CBlockIndex* pindexPrev = chainActive.Tip(); if(pindexPrev == NULL) return true; @@ -267,7 +267,7 @@ bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight) } -void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees) +void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) { CBlockIndex* pindexPrev = chainActive.Tip(); if(!pindexPrev) return; @@ -288,7 +288,7 @@ std::string GetRequiredPaymentsString(int nBlockHeight) } } -void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFees) +void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) { CBlockIndex* pindexPrev = chainActive.Tip(); if(!pindexPrev) return; diff --git a/src/masternode-payments.h b/src/masternode-payments.h index e4783a5a81ee..58cca65f8df6 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -30,8 +30,8 @@ void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDa bool IsReferenceNode(CTxIn& vin); bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight); std::string GetRequiredPaymentsString(int nBlockHeight); -bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue); -void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees); +bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue); +void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees); void DumpMasternodePayments(); @@ -268,7 +268,7 @@ class CMasternodePayments int GetMinMasternodePaymentsProto(); void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); std::string GetRequiredPaymentsString(int nBlockHeight); - void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees); + void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees); std::string ToString() const; int GetOldestBlock(); int GetNewestBlock(); From dd3ab83738dd9b5489743a98f50ccec99ddb6ac4 Mon Sep 17 00:00:00 2001 From: CryptoVote Date: Sat, 23 Jan 2016 22:33:45 -0600 Subject: [PATCH 3/6] Updates monetary variable int64_t types to CAmount in Wallet. --- src/wallet.cpp | 34 +++++++++++++++++----------------- src/wallet.h | 22 +++++++++++----------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/wallet.cpp b/src/wallet.cpp index 0ce841c526f2..bedc4caafad3 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -954,9 +954,9 @@ bool CWallet::IsDenominated(const CTransaction& tx) const } -bool CWallet::IsDenominatedAmount(int64_t nInputAmount) const +bool CWallet::IsDenominatedAmount(CAmount nInputAmount) const { - BOOST_FOREACH(int64_t d, darkSendDenominations) + BOOST_FOREACH(CAmount d, darkSendDenominations) if(nInputAmount == d) return true; return false; @@ -1592,7 +1592,7 @@ bool less_then_denom (const COutput& out1, const COutput& out2) bool found1 = false; bool found2 = false; - BOOST_FOREACH(int64_t d, darkSendDenominations) // loop through predefined denoms + BOOST_FOREACH(CAmount d, darkSendDenominations) // loop through predefined denoms { if(pcoin1->vout[out1.i].nValue == d) found1 = true; if(pcoin2->vout[out2.i].nValue == d) found2 = true; @@ -1754,7 +1754,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set& vCoinsRet, std::vector& vCoinsRet2, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) +bool CWallet::SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount nValueMax, std::vector& vCoinsRet, std::vector& vCoinsRet2, CAmount& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) { vCoinsRet.clear(); nValueRet = 0; @@ -1906,7 +1906,7 @@ bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector< return false; } -bool CWallet::SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const +bool CWallet::SelectCoinsCollateral(std::vector& setCoinsRet, CAmount& nValueRet) const { vector vCoins; @@ -1935,9 +1935,9 @@ bool CWallet::SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nV return false; } -int CWallet::CountInputsWithAmount(int64_t nInputAmount) +int CWallet::CountInputsWithAmount(CAmount nInputAmount) { - int64_t nTotal = 0; + CAmount nTotal = 0; { LOCK(cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) @@ -1975,7 +1975,7 @@ bool CWallet::HasCollateralInputs(bool fOnlyConfirmed) const return nFound > 0; } -bool CWallet::IsCollateralAmount(int64_t nInputAmount) const +bool CWallet::IsCollateralAmount(CAmount nInputAmount) const { return nInputAmount != 0 && nInputAmount % DARKSEND_COLLATERAL == 0 && nInputAmount < DARKSEND_COLLATERAL * 5 && nInputAmount > DARKSEND_COLLATERAL; } @@ -2050,9 +2050,9 @@ bool CWallet::GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useI CScript scriptChange; scriptChange << OP_RETURN << ToByteVector(hash); - int64_t nFeeRet = 0; + CAmount nFeeRet = 0; std::string strFail = ""; - vector< pair > vecSend; + vector< pair > vecSend; vecSend.push_back(make_pair(scriptChange, BUDGET_FEE_TX)); CCoinControl *coinControl=NULL; @@ -2066,7 +2066,7 @@ bool CWallet::GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useI } -bool CWallet::ConvertList(std::vector vCoins, std::vector& vecAmounts) +bool CWallet::ConvertList(std::vector vCoins, std::vector& vecAmounts) { BOOST_FOREACH(CTxIn i, vCoins){ if (mapWallet.count(i.prevout.hash)) @@ -2380,8 +2380,8 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge return nFeeNeeded; } -int64_t CWallet::GetTotalValue(std::vector vCoins) { - int64_t nTotalValue = 0; +CAmount CWallet::GetTotalValue(std::vector vCoins) { + CAmount nTotalValue = 0; CWalletTx wtx; BOOST_FOREACH(CTxIn i, vCoins){ if (mapWallet.count(i.prevout.hash)) @@ -2410,7 +2410,7 @@ string CWallet::PrepareDarksendDenominate(int minRounds, int maxRounds) std::vector vCoins; std::vector vCoinsResult; std::vector vCoins2; - int64_t nValueIn = 0; + CAmount nValueIn = 0; CReserveKey reservekey(this); /* @@ -2431,7 +2431,7 @@ string CWallet::PrepareDarksendDenominate(int minRounds, int maxRounds) LockCoin(v.prevout); } - int64_t nValueLeft = nValueIn; + CAmount nValueLeft = nValueIn; std::vector vOut; /* @@ -2446,7 +2446,7 @@ string CWallet::PrepareDarksendDenominate(int minRounds, int maxRounds) int nStepsMax = 5 + GetRandInt(5); while(nStep < nStepsMax) { - BOOST_FOREACH(int64_t v, darkSendDenominations){ + BOOST_FOREACH(CAmount v, darkSendDenominations){ // only use the ones that are approved bool fAccepted = false; if((darkSendPool.sessionDenom & (1 << 0)) && v == ((100*COIN) +100000)) {fAccepted = true;} diff --git a/src/wallet.h b/src/wallet.h index 08e5e064a823..7867b87a3055 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -150,14 +150,14 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface public: // bool SelectCoins(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = true) const; - bool SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const; - bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector& vCoinsRet, std::vector& vCoinsRet2, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax); - bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector& setCoinsRet, CAmount& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const; + bool SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount nValueMax, std::vector& vCoinsRet, std::vector& vCoinsRet2, CAmount& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax); + bool SelectCoinsDarkDenominated(CAmount nTargetValue, std::vector& setCoinsRet, CAmount& nValueRet) const; bool HasCollateralInputs(bool fOnlyConfirmed = true) const; - bool IsCollateralAmount(int64_t nInputAmount) const; - int CountInputsWithAmount(int64_t nInputAmount); + bool IsCollateralAmount(CAmount nInputAmount) const; + int CountInputsWithAmount(CAmount nInputAmount); - bool SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const ; + bool SelectCoinsCollateral(std::vector& setCoinsRet, CAmount& nValueRet) const ; /* * Main wallet lock. @@ -239,7 +239,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface void UnlockCoin(COutPoint& output); void UnlockAllCoins(); void ListLockedCoins(std::vector& vOutpts); - int64_t GetTotalValue(std::vector vCoins); + CAmount GetTotalValue(std::vector vCoins); /** * keystore implementation @@ -326,7 +326,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface std::string PrepareDarksendDenominate(int minRounds, int maxRounds); int GenerateDarksendOutputs(int nTotalValue, std::vector& vout); bool CreateCollateralTransaction(CMutableTransaction& txCollateral, std::string& strReason); - bool ConvertList(std::vector vCoins, std::vector& vecAmounts); + bool ConvertList(std::vector vCoins, std::vector& vecAmounts); static CFeeRate minTxFee; static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool); @@ -356,7 +356,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface bool IsDenominated(const CTxIn &txin) const; bool IsDenominated(const CTransaction& tx) const; - bool IsDenominatedAmount(int64_t nInputAmount) const; + bool IsDenominatedAmount(CAmount nInputAmount) const; isminetype IsMine(const CTxIn& txin) const; CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const; @@ -811,7 +811,7 @@ class CWalletTx : public CMerkleTx if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; - int64_t credit = 0; + CAmount credit = 0; if (filter & ISMINE_SPENDABLE) { // GetBalance can assume transactions in mapWallet won't change @@ -1119,7 +1119,7 @@ class COutput //Used with Darksend. Will return largest nondenom, then denominations, then very small inputs int Priority() const { - BOOST_FOREACH(int64_t d, darkSendDenominations) + BOOST_FOREACH(CAmount d, darkSendDenominations) if(tx->vout[i].nValue == d) return 10000; if(tx->vout[i].nValue < 1*COIN) return 20000; From 2b1cb55481aa88495330d0c0716542b09ec1e7d7 Mon Sep 17 00:00:00 2001 From: CryptoVote Date: Sat, 23 Jan 2016 22:37:40 -0600 Subject: [PATCH 4/6] Updates monetary variable int64_t types to CAmount in Main. --- src/main.cpp | 8 ++++---- src/main.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b0ec0ff399d0..9b4dbe84fd53 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1534,14 +1534,14 @@ double ConvertBitsToDouble(unsigned int nBits) return dDiff; } -int64_t GetBlockValue(int nBits, int nHeight, const CAmount& nFees) +CAmount GetBlockValue(int nBits, int nHeight, const CAmount& nFees) { double dDiff = (double)0x0000ffff / (double)(nBits & 0x00ffffff); /* fixed bug caused diff to not be correctly calculated */ if(nHeight > 4500 || Params().NetworkID() == CBaseChainParams::TESTNET) dDiff = ConvertBitsToDouble(nBits); - int64_t nSubsidy = 0; + CAmount nSubsidy = 0; if(nHeight >= 5465) { if((nHeight >= 17000 && dDiff > 75) || nHeight >= 24000) { // GPU/ASIC difficulty calc // 2222222/(((x+2600)/9)^2) @@ -1584,9 +1584,9 @@ int64_t GetBlockValue(int nBits, int nHeight, const CAmount& nFees) return nSubsidy + nFees; } -int64_t GetMasternodePayment(int nHeight, int64_t blockValue) +CAmount GetMasternodePayment(int nHeight, CAmount blockValue) { - int64_t ret = blockValue/5; // start at 20% + CAmount ret = blockValue/5; // start at 20% if(Params().NetworkID() == CBaseChainParams::TESTNET) { if(nHeight > 46000) ret += blockValue / 20; //25% - 2014-10-07 diff --git a/src/main.h b/src/main.h index f08c15e7af7e..e6aa418b186c 100644 --- a/src/main.h +++ b/src/main.h @@ -215,7 +215,7 @@ bool DisconnectBlocksAndReprocess(int blocks); // ***TODO*** double ConvertBitsToDouble(unsigned int nBits); -int64_t GetMasternodePayment(int nHeight, int64_t blockValue); +CAmount GetMasternodePayment(int nHeight, CAmount blockValue); unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock); bool ActivateBestChain(CValidationState &state, CBlock *pblock = NULL); From f203ab4b2daed7e4e426d46350ccb1390bda221e Mon Sep 17 00:00:00 2001 From: CryptoVote Date: Sat, 23 Jan 2016 22:40:36 -0600 Subject: [PATCH 5/6] Updates monetary variable int64_t types to CAmount in Util. --- src/util.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util.h b/src/util.h index 0ec4ceb679ec..069b31a6db81 100644 --- a/src/util.h +++ b/src/util.h @@ -18,6 +18,7 @@ #include "compat.h" #include "tinyformat.h" #include "utiltime.h" +#include "amount.h" #include #include @@ -43,7 +44,7 @@ extern int64_t enforceMasternodePaymentsTime; extern std::string strMasterNodeAddr; extern int keysLoaded; extern bool fSucessfullyLoaded; -extern std::vector darkSendDenominations; +extern std::vector darkSendDenominations; extern std::string strBudgetMode; extern std::map mapArgs; From c72886b928b687eed7f15d0df334f18440115a1c Mon Sep 17 00:00:00 2001 From: CryptoVote Date: Sat, 23 Jan 2016 22:44:40 -0600 Subject: [PATCH 6/6] Updates monetary variable int64_t types to CAmount in util.cpp. --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 2e76ec222da7..b0ab03c28409 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -119,7 +119,7 @@ bool fSucessfullyLoaded = false; bool fEnableDarksend = false; bool fDarksendMultiSession = false; /** All denominations used by darksend */ -std::vector darkSendDenominations; +std::vector darkSendDenominations; string strBudgetMode = ""; map mapArgs;