Wire up new seed page for wizard

This commit is contained in:
Aditya Kulkarni
2019-10-24 11:17:22 -07:00
parent f9beda0ded
commit 9c4ef3e019
17 changed files with 581 additions and 34 deletions

View File

@@ -2,9 +2,11 @@
#include "mainwindow.h"
#include "settings.h"
#include "ui_connection.h"
#include "firsttimewizard.h"
#include "ui_createzcashconfdialog.h"
#include "controller.h"
#include "../lib/zecwalletlitelib.h"
#include "precompiled.h"
@@ -42,7 +44,15 @@ void ConnectionLoader::doAutoConnect() {
// Initialize the library
main->logger->write(QObject::tr("Attempting to initialize"));
litelib_initialze_existing(config->dangerous, config->server.toStdString().c_str());
// Check to see if there's an existing wallet
if (litelib_wallet_exists(Settings::getChainName().toStdString().c_str())) {
main->logger->write(QObject::tr("Using existing wallet."));
litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str());
} else {
main->logger->write(QObject::tr("Create/restore wallet."));
createOrRestore(config->dangerous, config->server);
}
auto connection = makeConnection(config);
@@ -54,6 +64,16 @@ void ConnectionLoader::doAutoConnect() {
}, [=](auto err) {});
}
void ConnectionLoader::createOrRestore(bool dangerous, QString server) {
// Close the startup dialog, since we'll be showing the wizard
d->hide();
// Create a wizard
FirstTimeWizard wizard(dangerous, server);
wizard.exec();
}
void ConnectionLoader::doRPCSetConnection(Connection* conn) {
rpc->setConnection(conn);
@@ -94,15 +114,7 @@ void ConnectionLoader::showError(QString explanation) {
d->close();
}
/***********************************************************************************
* Connection, Executor and Callback Class
************************************************************************************/
void Executor::run() {
char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str());
// Copy the string, since we need to return this back to rust
QString litelib_process_response(char* resp) {
char* resp_copy = new char[strlen(resp) + 1];
strcpy(resp_copy, resp);
litelib_rust_free_string(resp);
@@ -111,6 +123,17 @@ void Executor::run() {
memset(resp_copy, '-', strlen(resp_copy));
delete[] resp_copy;
return reply;
}
/***********************************************************************************
* Connection, Executor and Callback Class
************************************************************************************/
void Executor::run() {
char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str());
QString reply = litelib_process_response(resp);
qDebug() << "Reply=" << reply;
auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false);
if (parsed.is_discarded() || parsed.is_null()) {