Merge branch 'embedded' of github.com:adityapk00/zec-qt-wallet into embedded
This commit is contained in:
@@ -16,13 +16,6 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
|
|||||||
connD = new Ui_ConnectionDialog();
|
connD = new Ui_ConnectionDialog();
|
||||||
connD->setupUi(d);
|
connD->setupUi(d);
|
||||||
connD->topIcon->setBasePixmap(QIcon(":/icons/res/icon.ico").pixmap(256, 256));
|
connD->topIcon->setBasePixmap(QIcon(":/icons/res/icon.ico").pixmap(256, 256));
|
||||||
|
|
||||||
// Center on screen
|
|
||||||
QRect screenGeometry = QApplication::desktop()->screenGeometry(d);
|
|
||||||
int x = (screenGeometry.width() - d->width()) / 2;
|
|
||||||
int y = (screenGeometry.height() - d->height()) / 2;
|
|
||||||
d->move(x, y);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionLoader::~ConnectionLoader() {
|
ConnectionLoader::~ConnectionLoader() {
|
||||||
@@ -31,7 +24,11 @@ ConnectionLoader::~ConnectionLoader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionLoader::loadConnection() {
|
void ConnectionLoader::loadConnection() {
|
||||||
d->show();
|
QTimer::singleShot(1, [=]() { this->doAutoConnect(); });
|
||||||
|
d->exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionLoader::doAutoConnect() {
|
||||||
// Priority 1: Try to connect to detect zcash.conf and connect to it.
|
// Priority 1: Try to connect to detect zcash.conf and connect to it.
|
||||||
auto config = autoDetectZcashConf();
|
auto config = autoDetectZcashConf();
|
||||||
|
|
||||||
@@ -44,7 +41,7 @@ void ConnectionLoader::loadConnection() {
|
|||||||
this->showInformation("Starting Embedded zcashd");
|
this->showInformation("Starting Embedded zcashd");
|
||||||
if (this->startEmbeddedZcashd()) {
|
if (this->startEmbeddedZcashd()) {
|
||||||
// Embedded zcashd started up. Wait a second and then refresh the connection
|
// Embedded zcashd started up. Wait a second and then refresh the connection
|
||||||
QTimer::singleShot(1000, [=]() { loadConnection(); } );
|
QTimer::singleShot(1000, [=]() { doAutoConnect(); } );
|
||||||
} else {
|
} else {
|
||||||
// Errored out, show error and exit
|
// Errored out, show error and exit
|
||||||
QString explanation = QString() % "Couldn't start the embedded zcashd.\n\n" %
|
QString explanation = QString() % "Couldn't start the embedded zcashd.\n\n" %
|
||||||
@@ -70,6 +67,23 @@ void ConnectionLoader::loadConnection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString randomPassword() {
|
||||||
|
static const char alphanum[] =
|
||||||
|
"0123456789"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
const int passwordLength = 10;
|
||||||
|
char* s = new char[passwordLength + 1];
|
||||||
|
|
||||||
|
for (int i = 0; i < passwordLength; ++i) {
|
||||||
|
s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
s[passwordLength] = 0;
|
||||||
|
return QString::fromStdString(s);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will create a new zcash.conf, download zcash parameters.
|
* This will create a new zcash.conf, download zcash parameters.
|
||||||
*/
|
*/
|
||||||
@@ -93,13 +107,14 @@ void ConnectionLoader::createZcashConf() {
|
|||||||
|
|
||||||
out << "server=1\n";
|
out << "server=1\n";
|
||||||
out << "rpcuser=zec-qt-wallet\n";
|
out << "rpcuser=zec-qt-wallet\n";
|
||||||
out << "rpcpassword=" % QString::number(std::rand()) << "\n";
|
out << "rpcpassword=" % randomPassword() << "\n";
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
this->loadConnection();
|
this->doAutoConnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ConnectionLoader::downloadParams(std::function<void(void)> cb) {
|
void ConnectionLoader::downloadParams(std::function<void(void)> cb) {
|
||||||
// Add all the files to the download queue
|
// Add all the files to the download queue
|
||||||
downloadQueue = new QQueue<QUrl>();
|
downloadQueue = new QQueue<QUrl>();
|
||||||
@@ -216,20 +231,19 @@ bool ConnectionLoader::startEmbeddedZcashd() {
|
|||||||
qDebug() << "Starting zcashd";
|
qDebug() << "Starting zcashd";
|
||||||
QFileInfo fi(Settings::getInstance()->getExecName());
|
QFileInfo fi(Settings::getInstance()->getExecName());
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
auto zcashdProgram = "zcashd";
|
auto zcashdProgram = fi.dir().absoluteFilePath("zcashd");
|
||||||
#elif defined(Q_OS_DARWIN)
|
#elif defined(Q_OS_DARWIN)
|
||||||
auto zcashdProgram = "zcashd";
|
auto zcashdProgram = fi.dir().absoluteFilePath("zcashd");
|
||||||
#else
|
#else
|
||||||
auto zcashdProgram = "zcashd.exe";
|
auto zcashdProgram = fi.dir().absoluteFilePath("zcashd.exe");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!QFile(zcashdProgram).exists()) {
|
if (!QFile(zcashdProgram).exists()) {
|
||||||
qDebug() << "Can't find zcashd";
|
qDebug() << "Can't find zcashd at " << zcashdProgram;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ezcashd = new QProcess(main);
|
ezcashd = new QProcess(main);
|
||||||
ezcashd->setWorkingDirectory(fi.dir().absolutePath());
|
|
||||||
QObject::connect(ezcashd, &QProcess::started, [=] () {
|
QObject::connect(ezcashd, &QProcess::started, [=] () {
|
||||||
qDebug() << "zcashd started";
|
qDebug() << "zcashd started";
|
||||||
});
|
});
|
||||||
@@ -251,7 +265,7 @@ bool ConnectionLoader::startEmbeddedZcashd() {
|
|||||||
void ConnectionLoader::doManualConnect() {
|
void ConnectionLoader::doManualConnect() {
|
||||||
auto config = loadFromSettings();
|
auto config = loadFromSettings();
|
||||||
|
|
||||||
if (config.get() == nullptr) {
|
if (!config) {
|
||||||
// Nothing configured, show an error
|
// Nothing configured, show an error
|
||||||
QString explanation = QString()
|
QString explanation = QString()
|
||||||
% "A manual connection was requested, but the settings are not configured.\n\n"
|
% "A manual connection was requested, but the settings are not configured.\n\n"
|
||||||
@@ -277,11 +291,13 @@ void ConnectionLoader::doManualConnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionLoader::doRPCSetConnection(Connection* conn) {
|
void ConnectionLoader::doRPCSetConnection(Connection* conn) {
|
||||||
if (ezcashd != nullptr) {
|
if (ezcashd) {
|
||||||
rpc->setEZcashd(ezcashd);
|
rpc->setEZcashd(ezcashd);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc->setConnection(conn);
|
rpc->setConnection(conn);
|
||||||
|
d->accept();
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,10 +366,12 @@ void ConnectionLoader::showInformation(QString info, QString detail) {
|
|||||||
/**
|
/**
|
||||||
* Show error will close the loading dialog and show an error.
|
* Show error will close the loading dialog and show an error.
|
||||||
*/
|
*/
|
||||||
void ConnectionLoader::showError(QString explanation) {
|
void ConnectionLoader::showError(QString explanation) {
|
||||||
d->hide();
|
rpc->setEZcashd(nullptr);
|
||||||
main->ui->statusBar->showMessage("Connection Error");
|
rpc->noConnection();
|
||||||
|
|
||||||
QMessageBox::critical(main, "Connection Error", explanation, QMessageBox::Ok);
|
QMessageBox::critical(main, "Connection Error", explanation, QMessageBox::Ok);
|
||||||
|
d->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConnectionLoader::locateZcashConfFile() {
|
QString ConnectionLoader::locateZcashConfFile() {
|
||||||
@@ -551,4 +569,4 @@ void Connection::showTxError(const QString& error) {
|
|||||||
*/
|
*/
|
||||||
void Connection::shutdown() {
|
void Connection::shutdown() {
|
||||||
shutdownInProgress = true;
|
shutdownInProgress = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ private:
|
|||||||
|
|
||||||
Connection* makeConnection(std::shared_ptr<ConnectionConfig> config);
|
Connection* makeConnection(std::shared_ptr<ConnectionConfig> config);
|
||||||
|
|
||||||
|
void doAutoConnect();
|
||||||
void doManualConnect();
|
void doManualConnect();
|
||||||
|
|
||||||
void createZcashConf();
|
void createZcashConf();
|
||||||
@@ -53,7 +54,6 @@ private:
|
|||||||
bool startEmbeddedZcashd();
|
bool startEmbeddedZcashd();
|
||||||
|
|
||||||
void refreshZcashdState(Connection* connection, std::function<void(void)> refused);
|
void refreshZcashdState(Connection* connection, std::function<void(void)> refused);
|
||||||
int getProgressFromStatus(QString status);
|
|
||||||
|
|
||||||
void showError(QString explanation);
|
void showError(QString explanation);
|
||||||
void showInformation(QString info, QString detail = "");
|
void showInformation(QString info, QString detail = "");
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="status">
|
<widget class="QLabel" name="status">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Connection Status</string>
|
<string>Starting Up</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
|
|||||||
@@ -373,13 +373,6 @@ void MainWindow::setupSettingsModal() {
|
|||||||
QIntValidator validator(0, 65535);
|
QIntValidator validator(0, 65535);
|
||||||
settings.port->setValidator(&validator);
|
settings.port->setValidator(&validator);
|
||||||
|
|
||||||
// Load current values into the dialog
|
|
||||||
auto conf = Settings::getInstance()->getSettings();
|
|
||||||
settings.hostname->setText(conf.host);
|
|
||||||
settings.port->setText(conf.port);
|
|
||||||
settings.rpcuser->setText(conf.rpcuser);
|
|
||||||
settings.rpcpassword->setText(conf.rpcpassword);
|
|
||||||
|
|
||||||
// If values are coming from zcash.conf, then disable all the fields
|
// If values are coming from zcash.conf, then disable all the fields
|
||||||
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
|
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
|
||||||
if (!zcashConfLocation.isEmpty()) {
|
if (!zcashConfLocation.isEmpty()) {
|
||||||
@@ -390,6 +383,13 @@ void MainWindow::setupSettingsModal() {
|
|||||||
settings.rpcpassword->setEnabled(false);
|
settings.rpcpassword->setEnabled(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Load current values into the dialog
|
||||||
|
auto conf = Settings::getInstance()->getSettings();
|
||||||
|
settings.hostname->setText(conf.host);
|
||||||
|
settings.port->setText(conf.port);
|
||||||
|
settings.rpcuser->setText(conf.rpcuser);
|
||||||
|
settings.rpcpassword->setText(conf.rpcpassword);
|
||||||
|
|
||||||
settings.confMsg->setText("No local zcash.conf found. Please configure connection manually.");
|
settings.confMsg->setText("No local zcash.conf found. Please configure connection manually.");
|
||||||
settings.hostname->setEnabled(true);
|
settings.hostname->setEnabled(true);
|
||||||
settings.port->setEnabled(true);
|
settings.port->setEnabled(true);
|
||||||
|
|||||||
@@ -316,8 +316,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>920</width>
|
<width>922</width>
|
||||||
<height>334</height>
|
<height>376</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="sendToLayout">
|
<layout class="QVBoxLayout" name="sendToLayout">
|
||||||
@@ -767,7 +767,7 @@
|
|||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QLabel" name="numconnections">
|
<widget class="QLabel" name="numconnections">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>Loading...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -781,7 +781,7 @@
|
|||||||
<item row="3" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QLabel" name="solrate">
|
<widget class="QLabel" name="solrate">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>Loading...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -802,7 +802,7 @@
|
|||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="blockheight">
|
<widget class="QLabel" name="blockheight">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>Loading...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -864,7 +864,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>968</width>
|
<width>968</width>
|
||||||
<height>22</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|||||||
53
src/rpc.cpp
53
src/rpc.cpp
@@ -9,8 +9,8 @@ using json = nlohmann::json;
|
|||||||
RPC::RPC(MainWindow* main) {
|
RPC::RPC(MainWindow* main) {
|
||||||
auto cl = new ConnectionLoader(main, this);
|
auto cl = new ConnectionLoader(main, this);
|
||||||
|
|
||||||
// Show a default no connection message until we can connect.
|
// Execute the load connection async, so we can set up the rest of RPC properly.
|
||||||
cl->loadConnection();
|
QTimer::singleShot(1, [=]() {cl->loadConnection(); });
|
||||||
|
|
||||||
this->main = main;
|
this->main = main;
|
||||||
this->ui = main->ui;
|
this->ui = main->ui;
|
||||||
@@ -66,6 +66,9 @@ RPC::~RPC() {
|
|||||||
|
|
||||||
void RPC::setEZcashd(QProcess* p) {
|
void RPC::setEZcashd(QProcess* p) {
|
||||||
ezcashd = p;
|
ezcashd = p;
|
||||||
|
|
||||||
|
if (ezcashd == nullptr)
|
||||||
|
ui->tabWidget->removeTab(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPC::setConnection(Connection* c) {
|
void RPC::setConnection(Connection* c) {
|
||||||
@@ -326,8 +329,10 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RPC::noConnection() {
|
void RPC::noConnection() {
|
||||||
ui->statusBar->showMessage("No Connection to zcashd");
|
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
|
||||||
|
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
||||||
|
main->statusLabel->setText("No Connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh received z txs by calling z_listreceivedbyaddress/gettransaction
|
// Refresh received z txs by calling z_listreceivedbyaddress/gettransaction
|
||||||
@@ -439,7 +444,6 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// This will refresh all the balance data from zcashd
|
/// This will refresh all the balance data from zcashd
|
||||||
void RPC::refresh(bool force) {
|
void RPC::refresh(bool force) {
|
||||||
if (conn == nullptr)
|
if (conn == nullptr)
|
||||||
@@ -482,7 +486,7 @@ void RPC::getInfoThenRefresh(bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get network sol/s
|
// Get network sol/s
|
||||||
if (ezcashd != nullptr) {
|
if (ezcashd) {
|
||||||
int conns = reply["connections"].get<json::number_integer_t>();
|
int conns = reply["connections"].get<json::number_integer_t>();
|
||||||
|
|
||||||
json payload = {
|
json payload = {
|
||||||
@@ -498,11 +502,7 @@ void RPC::getInfoThenRefresh(bool force) {
|
|||||||
ui->numconnections->setText(QString::number(conns));
|
ui->numconnections->setText(QString::number(conns));
|
||||||
ui->solrate->setText(QString::number(solrate) % " Sol/s");
|
ui->solrate->setText(QString::number(solrate) % " Sol/s");
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
qDebug() << "removing tab!";
|
|
||||||
ui->tabWidget->removeTab(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Call to see if the blockchain is syncing.
|
// Call to see if the blockchain is syncing.
|
||||||
json payload = {
|
json payload = {
|
||||||
@@ -519,6 +519,18 @@ void RPC::getInfoThenRefresh(bool force) {
|
|||||||
Settings::getInstance()->setSyncing(isSyncing);
|
Settings::getInstance()->setSyncing(isSyncing);
|
||||||
Settings::getInstance()->setBlockNumber(blockNumber);
|
Settings::getInstance()->setBlockNumber(blockNumber);
|
||||||
|
|
||||||
|
// Update zcashd tab if it exists
|
||||||
|
if (ezcashd && isSyncing) {
|
||||||
|
// 895 / ~426530 (0 % )
|
||||||
|
const qint64 genisisTimeMSec = 1477638000000;
|
||||||
|
qint64 estBlocks = (QDateTime::currentMSecsSinceEpoch() - genisisTimeMSec) / 2.5 / 60 / 1000;
|
||||||
|
// Round to nearest 10
|
||||||
|
estBlocks = ((estBlocks + 5) / 10) * 10;
|
||||||
|
ui->blockheight->setText(ui->blockheight->text() % /*" / ~" % QString::number(estBlocks) % */
|
||||||
|
" ( " % QString::number(progress * 100, 'f', 0) % "% )");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the status bar
|
||||||
QString statusText = QString() %
|
QString statusText = QString() %
|
||||||
(isSyncing ? "Syncing" : "Connected") %
|
(isSyncing ? "Syncing" : "Connected") %
|
||||||
" (" %
|
" (" %
|
||||||
@@ -825,7 +837,7 @@ void RPC::refreshZECPrice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const json& item : parsed.get<json::array_t>()) {
|
for (const json& item : parsed.get<json::array_t>()) {
|
||||||
if (item["symbol"].get<json::string_t>().compare("ZEC") == 0) {
|
if (item["symbol"].get<json::string_t>() == "ZEC") {
|
||||||
QString price = QString::fromStdString(item["price_usd"].get<json::string_t>());
|
QString price = QString::fromStdString(item["price_usd"].get<json::string_t>());
|
||||||
qDebug() << "ZEC Price=" << price;
|
qDebug() << "ZEC Price=" << price;
|
||||||
Settings::getInstance()->setZECPrice(price.toDouble());
|
Settings::getInstance()->setZECPrice(price.toDouble());
|
||||||
@@ -859,19 +871,22 @@ void RPC::shutdownZcashd() {
|
|||||||
conn->doRPCWithDefaultErrorHandling(payload, [=](auto) {});
|
conn->doRPCWithDefaultErrorHandling(payload, [=](auto) {});
|
||||||
conn->shutdown();
|
conn->shutdown();
|
||||||
|
|
||||||
|
QDialog d(main);
|
||||||
|
Ui_ConnectionDialog connD;
|
||||||
|
connD.setupUi(&d);
|
||||||
|
connD.topIcon->setBasePixmap(QIcon(":/icons/res/icon.ico").pixmap(256, 256));
|
||||||
|
connD.status->setText("Please wait for zec-qt-wallet to exit");
|
||||||
|
connD.statusDetail->setText("Waiting for zcashd to exit");
|
||||||
|
|
||||||
QMessageBox d(main);
|
|
||||||
d.setIcon(QMessageBox::Icon::Information);
|
|
||||||
d.setWindowTitle("Waiting for zcashd to exit");
|
|
||||||
d.setText("Please wait for zcashd to exit. Don't click OK!");
|
|
||||||
d.setStandardButtons(QMessageBox::NoButton);
|
|
||||||
|
|
||||||
QTimer waiter(main);
|
QTimer waiter(main);
|
||||||
|
|
||||||
// We capture by reference all the local variables because of the d.exec()
|
// We capture by reference all the local variables because of the d.exec()
|
||||||
// below, which blocks this function until we exit.
|
// below, which blocks this function until we exit.
|
||||||
|
int waitCount = 0;
|
||||||
QObject::connect(&waiter, &QTimer::timeout, [&] () {
|
QObject::connect(&waiter, &QTimer::timeout, [&] () {
|
||||||
if (ezcashd->atEnd() && ezcashd->processId() == 0) {
|
waitCount++;
|
||||||
|
if ((ezcashd->atEnd() && ezcashd->processId() == 0) ||
|
||||||
|
waitCount > 30) {
|
||||||
qDebug() << "Ended";
|
qDebug() << "Ended";
|
||||||
waiter.stop();
|
waiter.stop();
|
||||||
QTimer::singleShot(1000, [&]() { d.accept(); });
|
QTimer::singleShot(1000, [&]() { d.accept(); });
|
||||||
|
|||||||
@@ -59,16 +59,14 @@ public:
|
|||||||
void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
|
void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
|
||||||
|
|
||||||
void shutdownZcashd();
|
void shutdownZcashd();
|
||||||
|
void noConnection();
|
||||||
|
|
||||||
void getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>)>);
|
void getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>)>);
|
||||||
|
|
||||||
Turnstile* getTurnstile() { return turnstile; }
|
Turnstile* getTurnstile() { return turnstile; }
|
||||||
Connection* getConnection() { return conn; }
|
Connection* getConnection() { return conn; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void noConnection();
|
|
||||||
|
|
||||||
void refreshBalances();
|
void refreshBalances();
|
||||||
|
|
||||||
void refreshTransactions();
|
void refreshTransactions();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ QList<TransactionItem> SentTxStore::readSentTxFile() {
|
|||||||
QJsonDocument jsonDoc;
|
QJsonDocument jsonDoc;
|
||||||
|
|
||||||
data.open(QFile::ReadOnly);
|
data.open(QFile::ReadOnly);
|
||||||
jsonDoc = QJsonDocument().fromJson(data.readAll());
|
jsonDoc = QJsonDocument::fromJson(data.readAll());
|
||||||
data.close();
|
data.close();
|
||||||
|
|
||||||
QList<TransactionItem> items;
|
QList<TransactionItem> items;
|
||||||
@@ -87,7 +87,7 @@ void SentTxStore::addToSentTx(Tx tx, QString txid) {
|
|||||||
QJsonObject txItem;
|
QJsonObject txItem;
|
||||||
txItem["type"] = "sent";
|
txItem["type"] = "sent";
|
||||||
txItem["from"] = tx.fromAddr;
|
txItem["from"] = tx.fromAddr;
|
||||||
txItem["datetime"] = QDateTime().currentMSecsSinceEpoch() / (qint64)1000;
|
txItem["datetime"] = QDateTime::currentMSecsSinceEpoch() / (qint64)1000;
|
||||||
txItem["address"] = QString(); // The sent address is blank, to be consistent with t-Addr sent behaviour
|
txItem["address"] = QString(); // The sent address is blank, to be consistent with t-Addr sent behaviour
|
||||||
txItem["txid"] = txid;
|
txItem["txid"] = txid;
|
||||||
txItem["amount"] = -totalAmount;
|
txItem["amount"] = -totalAmount;
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
|
|
||||||
Settings* Settings::instance = nullptr;
|
Settings* Settings::instance = nullptr;
|
||||||
|
|
||||||
Settings::~Settings() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Settings::getSaveZtxs() {
|
bool Settings::getSaveZtxs() {
|
||||||
// Load from the QT Settings.
|
// Load from the QT Settings.
|
||||||
return QSettings().value("options/savesenttx", true).toBool();
|
return QSettings().value("options/savesenttx", true).toBool();
|
||||||
@@ -122,4 +119,4 @@ QString Settings::getZECUSDDisplayFormat(double bal) {
|
|||||||
return getZECDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")";
|
return getZECDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")";
|
||||||
else
|
else
|
||||||
return getZECDisplayFormat(bal);
|
return getZECDisplayFormat(bal);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ Turnstile::Turnstile(RPC* _rpc, MainWindow* mainwindow) {
|
|||||||
this->mainwindow = mainwindow;
|
this->mainwindow = mainwindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
Turnstile::~Turnstile() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void printPlan(QList<TurnstileMigrationItem> plan) {
|
void printPlan(QList<TurnstileMigrationItem> plan) {
|
||||||
for (auto item : plan) {
|
for (auto item : plan) {
|
||||||
@@ -118,7 +116,7 @@ void Turnstile::planMigration(QString zaddr, QString destAddr, int numsplits, in
|
|||||||
|
|
||||||
// The first migration is shifted to the current block, so the user sees something
|
// The first migration is shifted to the current block, so the user sees something
|
||||||
// happening immediately
|
// happening immediately
|
||||||
if (migItems.size() == 0) {
|
if (migItems.empty()) {
|
||||||
// Show error and abort
|
// Show error and abort
|
||||||
QMessageBox::warning(mainwindow,
|
QMessageBox::warning(mainwindow,
|
||||||
"Locked funds",
|
"Locked funds",
|
||||||
@@ -220,9 +218,7 @@ Turnstile::getNextStep(QList<TurnstileMigrationItem>& plan) {
|
|||||||
|
|
||||||
bool Turnstile::isMigrationPresent() {
|
bool Turnstile::isMigrationPresent() {
|
||||||
auto plan = readMigrationPlan();
|
auto plan = readMigrationPlan();
|
||||||
if (plan.isEmpty()) return false;
|
return !plan.isEmpty();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressReport Turnstile::getPlanProgress() {
|
ProgressReport Turnstile::getPlanProgress() {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class Turnstile
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Turnstile(RPC* _rpc, MainWindow* mainwindow);
|
Turnstile(RPC* _rpc, MainWindow* mainwindow);
|
||||||
~Turnstile();
|
|
||||||
|
|
||||||
void planMigration(QString zaddr, QString destAddr, int splits, int numBlocks);
|
void planMigration(QString zaddr, QString destAddr, int splits, int numBlocks);
|
||||||
QList<double> splitAmount(double amount, int parts);
|
QList<double> splitAmount(double amount, int parts);
|
||||||
|
|||||||
Reference in New Issue
Block a user