Merge pull request #180 from MyHush/dev

verify Seed and Birthday, fix radio button, update translations
This commit is contained in:
Denio
2020-07-27 21:10:27 +02:00
committed by GitHub
18 changed files with 7498 additions and 4553 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -138,7 +138,8 @@ FORMS += \
src/about.ui \
src/confirm.ui \
src/privkey.ui \
src/memodialog.ui \
src/memodialog.ui \
src/verifyseed.ui \
src/startupencryption.ui \
src/viewalladdresses.ui \
src/connection.ui \

View File

@@ -2,12 +2,29 @@
#include "ui_newseed.h"
#include "ui_restoreseed.h"
#include "ui_verifyseed.h"
#include "ui_newwallet.h"
#include "mainwindow.h"
#include "DataStore/DataStore.h"
#include "../lib/silentdragonlitelib.h"
#ifdef Q_OS_WIN
auto dirwalletfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet.dat");
auto dirwalletencfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet-enc.dat");
auto dirwalletbackupfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet.datBackup");
#endif
#ifdef Q_OS_MACOS
auto dirwalletfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet.dat");
auto dirwalletencfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet-enc.dat");
auto dirwalletbackupfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet.datBackup");
#endif
#ifdef Q_OS_LINUX
auto dirwalletfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".silentdragonlite/silentdragonlite-wallet.dat");
auto dirwalletencfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat");
auto dirwalletbackupfirst = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".silentdragonlite/silentdragonlite-wallet.datBackup");
#endif
FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server)
{
@@ -15,6 +32,7 @@ FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server)
this->dangerous = dangerous;
this->server = server;
////backup addresslabels.dat if there is one, to restore it later
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
@@ -48,6 +66,30 @@ int FirstTimeWizard::nextId() const {
}
}
QString FirstTimeWizard::getSeed()
{
return _seed;
}
void FirstTimeWizard::setSeed(QString seed)
{
_seed = seed;
}
QString FirstTimeWizard::getBirthday()
{
return _birthday;
}
void FirstTimeWizard::setBirthday(QString birthday)
{
_birthday = birthday;
}
NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent) {
setTitle("Create or Restore wallet.");
@@ -74,6 +116,9 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
form.txtPassword->setEnabled(true);
form.txtConfirmPassword->setEnabled(true);
}else{
parent->button(QWizard::CommitButton)->setEnabled(false);
parent->button(QWizard::NextButton)->setEnabled(false);
}
});
@@ -94,7 +139,7 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
form.radioRestoreWallet->setEnabled(true);
form.radioNewWallet->setEnabled(true);
form.radioNewWallet->setChecked(true);
parent->button(QWizard::CommitButton)->setEnabled(true);
int length = passphrase.length();
@@ -125,16 +170,13 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
/* out of memory */
}
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
DataStore::getChatDataStore()->setPassword(passphraseHash1);
//main->setPassword(Password);
//qDebug()<<"Objekt gesetzt";
DataStore::getChatDataStore()->setPassword(passphraseHash1);
// Exclusive buttons
// Exclusive buttons
QObject::connect(form.radioNewWallet, &QRadioButton::clicked, [=](bool checked) {
if (checked) {
form.radioRestoreWallet->setChecked(false);
parent->button(QWizard::CommitButton)->setEnabled(true);
}
});
@@ -142,6 +184,7 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
QObject::connect(form.radioRestoreWallet, &QRadioButton::clicked, [=](bool checked) {
if (checked) {
form.radioNewWallet->setChecked(false);
parent->button(QWizard::CommitButton)->setEnabled(true);
}
});
@@ -201,16 +244,45 @@ void NewSeedPage::initializePage() {
if (parsed.is_discarded() || parsed.is_null() || parsed.find("seed") == parsed.end()) {
form.txtSeed->setPlainText(tr("Error creating a wallet") + "\n" + reply);
} else {
QString birthday = QString::number(parsed["birthday"].get<json::number_unsigned_t>());
QString seed = QString::fromStdString(parsed["seed"].get<json::string_t>());
form.txtSeed->setPlainText(seed);
parent->setSeed(seed);
parent->setBirthday(birthday);
form.birthday->setPlainText(birthday);
parent->button(QWizard::CancelButton)->setEnabled(false);
disconnect(parent->button(QWizard::CancelButton ), SIGNAL( clicked() ), parent, SLOT( reject() ) );
connect(parent->button(QWizard::CancelButton ), SIGNAL( clicked() ), parent, SLOT( cancelEvent() ) );
}
}
void FirstTimeWizard::cancelEvent()
{
if( QMessageBox::question( this, ( "Quit Setup" ), ( "Setup is not complete yet. Are you sure you want to quit setup?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
// allow cancel
reject();
}
}
// Will be called just before closing. Make sure we can save the seed in the wallet
// before we allow the page to be closed
bool NewSeedPage::validatePage() {
Ui_verifyseed verifyseed;
QDialog dialog(this);
verifyseed.setupUi(&dialog);
Settings::saveRestore(&dialog);
dialog.exec();
QString seed = parent->getSeed();
QString birthday = parent->getBirthday();
if ((verifyseed.verifyText->toPlainText() == seed) && (verifyseed.verifyBirthday->toPlainText() == birthday))
{
char* resp = litelib_execute("save", "");
QString reply = litelib_process_response(resp);
@@ -224,6 +296,20 @@ bool NewSeedPage::validatePage() {
} else {
return true;
}
}else{
qDebug()<<"Falscher Seed";
QFile file(dirwalletencfirst);
QFile file1(dirwalletfirst);
file.remove();
file1.remove();
QMessageBox::warning(this, tr("Wrong Seed"),
tr("Please try again") + "\n" ,
QMessageBox::Ok);
return false;
this->validatePage();
}
}

View File

@@ -17,6 +17,13 @@ class FirstTimeWizard: public QWizard
public:
FirstTimeWizard(bool dangerous, QString server);
QString getSeed();
void setSeed(QString Seed);
QString _seed;
QString getBirthday();
void setBirthday(QString Birthday);
QString _birthday;
void cancelEvent();
protected:
@@ -51,6 +58,7 @@ public:
class NewSeedPage: public QWizardPage {
public:
NewSeedPage(FirstTimeWizard* parent);
protected:
virtual void initializePage();

View File

@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>416</height>
<width>432</width>
<height>516</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>This is your new wallet's seed phrase. PLEASE BACK IT UP SECURELY.</string>
@@ -24,7 +24,17 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>The seed phrase is the only way to restore the wallet. If you forget the seed phrase, THERE IS NO WAY TO RESTORE YOUR WALLET AND THE FUNDS in it</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@@ -46,16 +56,40 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>The seed phrase is the only way to restore the wallet. If you forget the seed phrase, THERE IS NO WAY TO RESTORE YOUR WALLET AND THE FUNDS in it</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;This is the birthday of your Seed. Please back it up too&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Birthday of the Seed :</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="birthday">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>

View File

@@ -244,6 +244,12 @@ p, li { white-space: pre-wrap; }
<property name="text">
<string>Restore wallet from seed</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
@@ -278,6 +284,15 @@ p, li { white-space: pre-wrap; }
<property name="text">
<string>Create a new wallet</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
@@ -289,4 +304,7 @@ p, li { white-space: pre-wrap; }
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

105
src/verifyseed.ui Normal file
View File

@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>verifyseed</class>
<widget class="QDialog" name="verifyseed">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>458</width>
<height>333</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Please verify, that you have backup your Seed and Birthday. &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Please enter your Seed :</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QTextEdit" name="verifyText">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>121</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Please enter the birthday of the Seed :</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextEdit" name="verifyBirthday">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>41</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>verifyseed</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>verifyseed</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>
</ui>

View File

@@ -1 +1 @@
#define APP_VERSION "1.3.8"
#define APP_VERSION "1.3.9"