Prevent rounding for small amounts
This commit is contained in:
parent
9776987971
commit
6175c3cde5
|
@ -20,9 +20,9 @@ void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
|||
|
||||
// Process the address balances into a list
|
||||
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) {
|
||||
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
|
||||
|
@ -85,7 +85,7 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
|
|||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
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()) {
|
||||
case 0: return std::get<0>(modeldata->at(index.row()));
|
||||
case 1: {
|
||||
auto bal = std::get<1>(modeldata->at(index.row())).toDouble();
|
||||
return Settings::getUSDFormat(bal);
|
||||
return Settings::getUSDFormat(std::get<1>(modeldata->at(index.row())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
|
||||
private:
|
||||
QList<std::tuple<QString, QString>>* modeldata = nullptr;
|
||||
QList<std::tuple<QString, double>>* modeldata = nullptr;
|
||||
QList<UnspentOutput>* utxos = nullptr;
|
||||
|
||||
bool loading = true;
|
||||
|
|
|
@ -317,7 +317,7 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
|||
// Construct the JSON params
|
||||
json rec = json::object();
|
||||
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())
|
||||
rec["memo"] = toAddr.encodedMemo.toStdString();
|
||||
|
||||
|
@ -331,7 +331,7 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
|||
// Add fees if custom fees are allowed.
|
||||
if (Settings::getInstance()->getAllowCustomFees()) {
|
||||
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(
|
||||
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>() });
|
||||
|
||||
(*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;
|
||||
maxamount = (maxamount < 0) ? 0 : maxamount;
|
||||
|
||||
ui->Amount1->setText(QString::number(maxamount, 'g', 8));
|
||||
ui->Amount1->setText(Settings::getDecimalString(maxamount));
|
||||
} else if (checked == Qt::Unchecked) {
|
||||
// Just remove the readonly part, don't change the content
|
||||
ui->Amount1->setReadOnly(false);
|
||||
|
|
|
@ -169,8 +169,6 @@ QList<double> Turnstile::splitAmount(double amount, int parts) {
|
|||
// Add the Tx fees
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue