Prevent rounding for small amounts
This commit is contained in:
@@ -20,9 +20,9 @@ void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
|||||||
|
|
||||||
// Process the address balances into a list
|
// Process the address balances into a list
|
||||||
delete modeldata;
|
delete modeldata;
|
||||||
modeldata = new QList<std::tuple<QString, QString>>();
|
modeldata = new QList<std::tuple<QString, double>>();
|
||||||
std::for_each(balances->keyBegin(), balances->keyEnd(), [=] (auto keyIt) {
|
std::for_each(balances->keyBegin(), balances->keyEnd(), [=] (auto keyIt) {
|
||||||
modeldata->push_back(std::make_tuple(keyIt, QString::number(balances->value(keyIt), 'g', 8)));
|
modeldata->push_back(std::make_tuple(keyIt, balances->value(keyIt)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// And then update the data
|
// And then update the data
|
||||||
@@ -85,7 +85,7 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return std::get<0>(modeldata->at(index.row()));
|
case 0: return std::get<0>(modeldata->at(index.row()));
|
||||||
case 1: return Settings::getZECDisplayFormat(std::get<1>(modeldata->at(index.row())).toDouble());
|
case 1: return Settings::getZECDisplayFormat(std::get<1>(modeldata->at(index.row())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +93,7 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return std::get<0>(modeldata->at(index.row()));
|
case 0: return std::get<0>(modeldata->at(index.row()));
|
||||||
case 1: {
|
case 1: {
|
||||||
auto bal = std::get<1>(modeldata->at(index.row())).toDouble();
|
return Settings::getUSDFormat(std::get<1>(modeldata->at(index.row())));
|
||||||
return Settings::getUSDFormat(bal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<std::tuple<QString, QString>>* modeldata = nullptr;
|
QList<std::tuple<QString, double>>* modeldata = nullptr;
|
||||||
QList<UnspentOutput>* utxos = nullptr;
|
QList<UnspentOutput>* utxos = nullptr;
|
||||||
|
|
||||||
bool loading = true;
|
bool loading = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
|||||||
// Construct the JSON params
|
// Construct the JSON params
|
||||||
json rec = json::object();
|
json rec = json::object();
|
||||||
rec["address"] = toAddr.addr.toStdString();
|
rec["address"] = toAddr.addr.toStdString();
|
||||||
rec["amount"] = QString::number(toAddr.amount, 'f', 8).toDouble(); // Force it through string for rounding
|
rec["amount"] = toAddr.amount;
|
||||||
if (toAddr.addr.startsWith("z") && !toAddr.encodedMemo.trimmed().isEmpty())
|
if (toAddr.addr.startsWith("z") && !toAddr.encodedMemo.trimmed().isEmpty())
|
||||||
rec["memo"] = toAddr.encodedMemo.toStdString();
|
rec["memo"] = toAddr.encodedMemo.toStdString();
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
|||||||
// Add fees if custom fees are allowed.
|
// Add fees if custom fees are allowed.
|
||||||
if (Settings::getInstance()->getAllowCustomFees()) {
|
if (Settings::getInstance()->getAllowCustomFees()) {
|
||||||
params.push_back(1); // minconf
|
params.push_back(1); // minconf
|
||||||
params.push_back(QString::number(tx.fee, 'f', 8).toDouble());
|
params.push_back(tx.fee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,7 +660,7 @@ bool RPC::processUnspent(const json& reply) {
|
|||||||
|
|
||||||
utxos->push_back(
|
utxos->push_back(
|
||||||
UnspentOutput{ qsAddr, QString::fromStdString(it["txid"]),
|
UnspentOutput{ qsAddr, QString::fromStdString(it["txid"]),
|
||||||
QString::number(it["amount"].get<json::number_float_t>(), 'g', 8),
|
Settings::getDecimalString(it["amount"].get<json::number_float_t>()),
|
||||||
(int)confirmations, it["spendable"].get<json::boolean_t>() });
|
(int)confirmations, it["spendable"].get<json::boolean_t>() });
|
||||||
|
|
||||||
(*allBalances)[qsAddr] = (*allBalances)[qsAddr] + it["amount"].get<json::number_float_t>();
|
(*allBalances)[qsAddr] = (*allBalances)[qsAddr] + it["amount"].get<json::number_float_t>();
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ void MainWindow::maxAmountChecked(int checked) {
|
|||||||
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
||||||
maxamount = (maxamount < 0) ? 0 : maxamount;
|
maxamount = (maxamount < 0) ? 0 : maxamount;
|
||||||
|
|
||||||
ui->Amount1->setText(QString::number(maxamount, 'g', 8));
|
ui->Amount1->setText(Settings::getDecimalString(maxamount));
|
||||||
} else if (checked == Qt::Unchecked) {
|
} else if (checked == Qt::Unchecked) {
|
||||||
// Just remove the readonly part, don't change the content
|
// Just remove the readonly part, don't change the content
|
||||||
ui->Amount1->setReadOnly(false);
|
ui->Amount1->setReadOnly(false);
|
||||||
|
|||||||
@@ -169,8 +169,6 @@ QList<double> Turnstile::splitAmount(double amount, int parts) {
|
|||||||
// Add the Tx fees
|
// Add the Tx fees
|
||||||
sumofparts += amounts.size() * Settings::getMinerFee();
|
sumofparts += amounts.size() * Settings::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;
|
return amounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user