mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
[qt] Add use available balance in send coins dialog
This commit is contained in:
@@ -410,6 +410,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
|
||||
entry->setModel(model);
|
||||
ui->entries->addWidget(entry);
|
||||
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
|
||||
connect(entry, SIGNAL(useAvailableBalance(SendCoinsEntry*)), this, SLOT(useAvailableBalance(SendCoinsEntry*)));
|
||||
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
|
||||
connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, SLOT(coinControlUpdateLabels()));
|
||||
|
||||
@@ -607,6 +608,31 @@ void SendCoinsDialog::on_buttonMinimizeFee_clicked()
|
||||
minimizeFeeSection(true);
|
||||
}
|
||||
|
||||
void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
|
||||
{
|
||||
// Get CCoinControl instance if CoinControl is enabled or create a new one.
|
||||
CCoinControl coin_control;
|
||||
if (model->getOptionsModel()->getCoinControlFeatures()) {
|
||||
coin_control = *CoinControlDialog::coinControl;
|
||||
}
|
||||
|
||||
// Calculate available amount to send.
|
||||
CAmount amount = model->getBalance(&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) {
|
||||
amount -= e->getValue().amount;
|
||||
}
|
||||
}
|
||||
|
||||
if (amount > 0) {
|
||||
entry->checkSubtractFeeFromAmount();
|
||||
entry->setAmount(amount);
|
||||
} else {
|
||||
entry->setAmount(0);
|
||||
}
|
||||
}
|
||||
|
||||
void SendCoinsDialog::setMinimumFee()
|
||||
{
|
||||
ui->radioCustomPerKilobyte->setChecked(true);
|
||||
|
||||
Reference in New Issue
Block a user