set passphrase on initial install #64
This commit is contained in:
@@ -33,6 +33,18 @@ ChatItem ChatDataStore::getData(QString key)
|
||||
return this->data[key];
|
||||
}
|
||||
|
||||
QString ChatDataStore::getPassword()
|
||||
{
|
||||
|
||||
return _password;
|
||||
}
|
||||
|
||||
void ChatDataStore::setPassword(QString password)
|
||||
{
|
||||
|
||||
_password = password;
|
||||
}
|
||||
|
||||
QString ChatDataStore::dump()
|
||||
{
|
||||
json chats;
|
||||
|
||||
@@ -25,6 +25,11 @@ class ChatDataStore
|
||||
std::map<QString, ChatItem> getAllNewContactRequests();
|
||||
std::map<QString, ChatItem> getAllOldContactRequests();
|
||||
std::map<QString, ChatItem> getAllMemos();
|
||||
QString getPassword();
|
||||
|
||||
void setPassword(QString Password);
|
||||
QString _password;
|
||||
|
||||
QString dump();
|
||||
|
||||
~ChatDataStore()
|
||||
|
||||
@@ -454,7 +454,7 @@ Tx MainWindow::createTxFromChatPage() {
|
||||
|
||||
|
||||
QString pubkey = this->getPubkeyByAddress(addr);
|
||||
QString passphrase = this->getPassword();
|
||||
QString passphrase = DataStore::getChatDataStore()->getPassword();
|
||||
QString hashEncryptionKey = passphrase;
|
||||
int length = hashEncryptionKey.length();
|
||||
|
||||
@@ -783,7 +783,7 @@ Tx MainWindow::createTxForSafeContactRequest()
|
||||
|
||||
QString memo = contactRequest.getMemo();
|
||||
// QString privkey = rpc->fetchPrivKey(myAddr);
|
||||
QString passphrase = this->getPassword();
|
||||
QString passphrase = DataStore::getChatDataStore()->getPassword();
|
||||
QString hashEncryptionKey = passphrase;
|
||||
int length = hashEncryptionKey.length();
|
||||
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "Model/ChatItem.h"
|
||||
#include "DataStore/DataStore.h"
|
||||
|
||||
/*template<>
|
||||
DataStore<QString>* DataStore<QString>::instance = nullptr;
|
||||
template<>
|
||||
bool DataStore<QString>::instanced = false;*/
|
||||
ChatModel *chatModel = new ChatModel();
|
||||
Chat *chat = new Chat();
|
||||
ContactModel *contactModel = new ContactModel();
|
||||
@@ -971,7 +967,7 @@ void Controller::refreshTransactions() {
|
||||
if ((memo.startsWith("{") == false) && (headerbytes.length() > 20))
|
||||
{
|
||||
|
||||
QString passphrase = main->getPassword();
|
||||
QString passphrase = DataStore::getChatDataStore()->getPassword();
|
||||
QString hashEncryptionKey = passphrase;
|
||||
int length = hashEncryptionKey.length();
|
||||
|
||||
@@ -1227,7 +1223,7 @@ void Controller::refreshTransactions() {
|
||||
chatModel->addMemo(txid, headerbytes);
|
||||
}else{}
|
||||
|
||||
QString passphrase = main->getPassword();
|
||||
QString passphrase = DataStore::getChatDataStore()->getPassword();
|
||||
QString hashEncryptionKey = passphrase;
|
||||
int length = hashEncryptionKey.length();
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "ui_newseed.h"
|
||||
#include "ui_restoreseed.h"
|
||||
#include "ui_newwallet.h"
|
||||
#include "mainwindow.h"
|
||||
#include "DataStore/DataStore.h"
|
||||
|
||||
#include "../lib/silentdragonlitelib.h"
|
||||
|
||||
@@ -38,31 +40,75 @@ int FirstTimeWizard::nextId() const {
|
||||
NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent) {
|
||||
setTitle("Create or Restore wallet.");
|
||||
|
||||
|
||||
|
||||
QWidget* pageWidget = new QWidget();
|
||||
Ui_CreateWalletForm form;
|
||||
form.setupUi(pageWidget);
|
||||
|
||||
|
||||
// Exclusive buttons
|
||||
auto fnPasswordEdited = [=](const QString&) {
|
||||
// Enable the Finish button if the passwords match.
|
||||
QString Password = form.txtPassword->text();
|
||||
|
||||
if (!form.txtPassword->text().isEmpty() &&
|
||||
form.txtPassword->text() == form.txtConfirmPassword->text() && Password.size() >= 16) {
|
||||
|
||||
form.lblPasswordMatch->setText("");
|
||||
parent->button(QWizard::CommitButton)->setEnabled(true);
|
||||
setButtonText(QWizard::CommitButton, "Next");
|
||||
form.radioRestoreWallet->setEnabled(true);
|
||||
form.radioNewWallet->setEnabled(true);
|
||||
form.radioNewWallet->setChecked(true);
|
||||
qDebug()<<"PW :"<<Password;
|
||||
|
||||
|
||||
DataStore::getChatDataStore()->setPassword(Password);
|
||||
//main->setPassword(Password);
|
||||
|
||||
//qDebug()<<"Objekt gesetzt";
|
||||
|
||||
|
||||
// Exclusive buttons
|
||||
QObject::connect(form.radioNewWallet, &QRadioButton::clicked, [=](bool checked) {
|
||||
if (checked) {
|
||||
form.radioRestoreWallet->setChecked(false);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(form.radioRestoreWallet, &QRadioButton::clicked, [=](bool checked) {
|
||||
if (checked) {
|
||||
form.radioNewWallet->setChecked(false);
|
||||
|
||||
}
|
||||
});
|
||||
form.radioNewWallet->setChecked(true);
|
||||
|
||||
|
||||
registerField("intro.new", form.radioNewWallet);
|
||||
|
||||
} else {
|
||||
form.lblPasswordMatch->setText(tr("Passphrase don't match or You have entered too few letters (16 minimum)"));
|
||||
|
||||
parent->button(QWizard::CommitButton)->setEnabled(false);
|
||||
form.radioRestoreWallet->setEnabled(false);
|
||||
form.radioNewWallet->setEnabled(false);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(pageWidget);
|
||||
setLayout(layout);
|
||||
|
||||
|
||||
QObject::connect(form.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||
QObject::connect(form.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||
registerField("intro.new", form.radioNewWallet);
|
||||
form.radioRestoreWallet->setEnabled(false);
|
||||
form.radioNewWallet->setEnabled(false);
|
||||
setCommitPage(true);
|
||||
setButtonText(QWizard::CommitButton, "Next");
|
||||
|
||||
|
||||
}
|
||||
|
||||
NewSeedPage::NewSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) {
|
||||
@@ -81,6 +127,7 @@ NewSeedPage::NewSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) {
|
||||
|
||||
void NewSeedPage::initializePage() {
|
||||
// Call the library to create a new wallet.
|
||||
|
||||
char* resp = litelib_initialize_new(parent->dangerous, parent->server.toStdString().c_str());
|
||||
QString reply = litelib_process_response(resp);
|
||||
|
||||
@@ -90,7 +137,11 @@ void NewSeedPage::initializePage() {
|
||||
} else {
|
||||
QString seed = QString::fromStdString(parsed["seed"].get<json::string_t>());
|
||||
form.txtSeed->setPlainText(seed);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Will be called just before closing. Make sure we can save the seed in the wallet
|
||||
@@ -175,4 +226,4 @@ bool RestoreSeedPage::validatePage() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,18 @@
|
||||
|
||||
#include "ui_newseed.h"
|
||||
#include "ui_restoreseed.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
|
||||
class FirstTimeWizard: public QWizard
|
||||
{
|
||||
|
||||
|
||||
|
||||
public:
|
||||
FirstTimeWizard(bool dangerous, QString server);
|
||||
|
||||
|
||||
protected:
|
||||
int nextId() const;
|
||||
@@ -27,11 +34,16 @@ private:
|
||||
friend class NewOrRestorePage;
|
||||
friend class NewSeedPage;
|
||||
friend class RestoreSeedPage;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class NewOrRestorePage: public QWizardPage {
|
||||
public:
|
||||
|
||||
NewOrRestorePage(FirstTimeWizard* parent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "Crypto/passwd.h"
|
||||
#include "Crypto/FileEncryption.h"
|
||||
#include "DataStore/DataStore.h"
|
||||
#include "firsttimewizard.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -52,8 +53,6 @@ auto dirwalletenc = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLo
|
||||
auto dirwalletbackup = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".silentdragonlite/silentdragonlite-wallet.datBackup");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
@@ -289,10 +288,10 @@ void MainWindow::closeEvent(QCloseEvent* event) {
|
||||
|
||||
s.sync();
|
||||
|
||||
|
||||
|
||||
// Let the RPC know to shut down any running service.
|
||||
rpc->shutdownhushd();
|
||||
int passphraselenght = this->getPassword().length();
|
||||
int passphraselenght = DataStore::getChatDataStore()->getPassword().length();
|
||||
|
||||
// Check is encryption is ON for SDl
|
||||
if(passphraselenght > 0)
|
||||
@@ -305,7 +304,7 @@ void MainWindow::closeEvent(QCloseEvent* event) {
|
||||
fileoldencryption.remove();
|
||||
|
||||
// Encrypt our wallet.dat
|
||||
QString str = this->getPassword();
|
||||
QString str = DataStore::getChatDataStore()->getPassword();
|
||||
// QString str = ed.txtPassword->text(); // data comes from user inputs
|
||||
int length = str.length();
|
||||
|
||||
@@ -401,7 +400,7 @@ void MainWindow::encryptWallet() {
|
||||
|
||||
QString passphrase = ed.txtPassword->text(); // data comes from user inputs
|
||||
int length = passphrase.length();
|
||||
this->setPassword(passphrase);
|
||||
DataStore::getChatDataStore()->setPassword(passphrase);
|
||||
|
||||
char *sequence = NULL;
|
||||
sequence = new char[length+1];
|
||||
@@ -561,7 +560,7 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
||||
{
|
||||
QString password = ed.txtPassword->text(); // data comes from user inputs
|
||||
int length = password.length();
|
||||
this->setPassword(password);
|
||||
DataStore::getChatDataStore()->setPassword(password);
|
||||
char *sequence = NULL;
|
||||
sequence = new char[length+1];
|
||||
strncpy(sequence, password.toLocal8Bit(), length +1);
|
||||
@@ -663,6 +662,7 @@ void MainWindow::setupStatusBar() {
|
||||
loadingMovie->start();
|
||||
loadingLabel->setAttribute(Qt::WA_NoSystemBackground);
|
||||
loadingLabel->setMovie(loadingMovie);
|
||||
|
||||
|
||||
ui->statusBar->addPermanentWidget(loadingLabel);
|
||||
loadingLabel->setVisible(false);
|
||||
@@ -1159,7 +1159,6 @@ void MainWindow::setupBalancesTab() {
|
||||
ui->lblSyncWarning->setVisible(false);
|
||||
ui->lblSyncWarningReceive->setVisible(false);
|
||||
|
||||
|
||||
// Setup context menu on balances tab
|
||||
ui->balancesTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
QObject::connect(ui->balancesTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) {
|
||||
@@ -1191,6 +1190,8 @@ void MainWindow::setupBalancesTab() {
|
||||
|
||||
menu.exec(ui->balancesTable->viewport()->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
qDebug()<<"PW :"<<DataStore::getChatDataStore()->getPassword();
|
||||
}
|
||||
|
||||
void MainWindow::setuphushdTab() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "logger.h"
|
||||
#include "recurring.h"
|
||||
|
||||
#include "firsttimewizard.h"
|
||||
|
||||
// Forward declare to break circular dependency.
|
||||
class Controller;
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
void addPubkey(QString requestZaddr, QString pubkey);
|
||||
|
||||
|
||||
|
||||
|
||||
void replaceWormholeClient(WormholeClient* newClient);
|
||||
bool isWebsocketListening();
|
||||
@@ -67,10 +68,7 @@ public:
|
||||
void saveContact();
|
||||
void saveandsendContact();
|
||||
void showRequesthush();
|
||||
// void setmaxlenChat(int len);
|
||||
// void updateDisplay();
|
||||
|
||||
|
||||
|
||||
void balancesReady();
|
||||
void payhushURI(QString uri = "", QString myAddr = "");
|
||||
|
||||
@@ -113,6 +111,7 @@ private:
|
||||
bool fileExists(QString path);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
void closeEventpw(QCloseEvent* event);
|
||||
QString _password;
|
||||
|
||||
|
||||
void setupSendTab();
|
||||
@@ -122,7 +121,6 @@ private:
|
||||
void setuphushdTab();
|
||||
void setupchatTab();
|
||||
void renderContactRequest();
|
||||
// void setLenDisplayLabel(QLabel* label);
|
||||
|
||||
void updateContacts();
|
||||
void updateChat();
|
||||
@@ -131,7 +129,7 @@ private:
|
||||
void setupStatusBar();
|
||||
|
||||
void clearSendForm();
|
||||
QString _password;
|
||||
|
||||
|
||||
Tx createTxFromSendPage();
|
||||
bool confirmTx(Tx tx, RecurringPaymentInfo* rpi);
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>427</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>This is your new wallet's seed phrase. PLEASE BACK IT UP SECURELY.</string>
|
||||
@@ -24,17 +24,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
@@ -56,6 +46,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
125
src/newwallet.ui
125
src/newwallet.ui
@@ -6,47 +6,15 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>437</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioRestoreWallet">
|
||||
<property name="text">
|
||||
<string>Restore wallet from seed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Restore an existing wallet, using the 24-word seed. </string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
@@ -78,6 +46,93 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblPasswordMatch">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Passphrase don't match</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>16 letters minimum</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Encryption Passphrase:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="txtPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Confirm Passphrase:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="txtConfirmPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioRestoreWallet">
|
||||
<property name="text">
|
||||
<string>Restore wallet from seed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Restore an existing wallet, using the 24-word seed. </string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user