aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/coincontrol.h59
-rw-r--r--src/qt/Makefile.am14
-rw-r--r--src/qt/coincontroldialog.cpp766
-rw-r--r--src/qt/coincontroldialog.h92
-rw-r--r--src/qt/coincontroltreewidget.cpp28
-rw-r--r--src/qt/coincontroltreewidget.h17
-rw-r--r--src/qt/forms/coincontroldialog.ui556
-rw-r--r--src/qt/forms/optionsdialog.ui10
-rw-r--r--src/qt/forms/sendcoinsdialog.ui609
-rw-r--r--src/qt/guiutil.cpp6
-rw-r--r--src/qt/guiutil.h2
-rw-r--r--src/qt/optionsdialog.cpp1
-rw-r--r--src/qt/optionsmodel.cpp15
-rw-r--r--src/qt/optionsmodel.h5
-rw-r--r--src/qt/sendcoinsdialog.cpp212
-rw-r--r--src/qt/sendcoinsdialog.h14
-rw-r--r--src/qt/sendcoinsentry.cpp2
-rw-r--r--src/qt/sendcoinsentry.h1
-rw-r--r--src/qt/walletmodel.cpp94
-rw-r--r--src/qt/walletmodel.h23
-rw-r--r--src/wallet.cpp64
-rw-r--r--src/wallet.h9
23 files changed, 2558 insertions, 43 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 24a95eed84..7450507b34 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,7 +13,7 @@ DIST_SUBDIRS = . qt test
# bitcoin core #
BITCOIN_CORE_H = addrman.h alert.h allocators.h base58.h bignum.h \
bitcoinrpc.h bloom.h chainparams.h checkpoints.h checkqueue.h \
- clientversion.h compat.h core.h coins.h crypter.h db.h hash.h init.h \
+ clientversion.h coincontrol.h compat.h core.h coins.h crypter.h db.h hash.h init.h \
key.h keystore.h leveldbwrapper.h limitedmap.h main.h miner.h mruset.h \
netbase.h net.h noui.h protocol.h script.h serialize.h sync.h threadsafety.h \
txdb.h txmempool.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h
diff --git a/src/coincontrol.h b/src/coincontrol.h
new file mode 100644
index 0000000000..0164bf1f84
--- /dev/null
+++ b/src/coincontrol.h
@@ -0,0 +1,59 @@
+#ifndef COINCONTROL_H
+#define COINCONTROL_H
+
+#include "core.h"
+
+/** Coin Control Features. */
+class CCoinControl
+{
+public:
+ CTxDestination destChange;
+
+ CCoinControl()
+ {
+ SetNull();
+ }
+
+ void SetNull()
+ {
+ destChange = CNoDestination();
+ setSelected.clear();
+ }
+
+ bool HasSelected() const
+ {
+ return (setSelected.size() > 0);
+ }
+
+ bool IsSelected(const uint256& hash, unsigned int n) const
+ {
+ COutPoint outpt(hash, n);
+ return (setSelected.count(outpt) > 0);
+ }
+
+ void Select(COutPoint& output)
+ {
+ setSelected.insert(output);
+ }
+
+ void UnSelect(COutPoint& output)
+ {
+ setSelected.erase(output);
+ }
+
+ void UnSelectAll()
+ {
+ setSelected.clear();
+ }
+
+ void ListSelected(std::vector<COutPoint>& vOutpoints)
+ {
+ vOutpoints.assign(setSelected.begin(), setSelected.end());
+ }
+
+private:
+ std::set<COutPoint> setSelected;
+
+};
+
+#endif // COINCONTROL_H
diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am
index a19cdc25a5..53126b39f8 100644
--- a/src/qt/Makefile.am
+++ b/src/qt/Makefile.am
@@ -32,7 +32,10 @@ QT_TS = locale/bitcoin_ach.ts locale/bitcoin_af_ZA.ts locale/bitcoin_ar.ts \
locale/bitcoin_zh_CN.ts locale/bitcoin_zh_TW.ts
QT_FORMS_UI = forms/aboutdialog.ui forms/addressbookpage.ui \
- forms/askpassphrasedialog.ui forms/editaddressdialog.ui forms/intro.ui \
+ forms/askpassphrasedialog.ui \
+ forms/coincontroldialog.ui \
+ forms/editaddressdialog.ui \
+ forms/intro.ui \
forms/openuridialog.ui \
forms/optionsdialog.ui forms/overviewpage.ui forms/receiverequestdialog.ui \
forms/receivecoinsdialog.ui \
@@ -43,6 +46,8 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
moc_addresstablemodel.cpp moc_askpassphrasedialog.cpp \
moc_bitcoinaddressvalidator.cpp moc_bitcoinamountfield.cpp \
moc_bitcoingui.cpp moc_bitcoinunits.cpp moc_clientmodel.cpp \
+ moc_coincontroldialog.cpp \
+ moc_coincontroltreewidget.cpp \
moc_csvmodelwriter.cpp moc_editaddressdialog.cpp moc_guiutil.cpp \
moc_intro.cpp moc_macdockiconhandler.cpp moc_macnotificationhandler.cpp \
moc_monitoreddatamapper.cpp moc_notificator.cpp \
@@ -70,7 +75,7 @@ PROTOBUF_PROTO = paymentrequest.proto
BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
askpassphrasedialog.h bitcoinaddressvalidator.h bitcoinamountfield.h \
- bitcoingui.h bitcoinunits.h clientmodel.h csvmodelwriter.h \
+ bitcoingui.h bitcoinunits.h clientmodel.h coincontroldialog.h coincontroltreewidget.h csvmodelwriter.h \
editaddressdialog.h guiconstants.h guiutil.h intro.h macdockiconhandler.h \
macnotificationhandler.h monitoreddatamapper.h notificator.h \
openuridialog.h \
@@ -103,7 +108,10 @@ RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
addresstablemodel.cpp askpassphrasedialog.cpp bitcoinaddressvalidator.cpp \
bitcoinamountfield.cpp bitcoin.cpp bitcoingui.cpp \
- bitcoinunits.cpp clientmodel.cpp csvmodelwriter.cpp editaddressdialog.cpp \
+ bitcoinunits.cpp clientmodel.cpp \
+ coincontroldialog.cpp \
+ coincontroltreewidget.cpp \
+ csvmodelwriter.cpp editaddressdialog.cpp \
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
openuridialog.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
new file mode 100644
index 0000000000..58f5113453
--- /dev/null
+++ b/src/qt/coincontroldialog.cpp
@@ -0,0 +1,766 @@
+#include "coincontroldialog.h"
+#include "ui_coincontroldialog.h"
+
+#include "init.h"
+#include "bitcoinunits.h"
+#include "walletmodel.h"
+#include "addresstablemodel.h"
+#include "optionsmodel.h"
+#include "guiutil.h"
+#include "coincontrol.h"
+#include "main.h"
+#include "wallet.h"
+
+#include <QApplication>
+#include <QCheckBox>
+#include <QClipboard>
+#include <QColor>
+#include <QCursor>
+#include <QDateTime>
+#include <QDialogButtonBox>
+#include <QFlags>
+#include <QIcon>
+#include <QString>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+
+using namespace std;
+QList<qint64> CoinControlDialog::payAmounts;
+CCoinControl* CoinControlDialog::coinControl = new CCoinControl();
+
+CoinControlDialog::CoinControlDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::CoinControlDialog),
+ model(0)
+{
+ ui->setupUi(this);
+
+ // context menu actions
+ QAction *copyAddressAction = new QAction(tr("Copy address"), this);
+ QAction *copyLabelAction = new QAction(tr("Copy label"), this);
+ QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
+ copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this
+ lockAction = new QAction(tr("Lock unspent"), this); // we need to enable/disable this
+ unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this
+
+ // context menu
+ contextMenu = new QMenu();
+ contextMenu->addAction(copyAddressAction);
+ contextMenu->addAction(copyLabelAction);
+ contextMenu->addAction(copyAmountAction);
+ contextMenu->addAction(copyTransactionHashAction);
+ contextMenu->addSeparator();
+ contextMenu->addAction(lockAction);
+ contextMenu->addAction(unlockAction);
+
+ // context menu signals
+ connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint)));
+ connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
+ connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
+ connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
+ connect(copyTransactionHashAction, SIGNAL(triggered()), this, SLOT(copyTransactionHash()));
+ connect(lockAction, SIGNAL(triggered()), this, SLOT(lockCoin()));
+ connect(unlockAction, SIGNAL(triggered()), this, SLOT(unlockCoin()));
+
+ // clipboard actions
+ QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
+ QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
+ QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
+ QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
+ QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
+ QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this);
+ QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this);
+ QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
+
+ connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(clipboardQuantity()));
+ connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(clipboardAmount()));
+ connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(clipboardFee()));
+ connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(clipboardAfterFee()));
+ connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(clipboardBytes()));
+ connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(clipboardPriority()));
+ connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(clipboardLowOutput()));
+ connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(clipboardChange()));
+
+ ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
+ ui->labelCoinControlAmount->addAction(clipboardAmountAction);
+ ui->labelCoinControlFee->addAction(clipboardFeeAction);
+ ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
+ ui->labelCoinControlBytes->addAction(clipboardBytesAction);
+ ui->labelCoinControlPriority->addAction(clipboardPriorityAction);
+ ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
+ ui->labelCoinControlChange->addAction(clipboardChangeAction);
+
+ // toggle tree/list mode
+ connect(ui->radioTreeMode, SIGNAL(toggled(bool)), this, SLOT(radioTreeMode(bool)));
+ connect(ui->radioListMode, SIGNAL(toggled(bool)), this, SLOT(radioListMode(bool)));
+
+ // click on checkbox
+ connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int)));
+
+ // click on header
+ ui->treeWidget->header()->setClickable(true);
+ connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int)));
+
+ // ok button
+ connect(ui->buttonBox, SIGNAL(clicked( QAbstractButton*)), this, SLOT(buttonBoxClicked(QAbstractButton*)));
+
+ // (un)select all
+ connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked()));
+
+ ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84);
+ ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 100);
+ ui->treeWidget->setColumnWidth(COLUMN_LABEL, 170);
+ ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 290);
+ ui->treeWidget->setColumnWidth(COLUMN_DATE, 110);
+ ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 100);
+ ui->treeWidget->setColumnWidth(COLUMN_PRIORITY, 100);
+ ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transacton hash in this column, but dont show it
+ ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but dont show it
+ ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64 in this column, but dont show it
+ ui->treeWidget->setColumnHidden(COLUMN_PRIORITY_INT64, true); // store priority int64 in this column, but dont show it
+
+ // default view is sorted by amount desc
+ sortView(COLUMN_AMOUNT_INT64, Qt::DescendingOrder);
+}
+
+CoinControlDialog::~CoinControlDialog()
+{
+ delete ui;
+}
+
+void CoinControlDialog::setModel(WalletModel *model)
+{
+ this->model = model;
+
+ if(model && model->getOptionsModel() && model->getAddressTableModel())
+ {
+ updateView();
+ updateLabelLocked();
+ CoinControlDialog::updateLabels(model, this);
+ }
+}
+
+// helper function str_pad
+QString CoinControlDialog::strPad(QString s, int nPadLength, QString sPadding)
+{
+ while (s.length() < nPadLength)
+ s = sPadding + s;
+
+ return s;
+}
+
+// ok button
+void CoinControlDialog::buttonBoxClicked(QAbstractButton* button)
+{
+ if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
+ done(QDialog::Accepted); // closes the dialog
+}
+
+// (un)select all
+void CoinControlDialog::buttonSelectAllClicked()
+{
+ Qt::CheckState state = Qt::Checked;
+ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
+ {
+ if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != Qt::Unchecked)
+ {
+ state = Qt::Unchecked;
+ break;
+ }
+ }
+ ui->treeWidget->setEnabled(false);
+ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
+ if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state)
+ ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state);
+ ui->treeWidget->setEnabled(true);
+ if (state == Qt::Unchecked)
+ coinControl->UnSelectAll(); // just to be sure
+ CoinControlDialog::updateLabels(model, this);
+}
+
+// context menu
+void CoinControlDialog::showMenu(const QPoint &point)
+{
+ QTreeWidgetItem *item = ui->treeWidget->itemAt(point);
+ if(item)
+ {
+ contextMenuItem = item;
+
+ // disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu
+ if (item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode)
+ {
+ copyTransactionHashAction->setEnabled(true);
+ if (model->isLockedCoin(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt()))
+ {
+ lockAction->setEnabled(false);
+ unlockAction->setEnabled(true);
+ }
+ else
+ {
+ lockAction->setEnabled(true);
+ unlockAction->setEnabled(false);
+ }
+ }
+ else // this means click on parent node in tree mode -> disable all
+ {
+ copyTransactionHashAction->setEnabled(false);
+ lockAction->setEnabled(false);
+ unlockAction->setEnabled(false);
+ }
+
+ // show context menu
+ contextMenu->exec(QCursor::pos());
+ }
+}
+
+// context menu action: copy amount
+void CoinControlDialog::copyAmount()
+{
+ GUIUtil::setClipboard(contextMenuItem->text(COLUMN_AMOUNT));
+}
+
+// context menu action: copy label
+void CoinControlDialog::copyLabel()
+{
+ if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_LABEL).length() == 0 && contextMenuItem->parent())
+ GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_LABEL));
+ else
+ GUIUtil::setClipboard(contextMenuItem->text(COLUMN_LABEL));
+}
+
+// context menu action: copy address
+void CoinControlDialog::copyAddress()
+{
+ if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_ADDRESS).length() == 0 && contextMenuItem->parent())
+ GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_ADDRESS));
+ else
+ GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS));
+}
+
+// context menu action: copy transaction id
+void CoinControlDialog::copyTransactionHash()
+{
+ GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH));
+}
+
+// context menu action: lock coin
+void CoinControlDialog::lockCoin()
+{
+ if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked)
+ contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
+
+ COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt());
+ model->lockCoin(outpt);
+ contextMenuItem->setDisabled(true);
+ contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed"));
+ updateLabelLocked();
+}
+
+// context menu action: unlock coin
+void CoinControlDialog::unlockCoin()
+{
+ COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt());
+ model->unlockCoin(outpt);
+ contextMenuItem->setDisabled(false);
+ contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon());
+ updateLabelLocked();
+}
+
+// copy label "Quantity" to clipboard
+void CoinControlDialog::clipboardQuantity()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
+}
+
+// copy label "Amount" to clipboard
+void CoinControlDialog::clipboardAmount()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
+}
+
+// copy label "Fee" to clipboard
+void CoinControlDialog::clipboardFee()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
+}
+
+// copy label "After fee" to clipboard
+void CoinControlDialog::clipboardAfterFee()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
+}
+
+// copy label "Bytes" to clipboard
+void CoinControlDialog::clipboardBytes()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlBytes->text());
+}
+
+// copy label "Priority" to clipboard
+void CoinControlDialog::clipboardPriority()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlPriority->text());
+}
+
+// copy label "Low output" to clipboard
+void CoinControlDialog::clipboardLowOutput()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
+}
+
+// copy label "Change" to clipboard
+void CoinControlDialog::clipboardChange()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
+}
+
+// treeview: sort
+void CoinControlDialog::sortView(int column, Qt::SortOrder order)
+{
+ sortColumn = column;
+ sortOrder = order;
+ ui->treeWidget->sortItems(column, order);
+ ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder);
+}
+
+// treeview: clicked on header
+void CoinControlDialog::headerSectionClicked(int logicalIndex)
+{
+ if (logicalIndex == COLUMN_CHECKBOX) // click on most left column -> do nothing
+ {
+ ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder);
+ }
+ else
+ {
+ if (logicalIndex == COLUMN_AMOUNT) // sort by amount
+ logicalIndex = COLUMN_AMOUNT_INT64;
+
+ if (logicalIndex == COLUMN_PRIORITY) // sort by priority
+ logicalIndex = COLUMN_PRIORITY_INT64;
+
+ if (sortColumn == logicalIndex)
+ sortOrder = ((sortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder);
+ else
+ {
+ sortColumn = logicalIndex;
+ sortOrder = ((sortColumn == COLUMN_AMOUNT_INT64 || sortColumn == COLUMN_PRIORITY_INT64 || sortColumn == COLUMN_DATE || sortColumn == COLUMN_CONFIRMATIONS) ? Qt::DescendingOrder : Qt::AscendingOrder); // if amount,date,conf,priority then default => desc, else default => asc
+ }
+
+ sortView(sortColumn, sortOrder);
+ }
+}
+
+// toggle tree mode
+void CoinControlDialog::radioTreeMode(bool checked)
+{
+ if (checked && model)
+ updateView();
+}
+
+// toggle list mode
+void CoinControlDialog::radioListMode(bool checked)
+{
+ if (checked && model)
+ updateView();
+}
+
+// checkbox clicked by user
+void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
+{
+ if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode)
+ {
+ COutPoint outpt(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt());
+
+ if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked)
+ coinControl->UnSelect(outpt);
+ else if (item->isDisabled()) // locked (this happens if "check all" through parent node)
+ item->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
+ else
+ coinControl->Select(outpt);
+
+ // selection changed -> update labels
+ if (ui->treeWidget->isEnabled()) // do not update on every click for (un)select all
+ CoinControlDialog::updateLabels(model, this);
+ }
+}
+
+// return human readable label for priority number
+QString CoinControlDialog::getPriorityLabel(double dPriority)
+{
+ if (AllowFree(dPriority)) // at least medium
+ {
+ if (AllowFree(dPriority / 1000000)) return tr("highest");
+ else if (AllowFree(dPriority / 100000)) return tr("higher");
+ else if (AllowFree(dPriority / 10000)) return tr("high");
+ else if (AllowFree(dPriority / 1000)) return tr("medium-high");
+ else return tr("medium");
+ }
+ else
+ {
+ if (AllowFree(dPriority * 10)) return tr("low-medium");
+ else if (AllowFree(dPriority * 100)) return tr("low");
+ else if (AllowFree(dPriority * 1000)) return tr("lower");
+ else return tr("lowest");
+ }
+}
+
+// shows count of locked unspent outputs
+void CoinControlDialog::updateLabelLocked()
+{
+ vector<COutPoint> vOutpts;
+ model->listLockedCoins(vOutpts);
+ if (vOutpts.size() > 0)
+ {
+ ui->labelLocked->setText(tr("(%1 locked)").arg(vOutpts.size()));
+ ui->labelLocked->setVisible(true);
+ }
+ else ui->labelLocked->setVisible(false);
+}
+
+void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
+{
+ if (!model) return;
+
+ // nPayAmount
+ qint64 nPayAmount = 0;
+ bool fLowOutput = false;
+ bool fDust = false;
+ CTransaction txDummy;
+ foreach(const qint64 &amount, CoinControlDialog::payAmounts)
+ {
+ nPayAmount += amount;
+
+ if (amount > 0)
+ {
+ if (amount < CENT)
+ fLowOutput = true;
+
+ CTxOut txout(amount, (CScript)vector<unsigned char>(24, 0));
+ txDummy.vout.push_back(txout);
+ if (txout.IsDust(CTransaction::nMinRelayTxFee))
+ fDust = true;
+ }
+ }
+
+ QString sPriorityLabel = "";
+ int64_t nAmount = 0;
+ int64_t nPayFee = 0;
+ int64_t nAfterFee = 0;
+ int64_t nChange = 0;
+ unsigned int nBytes = 0;
+ unsigned int nBytesInputs = 0;
+ double dPriority = 0;
+ double dPriorityInputs = 0;
+ unsigned int nQuantity = 0;
+ int nQuantityUncompressed = 0;
+
+ vector<COutPoint> vCoinControl;
+ vector<COutput> vOutputs;
+ coinControl->ListSelected(vCoinControl);
+ model->getOutputs(vCoinControl, vOutputs);
+
+ BOOST_FOREACH(const COutput& out, vOutputs)
+ {
+ // unselect already spent, very unlikely scenario, this could happen when selected are spent elsewhere, like rpc or another computer
+ if (out.tx->IsSpent(out.i))
+ {
+ uint256 txhash = out.tx->GetHash();
+ COutPoint outpt(txhash, out.i);
+ coinControl->UnSelect(outpt);
+ continue;
+ }
+
+ // Quantity
+ nQuantity++;
+
+ // Amount
+ nAmount += out.tx->vout[out.i].nValue;
+
+ // Priority
+ dPriorityInputs += (double)out.tx->vout[out.i].nValue * (out.nDepth+1);
+
+ // Bytes
+ CTxDestination address;
+ if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
+ {
+ CPubKey pubkey;
+ CKeyID *keyid = boost::get<CKeyID>(&address);
+ if (keyid && model->getPubKey(*keyid, pubkey))
+ {
+ nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);
+ if (!pubkey.IsCompressed())
+ nQuantityUncompressed++;
+ }
+ else
+ nBytesInputs += 148; // in all error cases, simply assume 148 here
+ }
+ else nBytesInputs += 148;
+ }
+
+ // calculation
+ if (nQuantity > 0)
+ {
+ // Bytes
+ nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here
+
+ // Priority
+ dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
+ sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority);
+
+ // Fee
+ int64_t nFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
+
+ // Min Fee
+ int64_t nMinFee = GetMinFee(txDummy, nBytes, AllowFree(dPriority), GMF_SEND);
+
+ nPayFee = max(nFee, nMinFee);
+
+ if (nPayAmount > 0)
+ {
+ nChange = nAmount - nPayFee - nPayAmount;
+
+ // if sub-cent change is required, the fee must be raised to at least CTransaction::nMinTxFee
+ if (nPayFee < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT)
+ {
+ if (nChange < CTransaction::nMinTxFee) // change < 0.0001 => simply move all change to fees
+ {
+ nPayFee += nChange;
+ nChange = 0;
+ }
+ else
+ {
+ nChange = nChange + nPayFee - CTransaction::nMinTxFee;
+ nPayFee = CTransaction::nMinTxFee;
+ }
+ }
+
+ // Never create dust outputs; if we would, just add the dust to the fee.
+ if (nChange > 0 && nChange < CENT)
+ {
+ CTxOut txout(nChange, (CScript)vector<unsigned char>(24, 0));
+ if (txout.IsDust(CTransaction::nMinRelayTxFee))
+ {
+ nPayFee += nChange;
+ nChange = 0;
+ }
+ }
+
+ if (nChange == 0)
+ nBytes -= 34;
+ }
+
+ // after fee
+ nAfterFee = nAmount - nPayFee;
+ if (nAfterFee < 0)
+ nAfterFee = 0;
+ }
+
+ // actually update labels
+ int nDisplayUnit = BitcoinUnits::BTC;
+ if (model && model->getOptionsModel())
+ nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
+
+ QLabel *l1 = dialog->findChild<QLabel *>("labelCoinControlQuantity");
+ QLabel *l2 = dialog->findChild<QLabel *>("labelCoinControlAmount");
+ QLabel *l3 = dialog->findChild<QLabel *>("labelCoinControlFee");
+ QLabel *l4 = dialog->findChild<QLabel *>("labelCoinControlAfterFee");
+ QLabel *l5 = dialog->findChild<QLabel *>("labelCoinControlBytes");
+ QLabel *l6 = dialog->findChild<QLabel *>("labelCoinControlPriority");
+ QLabel *l7 = dialog->findChild<QLabel *>("labelCoinControlLowOutput");
+ QLabel *l8 = dialog->findChild<QLabel *>("labelCoinControlChange");
+
+ // enable/disable "low output" and "change"
+ dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setEnabled(nPayAmount > 0);
+ dialog->findChild<QLabel *>("labelCoinControlLowOutput") ->setEnabled(nPayAmount > 0);
+ dialog->findChild<QLabel *>("labelCoinControlChangeText") ->setEnabled(nPayAmount > 0);
+ dialog->findChild<QLabel *>("labelCoinControlChange") ->setEnabled(nPayAmount > 0);
+
+ // stats
+ l1->setText(QString::number(nQuantity)); // Quantity
+ l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount
+ l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee
+ l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee
+ l5->setText(((nBytes > 0) ? "~" : "") + QString::number(nBytes)); // Bytes
+ l6->setText(sPriorityLabel); // Priority
+ l7->setText((fLowOutput ? (fDust ? tr("DUST") : tr("yes")) : tr("no"))); // Low Output / Dust
+ l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change
+
+ // turn labels "red"
+ l5->setStyleSheet((nBytes >= 1000) ? "color:red;" : ""); // Bytes >= 1000
+ l6->setStyleSheet((!AllowFree(dPriority)) ? "color:red;" : ""); // Priority < "medium"
+ l7->setStyleSheet((fLowOutput) ? "color:red;" : ""); // Low Output = "yes"
+ l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01BTC
+
+ // tool tips
+ l5->setToolTip(tr("This label turns red, if the transaction size is bigger than 1000 bytes.\n\n This means a fee of at least %1 per kb is required.\n\n Can vary +/- 1 Byte per input.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
+ l6->setToolTip(tr("Transactions with higher priority get more likely into a block.\n\nThis label turns red, if the priority is smaller than \"medium\".\n\n This means a fee of at least %1 per kb is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
+ l7->setToolTip(tr("This label turns red, if any recipient receives an amount smaller than %1.\n\n This means a fee of at least %2 is required. \n\n Amounts below 0.546 times the minimum relay fee are shown as DUST.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
+ l8->setToolTip(tr("This label turns red, if the change is smaller than %1.\n\n This means a fee of at least %2 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
+ dialog->findChild<QLabel *>("labelCoinControlBytesText") ->setToolTip(l5->toolTip());
+ dialog->findChild<QLabel *>("labelCoinControlPriorityText") ->setToolTip(l6->toolTip());
+ dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setToolTip(l7->toolTip());
+ dialog->findChild<QLabel *>("labelCoinControlChangeText") ->setToolTip(l8->toolTip());
+
+ // Insufficient funds
+ QLabel *label = dialog->findChild<QLabel *>("labelCoinControlInsuffFunds");
+ if (label)
+ label->setVisible(nChange < 0);
+}
+
+void CoinControlDialog::updateView()
+{
+ bool treeMode = ui->radioTreeMode->isChecked();
+
+ ui->treeWidget->clear();
+ ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox
+ ui->treeWidget->setAlternatingRowColors(!treeMode);
+ QFlags<Qt::ItemFlag> flgCheckbox=Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
+ QFlags<Qt::ItemFlag> flgTristate=Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
+
+ int nDisplayUnit = BitcoinUnits::BTC;
+ if (model && model->getOptionsModel())
+ nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
+
+ map<QString, vector<COutput> > mapCoins;
+ model->listCoins(mapCoins);
+
+ BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins)
+ {
+ QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem();
+ QString sWalletAddress = coins.first;
+ QString sWalletLabel = "";
+ if (model->getAddressTableModel())
+ sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);
+ if (sWalletLabel.length() == 0)
+ sWalletLabel = tr("(no label)");
+
+ if (treeMode)
+ {
+ // wallet address
+ ui->treeWidget->addTopLevelItem(itemWalletAddress);
+
+ itemWalletAddress->setFlags(flgTristate);
+ itemWalletAddress->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);
+
+ for (int i = 0; i < ui->treeWidget->columnCount(); i++)
+ itemWalletAddress->setBackground(i, QColor(248, 247, 246));
+
+ // label
+ itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel);
+
+ // address
+ itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress);
+ }
+
+ int64_t nSum = 0;
+ double dPrioritySum = 0;
+ int nChildren = 0;
+ int nInputSum = 0;
+ BOOST_FOREACH(const COutput& out, coins.second)
+ {
+ int nInputSize = 0;
+ nSum += out.tx->vout[out.i].nValue;
+ nChildren++;
+
+ QTreeWidgetItem *itemOutput;
+ if (treeMode) itemOutput = new QTreeWidgetItem(itemWalletAddress);
+ else itemOutput = new QTreeWidgetItem(ui->treeWidget);
+ itemOutput->setFlags(flgCheckbox);
+ itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);
+
+ // address
+ CTxDestination outputAddress;
+ QString sAddress = "";
+ if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress))
+ {
+ sAddress = CBitcoinAddress(outputAddress).ToString().c_str();
+
+ // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs
+ if (!treeMode || (!(sAddress == sWalletAddress)))
+ itemOutput->setText(COLUMN_ADDRESS, sAddress);
+
+ CPubKey pubkey;
+ CKeyID *keyid = boost::get<CKeyID>(&outputAddress);
+ if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed())
+ nInputSize = 29; // 29 = 180 - 151 (public key is 180 bytes, priority free area is 151 bytes)
+ }
+
+ // label
+ if (!(sAddress == sWalletAddress)) // change
+ {
+ // tooltip from where the change comes from
+ itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWalletLabel).arg(sWalletAddress));
+ itemOutput->setText(COLUMN_LABEL, tr("(change)"));
+ }
+ else if (!treeMode)
+ {
+ QString sLabel = "";
+ if (model->getAddressTableModel())
+ sLabel = model->getAddressTableModel()->labelForAddress(sAddress);
+ if (sLabel.length() == 0)
+ sLabel = tr("(no label)");
+ itemOutput->setText(COLUMN_LABEL, sLabel);
+ }
+
+ // amount
+ itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx->vout[out.i].nValue));
+ itemOutput->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(out.tx->vout[out.i].nValue), 15, " ")); // padding so that sorting works correctly
+
+ // date
+ itemOutput->setText(COLUMN_DATE, QDateTime::fromTime_t(out.tx->GetTxTime()).toString("yy-MM-dd hh:mm"));
+
+ // confirmations
+ itemOutput->setText(COLUMN_CONFIRMATIONS, strPad(QString::number(out.nDepth), 8, " "));
+
+ // priority
+ double dPriority = ((double)out.tx->vout[out.i].nValue / (nInputSize + 78)) * (out.nDepth+1); // 78 = 2 * 34 + 10
+ itemOutput->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPriority));
+ itemOutput->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPriority), 20, " "));
+ dPrioritySum += (double)out.tx->vout[out.i].nValue * (out.nDepth+1);
+ nInputSum += nInputSize;
+
+ // transaction hash
+ uint256 txhash = out.tx->GetHash();
+ itemOutput->setText(COLUMN_TXHASH, txhash.GetHex().c_str());
+
+ // vout index
+ itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i));
+
+ // disable locked coins
+ if (model->isLockedCoin(txhash, out.i))
+ {
+ COutPoint outpt(txhash, out.i);
+ coinControl->UnSelect(outpt); // just to be sure
+ itemOutput->setDisabled(true);
+ itemOutput->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed"));
+ }
+
+ // set checkbox
+ if (coinControl->IsSelected(txhash, out.i))
+ itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked);
+ }
+
+ // amount
+ if (treeMode)
+ {
+ dPrioritySum = dPrioritySum / (nInputSum + 78);
+ itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")");
+ itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum));
+ itemWalletAddress->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(nSum), 15, " "));
+ itemWalletAddress->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPrioritySum));
+ itemWalletAddress->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPrioritySum), 20, " "));
+ }
+ }
+
+ // expand all partially selected
+ if (treeMode)
+ {
+ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
+ if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked)
+ ui->treeWidget->topLevelItem(i)->setExpanded(true);
+ }
+
+ // sort view
+ sortView(sortColumn, sortOrder);
+ ui->treeWidget->setEnabled(true);
+}
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
new file mode 100644
index 0000000000..2674bab4f2
--- /dev/null
+++ b/src/qt/coincontroldialog.h
@@ -0,0 +1,92 @@
+#ifndef COINCONTROLDIALOG_H
+#define COINCONTROLDIALOG_H
+
+#include <QAbstractButton>
+#include <QAction>
+#include <QDialog>
+#include <QList>
+#include <QMenu>
+#include <QPoint>
+#include <QString>
+#include <QTreeWidgetItem>
+
+namespace Ui {
+ class CoinControlDialog;
+}
+class WalletModel;
+class CCoinControl;
+
+class CoinControlDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit CoinControlDialog(QWidget *parent = 0);
+ ~CoinControlDialog();
+
+ void setModel(WalletModel *model);
+
+ // static because also called from sendcoinsdialog
+ static void updateLabels(WalletModel*, QDialog*);
+ static QString getPriorityLabel(double);
+
+ static QList<qint64> payAmounts;
+ static CCoinControl *coinControl;
+
+private:
+ Ui::CoinControlDialog *ui;
+ WalletModel *model;
+ int sortColumn;
+ Qt::SortOrder sortOrder;
+
+ QMenu *contextMenu;
+ QTreeWidgetItem *contextMenuItem;
+ QAction *copyTransactionHashAction;
+ QAction *lockAction;
+ QAction *unlockAction;
+
+ QString strPad(QString, int, QString);
+ void sortView(int, Qt::SortOrder);
+ void updateView();
+
+ enum
+ {
+ COLUMN_CHECKBOX,
+ COLUMN_AMOUNT,
+ COLUMN_LABEL,
+ COLUMN_ADDRESS,
+ COLUMN_DATE,
+ COLUMN_CONFIRMATIONS,
+ COLUMN_PRIORITY,
+ COLUMN_TXHASH,
+ COLUMN_VOUT_INDEX,
+ COLUMN_AMOUNT_INT64,
+ COLUMN_PRIORITY_INT64
+ };
+
+private slots:
+ void showMenu(const QPoint &);
+ void copyAmount();
+ void copyLabel();
+ void copyAddress();
+ void copyTransactionHash();
+ void lockCoin();
+ void unlockCoin();
+ void clipboardQuantity();
+ void clipboardAmount();
+ void clipboardFee();
+ void clipboardAfterFee();
+ void clipboardBytes();
+ void clipboardPriority();
+ void clipboardLowOutput();
+ void clipboardChange();
+ void radioTreeMode(bool);
+ void radioListMode(bool);
+ void viewItemChanged(QTreeWidgetItem*, int);
+ void headerSectionClicked(int);
+ void buttonBoxClicked(QAbstractButton*);
+ void buttonSelectAllClicked();
+ void updateLabelLocked();
+};
+
+#endif // COINCONTROLDIALOG_H
diff --git a/src/qt/coincontroltreewidget.cpp b/src/qt/coincontroltreewidget.cpp
new file mode 100644
index 0000000000..aa75a49ae6
--- /dev/null
+++ b/src/qt/coincontroltreewidget.cpp
@@ -0,0 +1,28 @@
+#include "coincontroltreewidget.h"
+#include "coincontroldialog.h"
+
+CoinControlTreeWidget::CoinControlTreeWidget(QWidget *parent) :
+ QTreeWidget(parent)
+{
+
+}
+
+void CoinControlTreeWidget::keyPressEvent(QKeyEvent *event)
+{
+ if (event->key() == Qt::Key_Space) // press spacebar -> select checkbox
+ {
+ event->ignore();
+ int COLUMN_CHECKBOX = 0;
+ this->currentItem()->setCheckState(COLUMN_CHECKBOX, ((this->currentItem()->checkState(COLUMN_CHECKBOX) == Qt::Checked) ? Qt::Unchecked : Qt::Checked));
+ }
+ else if (event->key() == Qt::Key_Escape) // press esc -> close dialog
+ {
+ event->ignore();
+ CoinControlDialog *coinControlDialog = (CoinControlDialog*)this->parentWidget();
+ coinControlDialog->done(QDialog::Accepted);
+ }
+ else
+ {
+ this->QTreeWidget::keyPressEvent(event);
+ }
+} \ No newline at end of file
diff --git a/src/qt/coincontroltreewidget.h b/src/qt/coincontroltreewidget.h
new file mode 100644
index 0000000000..e55b98af68
--- /dev/null
+++ b/src/qt/coincontroltreewidget.h
@@ -0,0 +1,17 @@
+#ifndef COINCONTROLTREEWIDGET_H
+#define COINCONTROLTREEWIDGET_H
+
+#include <QKeyEvent>
+#include <QTreeWidget>
+
+class CoinControlTreeWidget : public QTreeWidget {
+Q_OBJECT
+
+public:
+ explicit CoinControlTreeWidget(QWidget *parent = 0);
+
+protected:
+ virtual void keyPressEvent(QKeyEvent *event);
+};
+
+#endif // COINCONTROLTREEWIDGET_H \ No newline at end of file
diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui
new file mode 100644
index 0000000000..58f6557fa5
--- /dev/null
+++ b/src/qt/forms/coincontroldialog.ui
@@ -0,0 +1,556 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CoinControlDialog</class>
+ <widget class="QDialog" name="CoinControlDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1000</width>
+ <height>500</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Coin Control</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayoutTop" stretch="0,0,0,0">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl1">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>10</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlQuantityText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Quantity:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlQuantity">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlBytesText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Bytes:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlBytes">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl2">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>10</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlAmountText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Amount:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlAmount">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlPriorityText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Priority:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlPriority">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl3">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>10</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlFeeText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Fee:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlFee">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlLowOutputText">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Low Output:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlLowOutput">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string>no</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl4">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>10</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlAfterFeeText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>After Fee:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlAfterFee">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlChangeText">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Change:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlChange">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QFrame" name="frame">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>40</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <widget class="QWidget" name="horizontalLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>0</y>
+ <width>781</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayoutPanel" stretch="0,0,0,0,0">
+ <property name="spacing">
+ <number>14</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="pushButtonSelectAll">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>(un)select all</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioTreeMode">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Tree mode</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioListMode">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>List mode</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelLocked">
+ <property name="text">
+ <string>(1 locked)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="CoinControlTreeWidget" name="treeWidget">
+ <property name="contextMenuPolicy">
+ <enum>Qt::CustomContextMenu</enum>
+ </property>
+ <property name="sortingEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="columnCount">
+ <number>11</number>
+ </property>
+ <attribute name="headerShowSortIndicator" stdset="0">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="headerStretchLastSection">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string/>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Amount</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string notr="true">Label</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Address</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Date</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Confirmations</string>
+ </property>
+ <property name="toolTip">
+ <string>Confirmed</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Priority</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string/>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string/>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string/>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string/>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>CoinControlTreeWidget</class>
+ <extends>QTreeWidget</extends>
+ <header>coincontroltreewidget.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 1e4335c645..90d720b089 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -364,6 +364,16 @@
</widget>
</item>
<item>
+ <widget class="QCheckBox" name="coinControlFeatures">
+ <property name="toolTip">
+ <string>Whether to show coin control features or not.</string>
+ </property>
+ <property name="text">
+ <string>Display coin &amp;control features (experts only!)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_Display">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index 7547931ff1..790d5d6c39 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -6,14 +6,615 @@
<rect>
<x>0</x>
<y>0</y>
- <width>686</width>
- <height>217</height>
+ <width>850</width>
+ <height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Send Coins</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
+ <property name="bottomMargin">
+ <number>8</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="frameCoinControl">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayoutCoinControl2">
+ <property name="spacing">
+ <number>-1</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayoutCoinControl" stretch="0,0,0,0,1">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>10</number>
+ </property>
+ <property name="topMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayoutCoinControl1">
+ <property name="bottomMargin">
+ <number>15</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="labelCoinControlFeatures">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Coin Control Features</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayoutCoinControl2" stretch="0,0,0,0">
+ <property name="spacing">
+ <number>8</number>
+ </property>
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="pushButtonCoinControl">
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Inputs...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelCoinControlAutomaticallySelected">
+ <property name="text">
+ <string>automatically selected</string>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelCoinControlInsuffFunds">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">color:red;font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Insufficient funds!</string>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacerCoinControl">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>1</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QWidget" name="widgetCoinControl" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayoutCoinControl5">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayoutCoinControl3" stretch="0,0,0,1">
+ <property name="spacing">
+ <number>20</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl1">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>14</number>
+ </property>
+ <property name="leftMargin">
+ <number>10</number>
+ </property>
+ <property name="topMargin">
+ <number>4</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlQuantityText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Quantity:</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlQuantity">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlBytesText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Bytes:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlBytes">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl2">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>14</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>4</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlAmountText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Amount:</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlAmount">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlPriorityText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Priority:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlPriority">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string>medium</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl3">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>14</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>4</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlFeeText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Fee:</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlFee">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlLowOutputText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Low Output:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlLowOutput">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string>no</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayoutCoinControl4">
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>14</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>4</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelCoinControlAfterFeeText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>After Fee:</string>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelCoinControlAfterFee">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelCoinControlChangeText">
+ <property name="styleSheet">
+ <string notr="true">font-weight:bold;</string>
+ </property>
+ <property name="text">
+ <string>Change:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelCoinControlChange">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="text">
+ <string notr="true">0.00 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayoutCoinControl4" stretch="0,0,0">
+ <property name="spacing">
+ <number>12</number>
+ </property>
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="checkBoxCoinControlChange">
+ <property name="text">
+ <string>custom change address</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEditCoinControlChange">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelCoinControlChangeLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacerCoinControl">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>800</width>
+ <height>1</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
@@ -24,7 +625,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>666</width>
+ <width>830</width>
<height>165</height>
</rect>
</property>
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index a45131846b..bbb3714dfe 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -633,4 +633,10 @@ void HelpMessageBox::showOrPrint()
#endif
}
+void setClipboard(const QString& str)
+{
+ QApplication::clipboard()->setText(str, QClipboard::Clipboard);
+ QApplication::clipboard()->setText(str, QClipboard::Selection);
+}
+
} // namespace GUIUtil
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index b86fd9117c..14d4ff17c1 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -55,6 +55,8 @@ namespace GUIUtil
*/
void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole);
+ void setClipboard(const QString& str);
+
/** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
when no suffix is provided by the user.
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 1e91a877a9..0a569d16f4 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -155,6 +155,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses);
+ mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
}
void OptionsDialog::enableApplyButton()
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 65c017f088..bd08a46803 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -59,6 +59,7 @@ void OptionsModel::Init()
fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool();
nTransactionFee = settings.value("nTransactionFee").toLongLong();
language = settings.value("language", "").toString();
+ fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
// These are shared with core Bitcoin; we want
// command-line options to override the GUI settings:
@@ -207,6 +208,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return QVariant(bDisplayAddresses);
case Language:
return settings.value("language", "");
+ case CoinControlFeatures:
+ return QVariant(fCoinControlFeatures);
default:
return QVariant();
}
@@ -275,6 +278,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case Fee:
nTransactionFee = value.toLongLong();
settings.setValue("nTransactionFee", (qint64) nTransactionFee);
+ emit transactionFeeChanged(nTransactionFee);
break;
case DisplayUnit:
nDisplayUnit = value.toInt();
@@ -288,6 +292,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case Language:
settings.setValue("language", value);
break;
+ case CoinControlFeatures: {
+ fCoinControlFeatures = value.toBool();
+ settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
+ emit coinControlFeaturesChanged(fCoinControlFeatures);
+ }
+ break;
default:
break;
}
@@ -302,6 +312,11 @@ qint64 OptionsModel::getTransactionFee()
return (qint64) nTransactionFee;
}
+bool OptionsModel::getCoinControlFeatures()
+{
+ return fCoinControlFeatures;
+}
+
bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const
{
std::string proxy = GetArg("-proxy", "");
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index 2d41cf889d..c716f74c0b 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -33,6 +33,7 @@ public:
DisplayUnit, // BitcoinUnits::Unit
DisplayAddresses, // bool
Language, // QString
+ CoinControlFeatures, // bool
OptionIDRowCount,
};
@@ -54,6 +55,7 @@ public:
bool getDisplayAddresses() { return bDisplayAddresses; }
QString getLanguage() { return language; }
bool getProxySettings(QString& proxyIP, quint16 &proxyPort) const;
+ bool getCoinControlFeatures();
private:
int nDisplayUnit;
@@ -61,9 +63,12 @@ private:
bool fMinimizeToTray;
bool fMinimizeOnClose;
QString language;
+ bool fCoinControlFeatures;
signals:
void displayUnitChanged(int unit);
+ void transactionFeeChanged(qint64);
+ void coinControlFeaturesChanged(bool);
};
#endif // OPTIONSMODEL_H
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index b9c5eb08d6..71a1eb7618 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -10,9 +10,12 @@
#include "optionsmodel.h"
#include "sendcoinsentry.h"
#include "walletmodel.h"
+#include "coincontroldialog.h"
+#include "addresstablemodel.h"
#include "base58.h"
#include "ui_interface.h"
+#include "coincontrol.h"
#include <QMessageBox>
#include <QScrollBar>
@@ -30,12 +33,48 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
ui->clearButton->setIcon(QIcon());
ui->sendButton->setIcon(QIcon());
#endif
+#if QT_VERSION >= 0x040700
+ /* Do not move this to the XML file, Qt before 4.7 will choke on it */
+ ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
+#endif
addEntry();
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
+ // Coin Control
+ ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont());
+ connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked()));
+ connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int)));
+ connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
+
+ // Coin Control: clipboard actions
+ QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
+ QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
+ QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
+ QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
+ QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
+ QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this);
+ QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this);
+ QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
+ connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity()));
+ connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount()));
+ connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee()));
+ connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee()));
+ connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes()));
+ connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority()));
+ connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput()));
+ connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange()));
+ ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
+ ui->labelCoinControlAmount->addAction(clipboardAmountAction);
+ ui->labelCoinControlFee->addAction(clipboardFeeAction);
+ ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
+ ui->labelCoinControlBytes->addAction(clipboardBytesAction);
+ ui->labelCoinControlPriority->addAction(clipboardPriorityAction);
+ ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
+ ui->labelCoinControlChange->addAction(clipboardChangeAction);
+
fNewRecipientAllowed = true;
}
@@ -57,6 +96,13 @@ void SendCoinsDialog::setModel(WalletModel *model)
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
+
+ // Coin Control
+ connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels()));
+ connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool)));
+ connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(qint64)), this, SLOT(coinControlUpdateLabels()));
+ ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures());
+ coinControlUpdateLabels();
}
}
@@ -144,7 +190,12 @@ void SendCoinsDialog::on_sendButton_clicked()
// prepare transaction for getting txFee earlier
WalletModelTransaction currentTransaction(recipients);
- WalletModel::SendCoinsReturn prepareStatus = model->prepareTransaction(currentTransaction);
+ WalletModel::SendCoinsReturn prepareStatus;
+ if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
+ prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
+ else
+ prepareStatus = model->prepareTransaction(currentTransaction);
+
// process prepareStatus and on error generate message shown to user
processSendCoinsReturn(prepareStatus,
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
@@ -192,6 +243,8 @@ void SendCoinsDialog::on_sendButton_clicked()
if (sendStatus.status == WalletModel::OK)
{
accept();
+ CoinControlDialog::coinControl->UnSelectAll();
+ coinControlUpdateLabels();
}
fNewRecipientAllowed = true;
}
@@ -226,6 +279,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
entry->setModel(model);
ui->entries->addWidget(entry);
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
+ connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
updateRemoveEnabled();
@@ -253,6 +307,8 @@ void SendCoinsDialog::updateRemoveEnabled()
}
}
setupTabChain(0);
+
+ coinControlUpdateLabels();
}
void SendCoinsDialog::removeEntry(SendCoinsEntry* entry)
@@ -317,6 +373,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
}
entry->setValue(rv);
+ coinControlUpdateLabels();
}
bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv)
@@ -404,3 +461,156 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
emit message(tr("Send Coins"), msgParams.first, msgParams.second);
}
+
+// Coin Control: copy label "Quantity" to clipboard
+void SendCoinsDialog::coinControlClipboardQuantity()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
+}
+
+// Coin Control: copy label "Amount" to clipboard
+void SendCoinsDialog::coinControlClipboardAmount()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
+}
+
+// Coin Control: copy label "Fee" to clipboard
+void SendCoinsDialog::coinControlClipboardFee()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
+}
+
+// Coin Control: copy label "After fee" to clipboard
+void SendCoinsDialog::coinControlClipboardAfterFee()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
+}
+
+// Coin Control: copy label "Bytes" to clipboard
+void SendCoinsDialog::coinControlClipboardBytes()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlBytes->text());
+}
+
+// Coin Control: copy label "Priority" to clipboard
+void SendCoinsDialog::coinControlClipboardPriority()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlPriority->text());
+}
+
+// Coin Control: copy label "Low output" to clipboard
+void SendCoinsDialog::coinControlClipboardLowOutput()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
+}
+
+// Coin Control: copy label "Change" to clipboard
+void SendCoinsDialog::coinControlClipboardChange()
+{
+ GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
+}
+
+// Coin Control: settings menu - coin control enabled/disabled by user
+void SendCoinsDialog::coinControlFeatureChanged(bool checked)
+{
+ ui->frameCoinControl->setVisible(checked);
+
+ if (!checked && model) // coin control features disabled
+ CoinControlDialog::coinControl->SetNull();
+}
+
+// Coin Control: button inputs -> show actual coin control dialog
+void SendCoinsDialog::coinControlButtonClicked()
+{
+ CoinControlDialog dlg;
+ dlg.setModel(model);
+ dlg.exec();
+ coinControlUpdateLabels();
+}
+
+// Coin Control: checkbox custom change address
+void SendCoinsDialog::coinControlChangeChecked(int state)
+{
+ if (model)
+ {
+ if (state == Qt::Checked)
+ CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get();
+ else
+ CoinControlDialog::coinControl->destChange = CNoDestination();
+ }
+
+ ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
+ ui->labelCoinControlChangeLabel->setVisible((state == Qt::Checked));
+}
+
+// Coin Control: custom change address changed
+void SendCoinsDialog::coinControlChangeEdited(const QString & text)
+{
+ if (model)
+ {
+ CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get();
+
+ // label for the change address
+ ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
+ if (text.isEmpty())
+ ui->labelCoinControlChangeLabel->setText("");
+ else if (!CBitcoinAddress(text.toStdString()).IsValid())
+ {
+ ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
+ ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin address"));
+ }
+ else
+ {
+ QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
+ if (!associatedLabel.isEmpty())
+ ui->labelCoinControlChangeLabel->setText(associatedLabel);
+ else
+ {
+ CPubKey pubkey;
+ CKeyID keyid;
+ CBitcoinAddress(text.toStdString()).GetKeyID(keyid);
+ if (model->getPubKey(keyid, pubkey))
+ ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
+ else
+ {
+ ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
+ ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
+ }
+ }
+ }
+ }
+}
+
+// Coin Control: update labels
+void SendCoinsDialog::coinControlUpdateLabels()
+{
+ if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures())
+ return;
+
+ // set pay amounts
+ CoinControlDialog::payAmounts.clear();
+ 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);
+ }
+
+ if (CoinControlDialog::coinControl->HasSelected())
+ {
+ // actual coin control calculation
+ CoinControlDialog::updateLabels(model, this);
+
+ // show coin control stats
+ ui->labelCoinControlAutomaticallySelected->hide();
+ ui->widgetCoinControl->show();
+ }
+ else
+ {
+ // hide coin control stats
+ ui->labelCoinControlAutomaticallySelected->show();
+ ui->widgetCoinControl->hide();
+ ui->labelCoinControlInsuffFunds->hide();
+ }
+}
+
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index 9d5f34f0c2..4327e8e382 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -8,6 +8,7 @@
#include "walletmodel.h"
#include <QDialog>
+#include <QString>
class OptionsModel;
class SendCoinsEntry;
@@ -62,6 +63,19 @@ private slots:
void on_sendButton_clicked();
void removeEntry(SendCoinsEntry* entry);
void updateDisplayUnit();
+ void coinControlFeatureChanged(bool);
+ void coinControlButtonClicked();
+ void coinControlChangeChecked(int);
+ void coinControlChangeEdited(const QString &);
+ void coinControlUpdateLabels();
+ void coinControlClipboardQuantity();
+ void coinControlClipboardAmount();
+ void coinControlClipboardFee();
+ void coinControlClipboardAfterFee();
+ void coinControlClipboardBytes();
+ void coinControlClipboardPriority();
+ void coinControlClipboardLowOutput();
+ void coinControlClipboardChange();
signals:
// Fired when a message should be reported to the user
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 2d240f1fe5..f6f86eb820 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -75,6 +75,8 @@ void SendCoinsEntry::setModel(WalletModel *model)
if (model && model->getOptionsModel())
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
+ connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged()));
+
clear();
}
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index 6fc36f9787..1c4ddaa8ef 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -51,6 +51,7 @@ public slots:
signals:
void removeEntry(SendCoinsEntry *entry);
+ void payAmountChanged();
private slots:
void on_deleteButton_clicked();
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index b1d770e1a7..2470af41a0 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -47,8 +47,19 @@ WalletModel::~WalletModel()
unsubscribeFromCoreSignals();
}
-qint64 WalletModel::getBalance() const
+qint64 WalletModel::getBalance(const CCoinControl *coinControl) const
{
+ if (coinControl)
+ {
+ qint64 nBalance = 0;
+ std::vector<COutput> vCoins;
+ wallet->AvailableCoins(vCoins, true, coinControl);
+ BOOST_FOREACH(const COutput& out, vCoins)
+ nBalance += out.tx->vout[out.i].nValue;
+
+ return nBalance;
+ }
+
return wallet->GetBalance();
}
@@ -136,7 +147,7 @@ bool WalletModel::validateAddress(const QString &address)
return addressParsed.IsValid();
}
-WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction)
+WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl)
{
qint64 total = 0;
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
@@ -197,12 +208,14 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
return DuplicateAddress;
}
- if(total > getBalance())
+ qint64 nBalance = getBalance(coinControl);
+
+ if(total > nBalance)
{
return AmountExceedsBalance;
}
- if((total + nTransactionFee) > getBalance())
+ if((total + nTransactionFee) > nBalance)
{
transaction.setTransactionFee(nTransactionFee);
return SendCoinsReturn(AmountWithFeeExceedsBalance);
@@ -217,12 +230,12 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
CWalletTx *newTx = transaction.getTransaction();
CReserveKey *keyChange = transaction.getPossibleKeyChange();
- bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason);
+ bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl);
transaction.setTransactionFee(nFeeRequired);
if(!fCreated)
{
- if((total + nFeeRequired) > wallet->GetBalance())
+ if((total + nFeeRequired) > nBalance)
{
return SendCoinsReturn(AmountWithFeeExceedsBalance);
}
@@ -458,3 +471,72 @@ void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs)
*this = rhs;
rhs.relock = false;
}
+
+bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
+{
+ return wallet->GetPubKey(address, vchPubKeyOut);
+}
+
+// returns a list of COutputs from COutPoints
+void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
+{
+ BOOST_FOREACH(const COutPoint& outpoint, vOutpoints)
+ {
+ if (!wallet->mapWallet.count(outpoint.hash)) continue;
+ COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, wallet->mapWallet[outpoint.hash].GetDepthInMainChain());
+ vOutputs.push_back(out);
+ }
+}
+
+// AvailableCoins + LockedCoins grouped by wallet address (put change in one group with wallet address)
+void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const
+{
+ std::vector<COutput> vCoins;
+ wallet->AvailableCoins(vCoins);
+
+ std::vector<COutPoint> vLockedCoins;
+ wallet->ListLockedCoins(vLockedCoins);
+
+ // add locked coins
+ BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins)
+ {
+ if (!wallet->mapWallet.count(outpoint.hash)) continue;
+ COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, wallet->mapWallet[outpoint.hash].GetDepthInMainChain());
+ vCoins.push_back(out);
+ }
+
+ BOOST_FOREACH(const COutput& out, vCoins)
+ {
+ COutput cout = out;
+
+ while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0]))
+ {
+ if (!wallet->mapWallet.count(cout.tx->vin[0].prevout.hash)) break;
+ cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0);
+ }
+
+ CTxDestination address;
+ if(!ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue;
+ mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out);
+ }
+}
+
+bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const
+{
+ return wallet->IsLockedCoin(hash, n);
+}
+
+void WalletModel::lockCoin(COutPoint& output)
+{
+ wallet->LockCoin(output);
+}
+
+void WalletModel::unlockCoin(COutPoint& output)
+{
+ wallet->UnlockCoin(output);
+}
+
+void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
+{
+ wallet->ListLockedCoins(vOutpts);
+}
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index f39e9dfca0..f5afe87260 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -11,11 +11,19 @@
#include "allocators.h" /* for SecureString */
#include <QObject>
+#include <vector>
+#include <map>
class AddressTableModel;
class OptionsModel;
class TransactionTableModel;
class WalletModelTransaction;
+class CKeyID;
+class CPubKey;
+class COutput;
+class COutPoint;
+class uint256;
+class CCoinControl;
class CWallet;
@@ -80,7 +88,7 @@ public:
AddressTableModel *getAddressTableModel();
TransactionTableModel *getTransactionTableModel();
- qint64 getBalance() const;
+ qint64 getBalance(const CCoinControl *coinControl=NULL) const;
qint64 getUnconfirmedBalance() const;
qint64 getImmatureBalance() const;
int getNumTransactions() const;
@@ -92,13 +100,13 @@ public:
// Return status record for SendCoins, contains error id + information
struct SendCoinsReturn
{
- SendCoinsReturn(StatusCode status):
+ SendCoinsReturn(StatusCode status=Aborted):
status(status) {}
StatusCode status;
};
// prepare transaction for getting txfee before sending coins
- SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction);
+ SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl=NULL);
// Send coins to a list of recipients
SendCoinsReturn sendCoins(WalletModelTransaction &transaction);
@@ -133,6 +141,15 @@ public:
UnlockContext requestUnlock();
+ bool getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
+ void getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs);
+ void listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const;
+
+ bool isLockedCoin(uint256 hash, unsigned int n) const;
+ void lockCoin(COutPoint& output);
+ void unlockCoin(COutPoint& output);
+ void listLockedCoins(std::vector<COutPoint>& vOutpts);
+
private:
CWallet *wallet;
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 868716cb2c..3e684a7879 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -7,6 +7,7 @@
#include "base58.h"
#include "net.h"
+#include "coincontrol.h"
#include <inttypes.h>
#include <stdint.h>
@@ -1004,7 +1005,7 @@ int64_t CWallet::GetImmatureBalance() const
}
// populate vCoins with vector of spendable COutputs
-void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed) const
+void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl) const
{
vCoins.clear();
@@ -1025,8 +1026,9 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed) const
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) &&
- !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0)
- vCoins.push_back(COutput(pcoin, i, pcoin->GetDepthInMainChain()));
+ !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 &&
+ (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
+ vCoins.push_back(COutput(pcoin, i, pcoin->GetDepthInMainChain()));
}
}
}
@@ -1176,10 +1178,21 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
return true;
}
-bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
+bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl) const
{
vector<COutput> vCoins;
- AvailableCoins(vCoins);
+ AvailableCoins(vCoins, true, coinControl);
+
+ // coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
+ if (coinControl && coinControl->HasSelected())
+ {
+ BOOST_FOREACH(const COutput& out, vCoins)
+ {
+ nValueRet += out.tx->vout[out.i].nValue;
+ setCoinsRet.insert(make_pair(out.tx, out.i));
+ }
+ return (nValueRet >= nTargetValue);
+ }
return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
@@ -1190,7 +1203,7 @@ bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsign
bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
- CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason)
+ CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl)
{
int64_t nValue = 0;
BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
@@ -1237,7 +1250,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
// Choose coins to use
set<pair<const CWalletTx*,unsigned int> > setCoins;
int64_t nValueIn = 0;
- if (!SelectCoins(nTotalValue, setCoins, nValueIn))
+ if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl))
{
strFailReason = _("Insufficient funds");
return false;
@@ -1265,22 +1278,31 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
if (nChange > 0)
{
- // Note: We use a new key here to keep it from being obvious which side is the change.
- // The drawback is that by not reusing a previous key, the change may be lost if a
- // backup is restored, if the backup doesn't have the new private key for the change.
- // If we reused the old key, it would be possible to add code to look for and
- // rediscover unknown transactions that were written with keys of ours to recover
- // post-backup change.
-
- // Reserve a new key pair from key pool
- CPubKey vchPubKey;
- assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
-
// Fill a vout to ourself
// TODO: pass in scriptChange instead of reservekey so
// change transaction isn't always pay-to-bitcoin-address
CScript scriptChange;
- scriptChange.SetDestination(vchPubKey.GetID());
+
+ // coin control: send change to custom address
+ if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange))
+ scriptChange.SetDestination(coinControl->destChange);
+
+ // no coin control: send change to newly generated address
+ else
+ {
+ // Note: We use a new key here to keep it from being obvious which side is the change.
+ // The drawback is that by not reusing a previous key, the change may be lost if a
+ // backup is restored, if the backup doesn't have the new private key for the change.
+ // If we reused the old key, it would be possible to add code to look for and
+ // rediscover unknown transactions that were written with keys of ours to recover
+ // post-backup change.
+
+ // Reserve a new key pair from key pool
+ CPubKey vchPubKey;
+ assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
+
+ scriptChange.SetDestination(vchPubKey.GetID());
+ }
CTxOut newTxOut(nChange, scriptChange);
@@ -1353,11 +1375,11 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
}
bool CWallet::CreateTransaction(CScript scriptPubKey, int64_t nValue,
- CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason)
+ CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl)
{
vector< pair<CScript, int64_t> > vecSend;
vecSend.push_back(make_pair(scriptPubKey, nValue));
- return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, strFailReason);
+ return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, strFailReason, coinControl);
}
// Call after CreateTransaction unless you want to abort
diff --git a/src/wallet.h b/src/wallet.h
index 5c38d7a1a0..928ba3de3f 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -28,6 +28,7 @@ class COutput;
class CReserveKey;
class CScript;
class CWalletTx;
+class CCoinControl;
/** (client) version numbers for particular wallet features */
enum WalletFeature
@@ -87,7 +88,7 @@ public:
class CWallet : public CCryptoKeyStore, public CWalletInterface
{
private:
- bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
+ bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const;
CWalletDB *pwalletdbEncryption;
@@ -152,7 +153,7 @@ public:
// check whether we are allowed to upgrade (or already support) to the named feature
bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; }
- void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true) const;
+ void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const;
bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
bool IsLockedCoin(uint256 hash, unsigned int n) const;
void LockCoin(COutPoint& output);
@@ -212,9 +213,9 @@ public:
int64_t GetUnconfirmedBalance() const;
int64_t GetImmatureBalance() const;
bool CreateTransaction(const std::vector<std::pair<CScript, int64_t> >& vecSend,
- CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason);
+ CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl=NULL);
bool CreateTransaction(CScript scriptPubKey, int64_t nValue,
- CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason);
+ CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl=NULL);
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);