From 321335bf0292034d79afa6c44f7f072942b6cc3c Mon Sep 17 00:00:00 2001 From: furszy Date: Mon, 9 May 2022 11:24:20 -0300 Subject: GUI: add getter for WalletModel::m_cached_balances field No need to guard it as it is/will only be accessed from the main thread for now --- src/qt/walletmodel.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/qt/walletmodel.h') diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index ad1239ccdc..18951c2858 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -157,6 +157,9 @@ public: uint256 getLastBlockProcessed() const; + // Retrieve the cached wallet balance + interfaces::WalletBalances getCachedBalance() const; + private: std::unique_ptr m_wallet; std::unique_ptr m_handler_unload; -- cgit v1.2.3 From 050e8b139145d6991e740b0e5f2b3364663dd348 Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 27 Apr 2022 11:26:15 -0300 Subject: 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. --- src/qt/walletmodel.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/qt/walletmodel.h') diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 18951c2858..afe93c43e0 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -160,6 +160,10 @@ public: // Retrieve the cached wallet balance interfaces::WalletBalances getCachedBalance() const; + // If coin control has selected outputs, searches the total amount inside the wallet. + // Otherwise, uses the wallet's cached available balance. + CAmount getAvailableBalance(const wallet::CCoinControl* control); + private: std::unique_ptr m_wallet; std::unique_ptr m_handler_unload; -- cgit v1.2.3