diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1074,7 +1074,6 @@ Amount GetImmatureBalance() const; Amount GetUnconfirmedWatchOnlyBalance() const; Amount GetImmatureWatchOnlyBalance() const; - Amount GetLegacyBalance(const isminefilter &filter, int minDepth) const; Amount GetAvailableBalance(const CCoinControl *coinControl = nullptr) const; OutputType TransactionChangeType(OutputType change_type, diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2429,52 +2429,6 @@ return nTotal; } -// Calculate total balance in a different way from GetBalance. The biggest -// difference is that GetBalance sums up all unspent TxOuts paying to the -// wallet, while this sums up both spent and 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. -Amount CWallet::GetLegacyBalance(const isminefilter &filter, - int minDepth) const { - auto locked_chain = chain().lock(); - LOCK(cs_wallet); - - const Consensus::Params params = Params().GetConsensus(); - - Amount balance = Amount::zero(); - for (const auto &entry : mapWallet) { - const CWalletTx &wtx = entry.second; - const int depth = wtx.GetDepthInMainChain(*locked_chain); - CValidationState state; - if (depth < 0 || - !locked_chain->contextualCheckTransactionForCurrentBlock( - params, *wtx.tx, state) || - wtx.IsImmatureCoinBase(*locked_chain)) { - continue; - } - - // Loop through tx outputs and add incoming payments. For outgoing txs, - // treat change outputs specially, as part of the amount debited. - Amount debit = wtx.GetDebit(filter); - const bool outgoing = debit > Amount::zero(); - for (const CTxOut &out : wtx.tx->vout) { - if (outgoing && IsChange(out)) { - debit -= out.nValue; - } else if (IsMine(out) & filter && depth >= minDepth) { - balance += out.nValue; - } - } - - // For outgoing txs, subtract amount debited. - if (outgoing) { - balance -= debit; - } - } - - return balance; -} - Amount CWallet::GetAvailableBalance(const CCoinControl *coinControl) const { auto locked_chain = chain().lock(); LOCK(cs_wallet);