diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -218,7 +218,7 @@ if (fAllToMe) { // Payment to self - CAmount nChange = wtx.GetChange(); + CAmount nChange = wtx.GetChange().GetSatoshis(); CAmount nValue = nCredit - nChange; strHTML += "" + tr("Total debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -nValue) + diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -90,7 +90,7 @@ if (fAllFromMe && fAllToMe) { // Payment to self - CAmount nChange = wtx.GetChange(); + CAmount nChange = wtx.GetChange().GetSatoshis(); parts.append( TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -292,7 +292,7 @@ mutable CAmount nWatchCreditCached; mutable CAmount nImmatureWatchCreditCached; mutable CAmount nAvailableWatchCreditCached; - mutable CAmount nChangeCached; + mutable Amount nChangeCached; CWalletTx() { Init(nullptr); } @@ -399,7 +399,7 @@ CAmount GetAvailableCredit(bool fUseCache = true) const; CAmount GetImmatureWatchOnlyCredit(const bool &fUseCache = true) const; CAmount GetAvailableWatchOnlyCredit(const bool &fUseCache = true) const; - CAmount GetChange() const; + Amount GetChange() const; void GetAmounts(std::list &listReceived, std::list &listSent, CAmount &nFee, @@ -906,7 +906,7 @@ isminetype IsMine(const CTxOut &txout) const; CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const; bool IsChange(const CTxOut &txout) const; - CAmount GetChange(const CTxOut &txout) const; + Amount GetChange(const CTxOut &txout) const; bool IsMine(const CTransaction &tx) const; /** should probably be renamed to IsRelevantToMe */ bool IsFromMe(const CTransaction &tx) const; @@ -914,7 +914,7 @@ /** Returns whether all of the inputs match the filter */ bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const; CAmount GetCredit(const CTransaction &tx, const isminefilter &filter) const; - CAmount GetChange(const CTransaction &tx) const; + Amount GetChange(const CTransaction &tx) const; void SetBestChain(const CBlockLocator &loc) override; DBErrors LoadWallet(bool &fFirstRunRet); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1414,13 +1414,13 @@ return false; } -CAmount CWallet::GetChange(const CTxOut &txout) const { +Amount CWallet::GetChange(const CTxOut &txout) const { if (!MoneyRange(txout.nValue)) { throw std::runtime_error(std::string(__func__) + ": value out of range"); } - return (IsChange(txout) ? txout.nValue.GetSatoshis() : 0); + return (IsChange(txout) ? txout.nValue : 0); } bool CWallet::IsMine(const CTransaction &tx) const { @@ -1491,8 +1491,8 @@ return nCredit; } -CAmount CWallet::GetChange(const CTransaction &tx) const { - CAmount nChange = 0; +Amount CWallet::GetChange(const CTransaction &tx) const { + Amount nChange = 0; for (const CTxOut &txout : tx.vout) { nChange += GetChange(txout); if (!MoneyRange(nChange)) { @@ -1990,7 +1990,7 @@ return nCredit; } -CAmount CWalletTx::GetChange() const { +Amount CWalletTx::GetChange() const { if (fChangeCached) { return nChangeCached; }