File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -613,5 +613,17 @@ uint256 WalletModel::getLastBlockProcessed() const
613
613
614
614
CAmount WalletModel::getAvailableBalance (const CCoinControl* control)
615
615
{
616
- return control && control->HasSelected () ? wallet ().getAvailableBalance (*control) : getCachedBalance ().balance ;
616
+ // No selected coins, return the cached balance
617
+ if (!control || !control->HasSelected ()) {
618
+ const interfaces::WalletBalances& balances = getCachedBalance ();
619
+ CAmount available_balance = balances.balance ;
620
+ // if wallet private keys are disabled, this is a watch-only wallet
621
+ // so, let's include the watch-only balance.
622
+ if (balances.have_watch_only && m_wallet->privateKeysDisabled ()) {
623
+ available_balance += balances.watch_only_balance ;
624
+ }
625
+ return available_balance;
626
+ }
627
+ // Fetch balance from the wallet, taking into account the selected coins
628
+ return wallet ().getAvailableBalance (*control);
617
629
}
You can’t perform that action at this time.
0 commit comments