diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -875,7 +875,7 @@ // unspent TxOuts paying to the wallet, and then subtracts the values of // TxIns spending from the wallet. This also has fewer restrictions on // which unconfirmed transactions are considered trusted. - CAmount nBalance = 0; + Amount nBalance = 0; for (std::map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { @@ -889,7 +889,7 @@ continue; } - CAmount allFee; + Amount allFee; std::string strSentAccount; std::list listReceived; std::list listSent; @@ -1595,7 +1595,7 @@ void ListTransactions(const CWalletTx &wtx, const std::string &strAccount, int nMinDepth, bool fLong, UniValue &ret, const isminefilter &filter) { - CAmount nFee; + Amount nFee; std::string strSentAccount; std::list listReceived; std::list listSent; @@ -1606,7 +1606,7 @@ bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY); // Sent - if ((!listSent.empty() || nFee != 0) && + if ((!listSent.empty() || nFee != Amount(0)) && (fAllAccounts || strAccount == strSentAccount)) { for (const COutputEntry &s : listSent) { UniValue entry(UniValue::VOBJ); @@ -1623,7 +1623,7 @@ "label", pwalletMain->mapAddressBook[s.destination].name)); } entry.push_back(Pair("vout", s.vout)); - entry.push_back(Pair("fee", ValueFromAmount(-nFee))); + entry.push_back(Pair("fee", ValueFromAmount(-1 * nFee))); if (fLong) { WalletTxToJSON(wtx, entry); } @@ -1936,7 +1936,7 @@ pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx &wtx = (*it).second; - CAmount nFee; + Amount nFee; std::string strSentAccount; std::list listReceived; std::list listSent; @@ -1946,7 +1946,7 @@ } wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); - mapAccountBalances[strSentAccount] -= nFee; + mapAccountBalances[strSentAccount] -= nFee.GetSatoshis(); for (const COutputEntry &s : listSent) { mapAccountBalances[strSentAccount] -= s.amount; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -287,11 +287,11 @@ mutable Amount nDebitCached; mutable Amount nCreditCached; mutable Amount nImmatureCreditCached; - mutable CAmount nAvailableCreditCached; - mutable CAmount nWatchDebitCached; - mutable CAmount nWatchCreditCached; - mutable CAmount nImmatureWatchCreditCached; - mutable CAmount nAvailableWatchCreditCached; + mutable Amount nAvailableCreditCached; + mutable Amount nWatchDebitCached; + mutable Amount nWatchCreditCached; + mutable Amount nImmatureWatchCreditCached; + mutable Amount nAvailableWatchCreditCached; mutable Amount nChangeCached; CWalletTx() { Init(nullptr); } @@ -396,18 +396,18 @@ Amount GetDebit(const isminefilter &filter) const; Amount GetCredit(const isminefilter &filter) const; Amount GetImmatureCredit(bool fUseCache = true) const; - CAmount GetAvailableCredit(bool fUseCache = true) const; - CAmount GetImmatureWatchOnlyCredit(const bool &fUseCache = true) const; - CAmount GetAvailableWatchOnlyCredit(const bool &fUseCache = true) const; + Amount GetAvailableCredit(bool fUseCache = true) const; + Amount GetImmatureWatchOnlyCredit(const bool &fUseCache = true) const; + Amount GetAvailableWatchOnlyCredit(const bool &fUseCache = true) const; Amount GetChange() const; void GetAmounts(std::list &listReceived, - std::list &listSent, CAmount &nFee, + std::list &listSent, Amount &nFee, std::string &strSentAccount, const isminefilter &filter) const; - void GetAccountAmounts(const std::string &strAccount, CAmount &nReceived, - CAmount &nSent, CAmount &nFee, + void GetAccountAmounts(const std::string &strAccount, Amount &nReceived, + Amount &nSent, Amount &nFee, const isminefilter &filter) const; bool IsFromMe(const isminefilter &filter) const { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1608,7 +1608,7 @@ } void CWalletTx::GetAmounts(std::list &listReceived, - std::list &listSent, CAmount &nFee, + std::list &listSent, Amount &nFee, std::string &strSentAccount, const isminefilter &filter) const { nFee = 0; @@ -1621,7 +1621,7 @@ // debit>0 means we signed/sent this transaction. if (nDebit > 0) { Amount nValueOut = tx->GetValueOut(); - nFee = (nDebit - nValueOut).GetSatoshis(); + nFee = (nDebit - nValueOut); } // Sent/received. @@ -1667,12 +1667,12 @@ } void CWalletTx::GetAccountAmounts(const std::string &strAccount, - CAmount &nReceived, CAmount &nSent, - CAmount &nFee, + Amount &nReceived, Amount &nSent, + Amount &nFee, const isminefilter &filter) const { nReceived = nSent = nFee = 0; - CAmount allFee; + Amount allFee; std::string strSentAccount; std::list listReceived; std::list listSent; @@ -1914,7 +1914,7 @@ return 0; } -CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const { +Amount CWalletTx::GetAvailableCredit(bool fUseCache) const { if (pwallet == 0) { return 0; } @@ -1929,13 +1929,12 @@ return nAvailableCreditCached; } - CAmount nCredit = 0; + Amount nCredit = 0; uint256 hashTx = GetId(); for (unsigned int i = 0; i < tx->vout.size(); i++) { if (!pwallet->IsSpent(hashTx, i)) { const CTxOut &txout = tx->vout[i]; - nCredit += - pwallet->GetCredit(txout, ISMINE_SPENDABLE).GetSatoshis(); + nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE); if (!MoneyRange(nCredit)) { throw std::runtime_error( "CWalletTx::GetAvailableCredit() : value out of range"); @@ -1948,7 +1947,7 @@ return nCredit; } -CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool &fUseCache) const { +Amount CWalletTx::GetImmatureWatchOnlyCredit(const bool &fUseCache) const { if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) { if (fUseCache && fImmatureWatchCreditCached) { return nImmatureWatchCreditCached; @@ -1963,7 +1962,7 @@ return 0; } -CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool &fUseCache) const { +Amount CWalletTx::GetAvailableWatchOnlyCredit(const bool &fUseCache) const { if (pwallet == 0) { return 0; } @@ -2139,7 +2138,7 @@ CAmount CWallet::GetBalance() const { LOCK2(cs_main, cs_wallet); - CAmount nTotal = 0; + Amount nTotal = 0; for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx *pcoin = &(*it).second; @@ -2148,13 +2147,13 @@ } } - return nTotal; + return nTotal.GetSatoshis(); } CAmount CWallet::GetUnconfirmedBalance() const { LOCK2(cs_main, cs_wallet); - CAmount nTotal = 0; + Amount nTotal = 0; for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx *pcoin = &(*it).second; @@ -2164,7 +2163,7 @@ } } - return nTotal; + return nTotal.GetSatoshis(); } CAmount CWallet::GetImmatureBalance() const { @@ -2183,7 +2182,7 @@ CAmount CWallet::GetWatchOnlyBalance() const { LOCK2(cs_main, cs_wallet); - CAmount nTotal = 0; + Amount nTotal = 0; for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx *pcoin = &(*it).second; @@ -2192,13 +2191,13 @@ } } - return nTotal; + return nTotal.GetSatoshis(); } CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const { LOCK2(cs_main, cs_wallet); - CAmount nTotal = 0; + Amount nTotal = 0; for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx *pcoin = &(*it).second; @@ -2208,20 +2207,20 @@ } } - return nTotal; + return nTotal.GetSatoshis(); } CAmount CWallet::GetImmatureWatchOnlyBalance() const { LOCK2(cs_main, cs_wallet); - CAmount nTotal = 0; + Amount nTotal = 0; for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx *pcoin = &(*it).second; nTotal += pcoin->GetImmatureWatchOnlyCredit(); } - return nTotal; + return nTotal.GetSatoshis(); } void CWallet::AvailableCoins(std::vector &vCoins, bool fOnlyConfirmed, @@ -3610,10 +3609,10 @@ continue; } - CAmount nReceived, nSent, nFee; + Amount nReceived, nSent, nFee; wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee, filter); - if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) { + if (nReceived != Amount(0) && wtx.GetDepthInMainChain() >= nMinDepth) { nBalance += nReceived; }