prevent to open sdl without pw
This commit is contained in:
@@ -252,6 +252,10 @@ void MainWindow::doClose() {
|
|||||||
closeEvent(nullptr);
|
closeEvent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::doClosePw() {
|
||||||
|
closeEventpw(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event) {
|
void MainWindow::closeEvent(QCloseEvent* event) {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
@@ -261,8 +265,7 @@ void MainWindow::closeEvent(QCloseEvent* event) {
|
|||||||
|
|
||||||
s.sync();
|
s.sync();
|
||||||
|
|
||||||
// Let the RPC know to shut down any running service.
|
|
||||||
rpc->shutdownhushd();
|
|
||||||
|
|
||||||
|
|
||||||
// Check is encryption is ON for SDl
|
// Check is encryption is ON for SDl
|
||||||
@@ -319,26 +322,29 @@ void MainWindow::closeEvent(QCloseEvent* event) {
|
|||||||
|
|
||||||
///////////////// we rename the plaintext wallet.dat to Backup, for testing.
|
///////////////// we rename the plaintext wallet.dat to Backup, for testing.
|
||||||
|
|
||||||
QFile fileoldbackup(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP"));
|
|
||||||
fileoldbackup.remove();
|
|
||||||
QFile file(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"));
|
QFile file(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"));
|
||||||
file.rename(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP"));
|
file.rename(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Let the RPC know to shut down any running service.
|
||||||
|
rpc->shutdownhushd();
|
||||||
|
|
||||||
// Bubble up
|
// Bubble up
|
||||||
if (event)
|
if (event)
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_hex_buff(unsigned char buf[], unsigned int len)
|
void MainWindow::closeEventpw(QCloseEvent* event) {
|
||||||
{
|
|
||||||
int i;
|
// Let the RPC know to shut down any running service.
|
||||||
for (i=0; i<len; i++) printf("%02X ", buf[i]);
|
rpc->shutdownhushd();
|
||||||
printf("\n");
|
|
||||||
|
// Bubble up
|
||||||
|
if (event)
|
||||||
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::encryptWallet() {
|
void MainWindow::encryptWallet() {
|
||||||
|
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
@@ -351,7 +357,7 @@ void MainWindow::encryptWallet() {
|
|||||||
auto fnPasswordEdited = [=](const QString&) {
|
auto fnPasswordEdited = [=](const QString&) {
|
||||||
// Enable the OK button if the passwords match.
|
// Enable the OK button if the passwords match.
|
||||||
QString password = ed.txtPassword->text();
|
QString password = ed.txtPassword->text();
|
||||||
this->setPassword(password);
|
|
||||||
if (!ed.txtPassword->text().isEmpty() &&
|
if (!ed.txtPassword->text().isEmpty() &&
|
||||||
ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 16) {
|
ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 16) {
|
||||||
ed.lblPasswordMatch->setText("");
|
ed.lblPasswordMatch->setText("");
|
||||||
@@ -371,6 +377,7 @@ void MainWindow::encryptWallet() {
|
|||||||
|
|
||||||
QString str = ed.txtPassword->text(); // data comes from user inputs
|
QString str = ed.txtPassword->text(); // data comes from user inputs
|
||||||
int length = str.length();
|
int length = str.length();
|
||||||
|
this->setPassword(str);
|
||||||
|
|
||||||
char *sequence = NULL;
|
char *sequence = NULL;
|
||||||
sequence = new char[length+1];
|
sequence = new char[length+1];
|
||||||
@@ -399,8 +406,6 @@ void MainWindow::encryptWallet() {
|
|||||||
/* out of memory */
|
/* out of memory */
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug()<<"Generating cryptographic key from password: " <<sequence;
|
|
||||||
|
|
||||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||||
QString source_file = dir.filePath("addresslabels.dat");
|
QString source_file = dir.filePath("addresslabels.dat");
|
||||||
@@ -419,10 +424,11 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
ed.setupUi(&d);
|
ed.setupUi(&d);
|
||||||
|
|
||||||
// Handle edits on the password box
|
// Handle edits on the password box
|
||||||
|
QString password = ed.txtPassword->text();
|
||||||
auto fnPasswordEdited = [=](const QString&) {
|
auto fnPasswordEdited = [=](const QString&) {
|
||||||
// Enable the OK button if the passwords match.
|
// Enable the OK button if the passwords match.
|
||||||
if (!ed.txtPassword->text().isEmpty() &&
|
if (!ed.txtPassword->text().isEmpty() &&
|
||||||
ed.txtPassword->text() == ed.txtConfirmPassword->text()) {
|
ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 16) {
|
||||||
ed.lblPasswordMatch->setText("");
|
ed.lblPasswordMatch->setText("");
|
||||||
ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -467,10 +473,8 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
/* out of memory */
|
/* out of memory */
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat"));
|
|
||||||
filencrypted.remove();
|
|
||||||
|
|
||||||
{
|
|
||||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||||
QString target_encwallet_file = dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat");
|
QString target_encwallet_file = dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat");
|
||||||
@@ -481,29 +485,35 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
||||||
FileEncryption::decrypt(target_decaddr_file, target_encaddr_file, key);
|
FileEncryption::decrypt(target_decaddr_file, target_encaddr_file, key);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
|
||||||
|
|
||||||
QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"));
|
QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"));
|
||||||
|
|
||||||
if (filencrypted.size() > 0)
|
if (filencrypted.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
QMessageBox::information(this, tr("Wallet Encryption Success"),
|
QMessageBox::information(this, tr("Wallet decryption Success"),
|
||||||
QString("SDL is ready to Rock"),
|
QString("SDL is ready to Rock"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
|
|
||||||
|
filencrypted.remove();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
qDebug()<<"verschlüsselung gescheitert ";
|
qDebug()<<"verschlüsselung gescheitert ";
|
||||||
|
|
||||||
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
||||||
QString("false password please try again"),
|
QString("false password, please try again"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
this->removeWalletEncryptionStartUp();
|
this->removeWalletEncryptionStartUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
this->doClosePw();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -514,12 +524,12 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
ed.setupUi(&d);
|
ed.setupUi(&d);
|
||||||
|
|
||||||
// Handle edits on the password box
|
// Handle edits on the password box
|
||||||
QString password = ed.txtPassword->text();
|
|
||||||
|
|
||||||
auto fnPasswordEdited = [=](const QString&) {
|
auto fnPasswordEdited = [=](const QString&) {
|
||||||
|
QString password = ed.txtPassword->text();
|
||||||
// Enable the OK button if the passwords match.
|
// Enable the OK button if the passwords match.
|
||||||
if (!ed.txtPassword->text().isEmpty() &&
|
if (!ed.txtPassword->text().isEmpty() &&
|
||||||
ed.txtPassword->text() == ed.txtConfirmPassword->text()) {
|
ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 16) {
|
||||||
ed.lblPasswordMatch->setText("");
|
ed.lblPasswordMatch->setText("");
|
||||||
ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -580,6 +590,8 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
|
|
||||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||||
QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"));
|
QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"));
|
||||||
|
QFile backup(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP"));
|
||||||
|
|
||||||
|
|
||||||
if (filencrypted.size() > 0)
|
if (filencrypted.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -588,6 +600,8 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
QString("SDL is ready to Rock"),
|
QString("SDL is ready to Rock"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
|
|
||||||
|
backup.remove();
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
qDebug()<<"verschlüsselung gescheitert ";
|
qDebug()<<"verschlüsselung gescheitert ";
|
||||||
@@ -599,6 +613,9 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
this->removeWalletEncryptionStartUp();
|
this->removeWalletEncryptionStartUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
this->doClosePw();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ public:
|
|||||||
Logger* logger;
|
Logger* logger;
|
||||||
|
|
||||||
void doClose();
|
void doClose();
|
||||||
|
void doClosePw();
|
||||||
QString createHeaderMemo(QString type, QString cid, QString zaddr, int version, int headerNumber);
|
QString createHeaderMemo(QString type, QString cid, QString zaddr, int version, int headerNumber);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -104,6 +105,7 @@ private:
|
|||||||
|
|
||||||
bool fileExists(QString path);
|
bool fileExists(QString path);
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
|
void closeEventpw(QCloseEvent* event);
|
||||||
|
|
||||||
|
|
||||||
void setupSendTab();
|
void setupSendTab();
|
||||||
|
|||||||
@@ -181,7 +181,7 @@
|
|||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>removeencryption</receiver>
|
<receiver>removeencryption</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>close()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>316</x>
|
<x>316</x>
|
||||||
|
|||||||
Reference in New Issue
Block a user