mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
gui: bugfix, getAvailableBalance skips selected coins
The previous behavior for getAvailableBalance when coin control has selected coins was to return the sum of them. Instead, we are currently returning the wallet's available total balance minus the selected coins total amount. This turns into a GUI-only issue for the "use available balance" button when the user manually select coins in the send screen. Reason: We missed to update the GetAvailableBalance function to include the coin control selected coins on #25685. Context: Since #25685 we skip the selected coins inside `AvailableCoins`, the reason is that there is no need to traverse the wallet's txes map just to get coins that can directly be fetched by their id.
This commit is contained in:
@@ -791,8 +791,13 @@ void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
|
||||
// Include watch-only for wallets without private key
|
||||
m_coin_control->fAllowWatchOnly = model->wallet().privateKeysDisabled() && !model->wallet().hasExternalSigner();
|
||||
|
||||
// Same behavior as send: if we have selected coins, only obtain their available balance.
|
||||
// Copy to avoid modifying the member's data.
|
||||
CCoinControl coin_control = *m_coin_control;
|
||||
coin_control.m_allow_other_inputs = !coin_control.HasSelected();
|
||||
|
||||
// Calculate available amount to send.
|
||||
CAmount amount = model->getAvailableBalance(m_coin_control.get());
|
||||
CAmount amount = model->getAvailableBalance(&coin_control);
|
||||
for (int i = 0; i < ui->entries->count(); ++i) {
|
||||
SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
||||
if (e && !e->isHidden() && e != entry) {
|
||||
|
||||
Reference in New Issue
Block a user