fix IX and DS fee calculations / use coincontrol to show live calculations

This commit is contained in:
UdjinM6 2015-03-02 07:26:38 +03:00
parent 96dbba0d5f
commit 4bfdcc181c
5 changed files with 26 additions and 7 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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)

View File

@ -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);

View File

@ -1838,7 +1838,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& 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<pair<CScript, int64_t> >& 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)