diff --git a/src/coincontrol.h b/src/coincontrol.h index 97c30c2713..6e47a09730 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -12,6 +12,8 @@ class CCoinControl { public: CTxDestination destChange; + bool useDarkSend; + bool useInstantX; CCoinControl() { @@ -22,6 +24,8 @@ public: { destChange = CNoDestination(); setSelected.clear(); + useInstantX = false; + useDarkSend = true; } bool HasSelected() const diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index d0640d0565..e2d35ee296 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -530,6 +530,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) // Fee int64_t nFee = nTransactionFee * (1 + (int64_t)nBytes / 1000); + // IX Fee + if(coinControl->useInstantX) nFee = max(nFee, CENT); + // Min Fee int64_t nMinFee = GetMinFee(txDummy, nBytes, AllowFree(dPriority), GMF_SEND); @@ -539,6 +542,13 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) { nChange = nAmount - nPayFee - nPayAmount; + // DS Fee = overpay + if(coinControl->useDarkSend && nChange > 0) + { + nPayFee += nChange; + nChange = 0; + } + // if sub-cent change is required, the fee must be raised to at least CTransaction::nMinTxFee if (nPayFee < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT) { diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index cbbae8626f..2564a88427 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -47,7 +47,7 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) : connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); connect(ui->checkUseDarksend, SIGNAL(stateChanged ( int )), this, SLOT(updateDisplayUnit())); - connect(ui->checkInstantX, SIGNAL(stateChanged ( int )), this, SLOT(updateDisplayUnit())); + connect(ui->checkInstantX, SIGNAL(stateChanged ( int )), this, SLOT(updateInstantX())); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); @@ -473,6 +473,14 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint void SendCoinsDialog::updateDisplayUnit() { setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance()); + CoinControlDialog::coinControl->useDarkSend = ui->checkUseDarksend->isChecked(); + coinControlUpdateLabels(); +} + +void SendCoinsDialog::updateInstantX() +{ + CoinControlDialog::coinControl->useInstantX = ui->checkInstantX->isChecked(); + coinControlUpdateLabels(); } void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg) diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 5df7795676..6f86057313 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -64,6 +64,7 @@ private slots: void on_sendButton_clicked(); void removeEntry(SendCoinsEntry* entry); void updateDisplayUnit(); + void updateInstantX(); void coinControlFeatureChanged(bool); void coinControlButtonClicked(); void coinControlChangeChecked(int); diff --git a/src/wallet.cpp b/src/wallet.cpp index 06a17b1ab7..5171ab85d4 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1838,7 +1838,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, LOCK2(cs_main, cs_wallet); { nFeeRet = nTransactionFee; - if(useIX && nFeeRet < CENT) nFeeRet = CENT; + if(useIX) nFeeRet = max(CENT, nFeeRet); while (true) { wtxNew.vin.clear(); @@ -1912,13 +1912,9 @@ bool CWallet::CreateTransaction(const vector >& vecSend, //over pay for denominated transactions if(coin_type == ONLY_DENOMINATED) { - nFeeRet = nChange; + nFeeRet += nChange; nChange = 0; wtxNew.mapValue["DS"] = "1"; - } else if(useIX && nFeeRet < CENT && nChange > (CENT-nFeeRet)) { - // IX has a minimum fee of 0.01 DRK - nChange -= CENT-nFeeRet; - nFeeRet = CENT; } if (nChange > 0)