Fix Transaction decimal

This commit is contained in:
DenioD
2019-10-26 12:53:09 +02:00
parent 9808e65293
commit 2f4e024fdc
11 changed files with 23 additions and 25 deletions

View File

@@ -267,7 +267,7 @@ bool Controller::processUnspent(const json& reply, QMap<QString, double>* balanc
newUtxos->push_back(UnspentOutput{ qsAddr, txid, amount, block, true });
(*balancesMap)[qsAddr] = ((*balancesMap)[qsAddr] + it["value"].get<json::number_float_t>()) /10000000;
(*balancesMap)[qsAddr] = ((*balancesMap)[qsAddr] + (it["value"].get<json::number_float_t>()) /10000000);
}
};
@@ -337,7 +337,7 @@ void Controller::refreshTransactions() {
for (auto o: it["outgoing_metadata"].get<json::array_t>()) {
QString address = QString::fromStdString(o["address"]);
double amount = it["value"].get<json::number_float_t>(); // Sent items are -ve
double amount = -1 * o ["value"].get<json::number_float_t>() /10000000; // Sent items are -ve
QString memo;
if (!o["memo"].is_null()) {
@@ -369,8 +369,8 @@ void Controller::refreshTransactions() {
items.push_back(TransactionItemDetail{
address,
it["amount"].get<json::number_float_t>(),
""
it["amount"].get<json::number_float_t>() /10000000,
"."
});
TransactionItem tx{

View File

@@ -20,6 +20,7 @@ struct WatchedTx {
std::function<void(QString, QString)> error;
};
struct MigrationStatus {
bool available; // Whether the underlying hushd supports migration?
bool enabled;

View File

@@ -905,7 +905,7 @@
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>hushd</string>
<string>Hush Daemon</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>

View File

@@ -201,8 +201,8 @@ void Recurring::updateInfoWithTx(RecurringPaymentInfo* r, Tx tx) {
r->toAddr = tx.toAddrs[0].addr;
r->memo = tx.toAddrs[0].memo;
r->fromAddr = tx.fromAddr;
if (r->currency.isEmpty() || r->currency == "USD") {
r->currency = "USD";
if (r->currency.isEmpty() || r->currency == "usd") {
r->currency = "usd";
r->amt = tx.toAddrs[0].amount * Settings::getInstance()->gethushPrice();
}
else {
@@ -461,7 +461,7 @@ void Recurring::processMultiplePending(RecurringPaymentInfo rpi, MainWindow* mai
void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo rpi, QList<int> paymentNumbers) {
// Amount is in USD or hush?
auto amt = rpi.amt;
if (rpi.currency == "USD") {
if (rpi.currency == "usd") {
// If there is no price, then fail the payment
if (Settings::getInstance()->gethushPrice() == 0) {
for (auto paymentNumber: paymentNumbers) {

View File

@@ -511,22 +511,17 @@ Tx MainWindow::createTxFromSendPage() {
// If address is sprout, then we can't send change to sapling, because of turnstile.
sendChangeToSapling = sendChangeToSapling && !Settings::getInstance()->isSproutAddress(addr);
QString amtStr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed();
if (amtStr.isEmpty()) {
amtStr = "-1";; // The user didn't specify an amount
}
double amt = amtStr.toDouble();
double amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed().toDouble();
totalAmt += amt;
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
tx.toAddrs.push_back( ToFields{addr, amt, memo} );
tx.toAddrs.push_back( ToFields{addr, amt, memo,} );
}
if (Settings::getInstance()->getAllowCustomFees()) {
tx.fee = ui->minerFeeAmt->text().toDouble();
} else {
}
else {
tx.fee = Settings::getMinerFee();
}

View File

@@ -99,7 +99,7 @@ public:
static bool isTAddress(QString addr);
static QString getDecimalString(double amt);
static QString getUSDFormat(double usdAmt);
static QString getUSDFormat(double bal);
static QString getUSDFromhushAmount(double bal);
static QString gethushDisplayFormat(double bal);

View File

@@ -105,7 +105,7 @@ bool TxTableModel::exportToCsv(QString fileName) const {
case Column::Confirmations: return QString::number(dat.confirmations);
case Column::Amount: {
// Sum up all the amounts
qint64 total = 0;
double total = 0;
for (int i=0; i < dat.items.length(); i++) {
total += dat.items[i].amount;
}
@@ -141,7 +141,7 @@ bool TxTableModel::exportToCsv(QString fileName) const {
case Column::Confirmations: return QString("%1 Network Confirmations").arg(QString::number(dat.confirmations));
case Column::Amount: {
// Sum up all the amounts
qint64 total = 0;
double total = 0;
for (int i=0; i < dat.items.length(); i++) {
total += dat.items[i].amount;
}
@@ -237,7 +237,7 @@ QString TxTableModel::getType(int row) const {
QString TxTableModel::getAmt(int row) const {
auto dat = modeldata->at(row);
qint64 total = 0;
double total = 0;
for (int i=0; i < dat.items.length(); i++) {
total += dat.items[i].amount;
}

View File

@@ -769,6 +769,8 @@ void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, std
void AppDataServer::processGetTransactions(MainWindow* mainWindow, std::shared_ptr<ClientWebSocket> pClient) {
QJsonArray txns;
auto model = mainWindow->getRPC()->getTransactionsModel();
qDebug() << "processGetTransactions";
// Add transactions
for (int i = 0; i < model->rowCount(QModelIndex()) && i < Settings::getMaxMobileAppTxns(); i++) {