Browse Source

prevent unnecessary rounding

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
7f6c0db7d7
  1. 5
      src/mainwindow.ui
  2. 15
      src/turnstile.cpp
  3. 3
      src/ui_mainwindow.h

5
src/mainwindow.ui

@ -22,7 +22,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -362,6 +362,9 @@
<height>0</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="placeholderText">
<string>Amount</string>
</property>

15
src/turnstile.cpp

@ -155,21 +155,15 @@ QList<double> Turnstile::splitAmount(double amount, int parts) {
// Add the Tx fees
sumofparts += amounts.size() * Utils::getMinerFee();
qDebug() << QString::number(sumofparts, 'f', 8) << QString::number(amount, 'f', 8);
Q_ASSERT(QString::number(sumofparts, 'f', 8) == QString::number(amount, 'f', 8));
return amounts;
}
void Turnstile::fillAmounts(QList<double>& amounts, double amount, int count) {
if (count == 1 || amount < 0.01) {
// Split the chaff.
// Chaff is all amounts lesser than 0.0001 ZEC. The chaff will be added to the
// dev fee, and is done so to protect privacy.
// Get the rounded value to 4 decimal places (approx $0.01)
double actual = std::floor(amount * 10000) / 10000;
// Also account for the fees needed to send all these transactions
actual = actual - (Utils::getMinerFee() * (amounts.size() + 1));
auto actual = amount - (Utils::getMinerFee() * (amounts.size() + 1));
amounts.push_back(actual);
return;
@ -317,6 +311,11 @@ void Turnstile::executeMigrationStep() {
return;
}
if (!rpc->getAllBalances()->keys().contains(nextStep->intTAddr)) {
qDebug() << QString("The int address doesn't have balance, even though it is confirmed");
return;
}
// Send it to the final destination address.
auto bal = rpc->getAllBalances()->value(nextStep->intTAddr);
auto sendAmt = bal - Utils::getMinerFee();

3
src/ui_mainwindow.h

@ -409,6 +409,7 @@ public:
Amount1 = new QLineEdit(verticalGroupBox);
Amount1->setObjectName(QStringLiteral("Amount1"));
Amount1->setBaseSize(QSize(200, 0));
Amount1->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
horizontalLayout_13->addWidget(Amount1);
@ -683,7 +684,7 @@ public:
retranslateUi(MainWindow);
tabWidget->setCurrentIndex(0);
tabWidget->setCurrentIndex(1);
QMetaObject::connectSlotsByName(MainWindow);

Loading…
Cancel
Save