As per the title says, we are recalculating the entire wallet balance on different situations calling to wallet().getBalances(), when should instead make use of the wallet model cached balance.
This has the benefits of (1) not spending resources calculating a balance that we already have cached, and (2) avoid blocking the main thread for a long time, in case of big wallets, walking through the entire wallet’s tx map more than what it’s really needed.
Changes:
- Fix:
SendCoinsDialogwas callingwallet().getBalances()twice duringsetModel. - Use the cached balance if the user did not select any UTXO manually inside the wallet model
getAvailableBalancecall.
As an extra note, this work born in #25005 but grew out of scope of it.