add dangerous option

This commit is contained in:
DenioD
2020-07-25 14:56:16 +02:00
parent ab46276cee
commit 1171aca5df
9 changed files with 87 additions and 60 deletions

View File

@@ -69,6 +69,7 @@ void ConnectionLoader::doAutoConnect()
{
qDebug() << "Doing autoconnect";
auto config = std::shared_ptr<ConnectionConfig>(new ConnectionConfig());
config->dangerous = false;
config->server = Settings::getInstance()->getSettings().server;
// Initialize the library
@@ -79,6 +80,7 @@ void ConnectionLoader::doAutoConnect()
{
main->logger->write(QObject::tr("Using existing wallet."));
char* resp = litelib_initialize_existing(
config->dangerous,
config->server.toStdString().c_str()
);
QString response = litelib_process_response(resp);
@@ -93,7 +95,7 @@ void ConnectionLoader::doAutoConnect()
else
{
main->logger->write(QObject::tr("Create/restore wallet."));
createOrRestore(config->server);
createOrRestore(config->dangerous, config->server);
d->show();
}
@@ -160,12 +162,12 @@ void ConnectionLoader::doAutoConnect()
});
}
void ConnectionLoader::createOrRestore(QString server)
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(server);
FirstTimeWizard wizard(dangerous,server);
main->logger->write("Start new Wallet with FirstimeWizard");
wizard.exec();
}

View File

@@ -11,6 +11,7 @@ class Controller;
struct ConnectionConfig {
QString server;
bool dangerous;
QString proxy;
};
@@ -32,7 +33,7 @@ private:
void doAutoConnect();
void createOrRestore(QString server);
void createOrRestore(bool dangerous, QString server);
void showError(QString explanation);
void showInformation(QString info, QString detail = "");

View File

@@ -9,9 +9,10 @@
#include "../lib/silentdragonlitelib.h"
FirstTimeWizard::FirstTimeWizard(QString server)
FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server)
{
setWindowTitle("New wallet wizard");
this->dangerous = dangerous;
this->server = server;
////backup addresslabels.dat if there is one, to restore it later
@@ -193,7 +194,7 @@ NewSeedPage::NewSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) {
void NewSeedPage::initializePage() {
// Call the library to create a new wallet.
char* resp = litelib_initialize_new(parent->server.toStdString().c_str());
char* resp = litelib_initialize_new(parent->dangerous,parent->server.toStdString().c_str());
QString reply = litelib_process_response(resp);
auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false);
@@ -267,7 +268,7 @@ QString number_str = form.number->text();
qint64 number = number_str.toUInt();
// 3. Attempt to restore wallet with the seed phrase
{
char* resp = litelib_initialize_new_from_phrase(parent->server.toStdString().c_str(),
char* resp = litelib_initialize_new_from_phrase(parent->dangerous, parent->server.toStdString().c_str(),
seed.toStdString().c_str(), birthday, number);
QString reply = litelib_process_response(resp);

View File

@@ -16,7 +16,7 @@ class FirstTimeWizard: public QWizard
public:
FirstTimeWizard(QString server);
FirstTimeWizard(bool dangerous, QString server);
protected:
@@ -29,6 +29,7 @@ private:
Page_Restore
};
bool dangerous;
QString server;
friend class NewOrRestorePage;

View File

@@ -166,7 +166,7 @@ MainWindow::MainWindow(QWidget *parent) :
// Rescan
QObject::connect(ui->actionRescan, &QAction::triggered, [=]() {
QFile file(dirwalletenc);
/* QFile file(dirwalletenc);
QFile file1(dirwallet);
if(fileExists(dirwalletenc))
@@ -174,7 +174,7 @@ MainWindow::MainWindow(QWidget *parent) :
{
file.remove();
file1.remove();
}
}*/
Ui_Restore restoreSeed;
@@ -234,7 +234,7 @@ MainWindow::MainWindow(QWidget *parent) :
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(),
char* resp = litelib_initialize_new_from_phrase(config->dangerous, config->server.toStdString().c_str(),
seed.toStdString().c_str(), birthday, number);
QString reply = litelib_process_response(resp);