mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
GUI: 'getAvailableBalance', use cached balance if the user did not select UTXO manually
No need to walk through the entire wallet's tx map. Used for 'walletModel::prepareTransaction' and 'useAvailable' flow in sendcoinsdialog.
This commit is contained in:
@@ -203,7 +203,9 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
||||
return DuplicateAddress;
|
||||
}
|
||||
|
||||
CAmount nBalance = m_wallet->getAvailableBalance(coinControl);
|
||||
// If no coin was manually selected, use the cached balance
|
||||
// Future: can merge this call with 'createTransaction'.
|
||||
CAmount nBalance = getAvailableBalance(&coinControl);
|
||||
|
||||
if(total > nBalance)
|
||||
{
|
||||
@@ -608,3 +610,8 @@ uint256 WalletModel::getLastBlockProcessed() const
|
||||
{
|
||||
return m_client_model ? m_client_model->getBestBlockHash() : uint256{};
|
||||
}
|
||||
|
||||
CAmount WalletModel::getAvailableBalance(const CCoinControl* control)
|
||||
{
|
||||
return control && control->HasSelected() ? wallet().getAvailableBalance(*control) : getCachedBalance().balance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user