Skip to content

Commit

Permalink
wallet: get used balance in getbalances RPC from updated GetBalance(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonOdiwuor committed Dec 13, 2023
1 parent 2578ba2 commit 19437c3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/wallet/rpc/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 19437c3

Please sign in to comment.