fix Balance render problems
This commit is contained in:
@@ -131,6 +131,7 @@ FORMS += \
|
||||
src/newwallet.ui \
|
||||
src/recurringpayments.ui \
|
||||
src/restoreseed.ui \
|
||||
src/seedrestore.ui \
|
||||
src/sendHushTransactionChat.ui \
|
||||
src/settings.ui \
|
||||
src/about.ui \
|
||||
|
||||
@@ -638,7 +638,7 @@ void Controller::getInfoThenRefresh(bool force)
|
||||
refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans()
|
||||
refreshTransactions();
|
||||
}
|
||||
|
||||
refreshBalances();
|
||||
int lag = longestchain - notarized ;
|
||||
this->setLag(lag);
|
||||
}, [=](QString err) {
|
||||
@@ -730,7 +730,7 @@ void Controller::processUnspent(const QJsonValue& reply, QMap<QString, CAmount>*
|
||||
QString qsAddr = it["address"].toString();
|
||||
int block = it["created_in_block"].toInt();
|
||||
QString txid = it["created_in_txid"].toString();
|
||||
CAmount amount = CAmount::fromqint64(it["value"].toInt());
|
||||
CAmount amount = CAmount::fromqint64(it["value"].toDouble());
|
||||
|
||||
bool spendable = it["unconfirmed_spent"].isNull() && it["spent"].isNull(); // TODO: Wait for 1 confirmations
|
||||
bool pending = !it["unconfirmed_spent"].isNull();
|
||||
@@ -741,7 +741,7 @@ void Controller::processUnspent(const QJsonValue& reply, QMap<QString, CAmount>*
|
||||
if (spendable)
|
||||
{
|
||||
(*balancesMap)[qsAddr] = (*balancesMap)[qsAddr] +
|
||||
CAmount::fromqint64(it["value"].toInt());
|
||||
CAmount::fromqint64(it["value"].toDouble());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -906,9 +906,9 @@ void Controller::refreshBalances()
|
||||
|
||||
// 1. Get the Balances
|
||||
zrpc->fetchBalance([=] (QJsonValue reply) {
|
||||
CAmount balT = CAmount::fromqint64(reply["tbalance"].toInt());
|
||||
CAmount balZ = CAmount::fromqint64(reply["zbalance"].toInt());
|
||||
CAmount balVerified = CAmount::fromqint64(reply["verified_zbalance"].toInt());
|
||||
CAmount balT = CAmount::fromqint64(reply["tbalance"].toDouble());
|
||||
CAmount balZ = CAmount::fromqint64(reply["zbalance"].toDouble());
|
||||
CAmount balVerified = CAmount::fromqint64(reply["verified_zbalance"].toDouble());
|
||||
|
||||
model->setBalT(balT);
|
||||
model->setBalZ(balZ);
|
||||
@@ -985,7 +985,7 @@ void Controller::refreshTransactions() {
|
||||
address = o.toObject()["address"].toString();
|
||||
|
||||
// Sent items are -ve
|
||||
CAmount amount = CAmount::fromqint64(-1* o.toObject()["value"].toInt());
|
||||
CAmount amount = CAmount::fromqint64(-1* o.toObject()["value"].toDouble());
|
||||
|
||||
// Check for Memos
|
||||
|
||||
@@ -1169,7 +1169,7 @@ void Controller::refreshTransactions() {
|
||||
);
|
||||
|
||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
||||
updateUIBalances();
|
||||
// updateUIBalances();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,18 +1194,18 @@ void Controller::refreshTransactions() {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Incoming Transaction
|
||||
|
||||
{ // Incoming Transaction
|
||||
address = (it.toObject()["address"].isNull() ? "" : it.toObject()["address"].toString());
|
||||
model->markAddressUsed(address);
|
||||
|
||||
QString memo;
|
||||
if (!it.toObject()["memo"].isNull()) {
|
||||
if (!it.toObject()["memo"].isNull())
|
||||
memo = it.toObject()["memo"].toString();
|
||||
}
|
||||
|
||||
items.push_back(TransactionItemDetail{
|
||||
address,
|
||||
CAmount::fromqint64(it.toObject()["amount"].toInt()),
|
||||
CAmount::fromqint64(it.toObject()["amount"].toDouble()),
|
||||
memo
|
||||
});
|
||||
|
||||
@@ -1214,7 +1214,14 @@ void Controller::refreshTransactions() {
|
||||
};
|
||||
|
||||
txdata.push_back(tx);
|
||||
|
||||
}
|
||||
|
||||
address = (it.toObject()["address"].isNull() ? "" : it.toObject()["address"].toString());
|
||||
model->markAddressUsed(address);
|
||||
|
||||
QString memo;
|
||||
if (!it.toObject()["memo"].isNull())
|
||||
memo = it.toObject()["memo"].toString();
|
||||
QString type;
|
||||
QString publickey;
|
||||
QString headerbytes;
|
||||
@@ -1470,8 +1477,9 @@ void Controller::refreshTransactions() {
|
||||
chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat);
|
||||
ui->listChat->verticalScrollBar()->setValue(
|
||||
ui->listChat->verticalScrollBar()->maximum());
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void Controller::refreshChat(QListView *listWidget, QLabel *label)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "requestdialog.h"
|
||||
#include "ui_startupencryption.h"
|
||||
#include "ui_removeencryption.h"
|
||||
#include "ui_seedrestore.h"
|
||||
#include "websockets.h"
|
||||
#include "sodium.h"
|
||||
#include "sodium/crypto_generichash_blake2b.h"
|
||||
@@ -162,17 +163,124 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
// Rescan
|
||||
QObject::connect(ui->actionRescan, &QAction::triggered, [=]() {
|
||||
// To rescan, we clear the wallet state, and then reload the connection
|
||||
|
||||
QFile file(dirwalletenc);
|
||||
QFile file1(dirwallet);
|
||||
|
||||
if(fileExists(dirwalletenc))
|
||||
|
||||
{
|
||||
file.remove();
|
||||
file1.remove();
|
||||
}
|
||||
|
||||
|
||||
Ui_Restore restoreSeed;
|
||||
QDialog dialog(this);
|
||||
restoreSeed.setupUi(&dialog);
|
||||
Settings::saveRestore(&dialog);
|
||||
|
||||
|
||||
rpc->fetchSeed([&](QJsonValue reply) {
|
||||
if (isJsonError(reply)) {
|
||||
return;
|
||||
}
|
||||
|
||||
restoreSeed.seed->setReadOnly(true);
|
||||
restoreSeed.seed->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
|
||||
QString seedJson = QLatin1String(QJsonDocument(reply.toObject()).toJson(QJsonDocument::Compact));
|
||||
int startPos = seedJson.indexOf("seed") +7;
|
||||
int endPos = seedJson.indexOf("}") -1;
|
||||
int length = endPos - startPos;
|
||||
QString seed = seedJson.mid(startPos, length);
|
||||
restoreSeed.seed->setPlainText(seed);
|
||||
|
||||
int startPosB = seedJson.indexOf("birthday") +10;
|
||||
int endPosB = seedJson.indexOf("seed") -2;
|
||||
int lengthB = endPosB - startPosB;
|
||||
QString birthday = seedJson.mid(startPosB, lengthB);
|
||||
restoreSeed.birthday->setPlainText(birthday);
|
||||
});
|
||||
|
||||
QObject::connect(restoreSeed.restore, &QPushButton::clicked, [&](){
|
||||
|
||||
QString seed = restoreSeed.seed->toPlainText();
|
||||
if (seed.trimmed().split(" ").length() != 24) {
|
||||
QMessageBox::warning(this, tr("Failed to restore wallet"),
|
||||
tr("SilentDragonLite needs 24 words to restore wallet"),
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 2. Validate birthday
|
||||
QString birthday_str = restoreSeed.birthday->toPlainText();
|
||||
bool ok;
|
||||
qint64 birthday = birthday_str.toUInt(&ok);
|
||||
if (!ok) {
|
||||
QMessageBox::warning(this, tr("Failed to parse wallet birthday"),
|
||||
tr("Couldn't understand wallet birthday. This should be a block height from where to rescan the wallet. You can leave it as '0' if you don't know what it should be."),
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString number_str = restoreSeed.quantity->text();
|
||||
qint64 number = number_str.toUInt();
|
||||
|
||||
auto config = std::shared_ptr<ConnectionConfig>(new ConnectionConfig());
|
||||
config->server = Settings::getInstance()->getSettings().server;
|
||||
// 3. Attempt to restore wallet with the seed phrase
|
||||
{
|
||||
char* resp = litelib_initialize_new_from_phrase(config->server.toStdString().c_str(),
|
||||
seed.toStdString().c_str(), birthday, number);
|
||||
QString reply = litelib_process_response(resp);
|
||||
|
||||
if (reply.toUpper().trimmed() != "OK") {
|
||||
QMessageBox::warning(this, tr("Failed to restore wallet"),
|
||||
tr("Couldn't restore the wallet") + "\n" + reply,
|
||||
QMessageBox::Ok);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Finally attempt to save the wallet
|
||||
{
|
||||
char* resp = litelib_execute("save", "");
|
||||
QString reply = litelib_process_response(resp);
|
||||
|
||||
QByteArray ba_reply = reply.toUtf8();
|
||||
QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
|
||||
QJsonObject parsed = jd_reply.object();
|
||||
|
||||
if (parsed.isEmpty() || parsed["result"].isNull()) {
|
||||
QMessageBox::warning(this, tr("Failed to save wallet"),
|
||||
tr("Couldn't save the wallet") + "\n" + reply,
|
||||
QMessageBox::Ok);
|
||||
|
||||
} else {}
|
||||
|
||||
dialog.close();
|
||||
// To rescan, we clear the wallet state, and then reload the connection
|
||||
// This will start a sync, and show the scanning status.
|
||||
this->getRPC()->clearWallet([=] (auto) {
|
||||
// Save the wallet
|
||||
this->getRPC()->saveWallet([=] (auto) {
|
||||
// Then reload the connection. The ConnectionLoader deletes itself.
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
cl->loadConnection();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// });
|
||||
|
||||
dialog.exec();
|
||||
});
|
||||
|
||||
// Address Book
|
||||
QObject::connect(ui->action_Address_Book, &QAction::triggered, this, &MainWindow::addressBook);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1282</width>
|
||||
<width>1308</width>
|
||||
<height>779</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -59,7 +59,7 @@
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>5</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@@ -428,7 +428,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1234</width>
|
||||
<width>1260</width>
|
||||
<height>509</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -1834,7 +1834,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1282</width>
|
||||
<width>1308</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -1,72 +1,114 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog" >
|
||||
<property name="geometry" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Restore</class>
|
||||
<widget class="QDialog" name="Restore">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>637</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
<property name="windowTitle">
|
||||
<string>Restore your Wallet</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QPlainTextEdit" name="seed">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>284</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Birthday :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Quantity :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="birthday">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>529</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="quantity">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>529</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>521</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="restore">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>89</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user