mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
gui: 'getAvailableBalance', include watch only balance
Only for wallets with private keys disabled. The returned amount need to include the watch-only available balance too. Solves #26687.
This commit is contained in:
parent
74eac3a82f
commit
cd98b71739
1 changed files with 13 additions and 1 deletions
|
@ -613,5 +613,17 @@ uint256 WalletModel::getLastBlockProcessed() const
|
||||||
|
|
||||||
CAmount WalletModel::getAvailableBalance(const CCoinControl* control)
|
CAmount WalletModel::getAvailableBalance(const CCoinControl* control)
|
||||||
{
|
{
|
||||||
return control && control->HasSelected() ? wallet().getAvailableBalance(*control) : getCachedBalance().balance;
|
// No selected coins, return the cached balance
|
||||||
|
if (!control || !control->HasSelected()) {
|
||||||
|
const interfaces::WalletBalances& balances = getCachedBalance();
|
||||||
|
CAmount available_balance = balances.balance;
|
||||||
|
// if wallet private keys are disabled, this is a watch-only wallet
|
||||||
|
// so, let's include the watch-only balance.
|
||||||
|
if (balances.have_watch_only && m_wallet->privateKeysDisabled()) {
|
||||||
|
available_balance += balances.watch_only_balance;
|
||||||
|
}
|
||||||
|
return available_balance;
|
||||||
|
}
|
||||||
|
// Fetch balance from the wallet, taking into account the selected coins
|
||||||
|
return wallet().getAvailableBalance(*control);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue