From 19437c3a1cca63c5fbc84071752a17255ed9c432 Mon Sep 17 00:00:00 2001 From: Brandon Odiwuor Date: Wed, 13 Dec 2023 13:46:42 +0300 Subject: [PATCH] wallet: get used balance in getbalances RPC from updated GetBalance(...) --- src/wallet/rpc/coins.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wallet/rpc/coins.cpp b/src/wallet/rpc/coins.cpp index 0cb0891141bd08..bcded509a9d06c 100644 --- a/src/wallet/rpc/coins.cpp +++ b/src/wallet/rpc/coins.cpp @@ -475,10 +475,7 @@ RPCHelpMan getbalances() balances_mine.pushKV("untrusted_pending", ValueFromAmount(bal.m_mine_untrusted_pending)); balances_mine.pushKV("immature", ValueFromAmount(bal.m_mine_immature)); if (wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE)) { - // If the AVOID_REUSE flag is set, bal has been set to just the un-reused address balance. Get - // the total balance, and then subtract bal to get the reused address balance. - const auto full_bal = GetBalance(wallet, 0, false); - balances_mine.pushKV("used", ValueFromAmount(full_bal.m_mine_trusted + full_bal.m_mine_untrusted_pending - bal.m_mine_trusted - bal.m_mine_untrusted_pending)); + balances_mine.pushKV("used", ValueFromAmount(bal.m_mine_used)); } balances.pushKV("mine", balances_mine); }