Subtract fee from amount

Fixes #2724 and #1570.

Adds the
automatically-subtract-the-fee-from-the-amount-and-send-whats-left
feature to the GUI and RPC (sendtoaddress,sendmany).
This commit is contained in:
Cozz Lovan
2014-07-23 14:34:36 +02:00
committed by Wladimir J. van der Laan
parent 90a43c1e93
commit 292623adf5
16 changed files with 248 additions and 62 deletions

View File

@@ -221,8 +221,6 @@ void SendCoinsDialog::on_sendButton_clicked()
}
fNewRecipientAllowed = false;
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
@@ -252,7 +250,7 @@ void SendCoinsDialog::on_sendButton_clicked()
// Format confirmation message
QStringList formatted;
foreach(const SendCoinsRecipient &rcp, recipients)
foreach(const SendCoinsRecipient &rcp, currentTransaction.getRecipients())
{
// generate bold amount string
QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
@@ -369,6 +367,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
ui->entries->addWidget(entry);
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, SLOT(coinControlUpdateLabels()));
updateTabsAndLabels();
@@ -784,11 +783,17 @@ void SendCoinsDialog::coinControlUpdateLabels()
// set pay amounts
CoinControlDialog::payAmounts.clear();
CoinControlDialog::fSubtractFeeFromAmount = false;
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
CoinControlDialog::payAmounts.append(entry->getValue().amount);
{
SendCoinsRecipient rcp = entry->getValue();
CoinControlDialog::payAmounts.append(rcp.amount);
if (rcp.fSubtractFeeFromAmount)
CoinControlDialog::fSubtractFeeFromAmount = true;
}
}
if (CoinControlDialog::coinControl->HasSelected())