diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1069,8 +1069,7 @@ EnsureWalletIsUnlocked(pwallet); // Check funds - if (totalAmount > - pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, nullptr)) { + if (totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth)) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Wallet has insufficient funds"); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1176,8 +1176,7 @@ Amount GetImmatureBalance() const; Amount GetUnconfirmedWatchOnlyBalance() const; Amount GetImmatureWatchOnlyBalance() const; - Amount GetLegacyBalance(const isminefilter &filter, int minDepth, - const std::string *account) 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 @@ -2470,8 +2470,8 @@ // 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 std::string *account) const { +Amount CWallet::GetLegacyBalance(const isminefilter &filter, + int minDepth) const { // Temporary, for CheckFinalTx below. Removed in upcoming commit. LockAnnotation lock(::cs_main); auto locked_chain = chain().lock(); @@ -2493,23 +2493,17 @@ for (const CTxOut &out : wtx.tx->vout) { if (outgoing && IsChange(out)) { debit -= out.nValue; - } else if (IsMine(out) & filter && depth >= minDepth && - (!account || - *account == GetLabelName(out.scriptPubKey))) { + } else if (IsMine(out) & filter && depth >= minDepth) { balance += out.nValue; } } // For outgoing txs, subtract amount debited. - if (outgoing && (!account || *account == wtx.strFromAccount)) { + if (outgoing) { balance -= debit; } } - if (account) { - balance += WalletBatch(*database).GetAccountCreditDebit(*account); - } - return balance; }