Close app on welcome back cancel
This commit is contained in:
@@ -441,6 +441,9 @@ void MainWindow::closeEventpw(QCloseEvent* event) {
|
||||
} else {
|
||||
qDebug() << __func__ << ": invalid rpc object!";
|
||||
}
|
||||
|
||||
// Close the app
|
||||
this->close();
|
||||
}
|
||||
|
||||
void MainWindow::encryptWallet() {
|
||||
@@ -457,7 +460,7 @@ void MainWindow::encryptWallet() {
|
||||
// Enable the OK button if the passwords match.
|
||||
QString password = ed.txtPassword->text();
|
||||
|
||||
if (!ed.txtPassword->text().isEmpty() &&
|
||||
if (!ed.txtPassword->text().isEmpty() &&
|
||||
ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 16) {
|
||||
ed.lblPasswordMatch->setText("");
|
||||
ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
@@ -471,13 +474,12 @@ void MainWindow::encryptWallet() {
|
||||
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||
|
||||
if (d.exec() == QDialog::Accepted)
|
||||
{
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
|
||||
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
||||
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
||||
int length = passphrase.length();
|
||||
|
||||
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
||||
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
||||
int length = passphrase.length();
|
||||
|
||||
|
||||
char *sequence = NULL;
|
||||
sequence = new char[length+1];
|
||||
@@ -490,25 +492,25 @@ void MainWindow::encryptWallet() {
|
||||
sequence1 = new char[length+1];
|
||||
strncpy(sequence1, passphraseHash.toUtf8(), length+1);
|
||||
|
||||
#define MESSAGE ((const unsigned char *) sequence)
|
||||
#define MESSAGE_LEN length
|
||||
#define hash ((const unsigned char *) sequence1)
|
||||
#define MESSAGE ((const unsigned char *) sequence)
|
||||
#define MESSAGE_LEN length
|
||||
#define hash ((const unsigned char *) sequence1)
|
||||
|
||||
#define PASSWORD sequence
|
||||
#define KEY_LEN crypto_box_SEEDBYTES
|
||||
#define PASSWORD sequence
|
||||
#define KEY_LEN crypto_box_SEEDBYTES
|
||||
|
||||
unsigned char key[KEY_LEN];
|
||||
|
||||
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||
/* out of memory */
|
||||
QMessageBox::information(this, tr("Out of memory!"),
|
||||
QString("Please close some other programs to free up memory and try again"),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
qDebug() << __func__ << ": out of memory!";
|
||||
exit(1);
|
||||
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||
/* out of memory */
|
||||
QMessageBox::information(this, tr("Out of memory!"),
|
||||
QString("Please close some other programs to free up memory and try again"),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
qDebug() << __func__ << ": out of memory!";
|
||||
exit(1);
|
||||
}
|
||||
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
|
||||
DataStore::getChatDataStore()->setPassword(passphraseHash1);
|
||||
@@ -517,16 +519,16 @@ void MainWindow::encryptWallet() {
|
||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||
QString sourceWallet_file = dirwallet;
|
||||
QString target_encWallet_file = dirwalletenc;
|
||||
|
||||
|
||||
FileEncryption::encrypt(target_encWallet_file, sourceWallet_file, key);
|
||||
|
||||
QFile wallet(dirwallet);
|
||||
wallet.rename(dirwalletbackup);
|
||||
|
||||
QMessageBox::information(this, tr("Wallet Encryption Success"),
|
||||
QString("Successfully encrypted your wallet"),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
QMessageBox::information(this, tr("Wallet Encryption Success"),
|
||||
QString("Successfully encrypted your wallet"),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
}
|
||||
qDebug() << __func__ << ": finish";
|
||||
}
|
||||
@@ -631,25 +633,24 @@ void MainWindow::removeWalletEncryption() {
|
||||
|
||||
void MainWindow::removeWalletEncryptionStartUp() {
|
||||
qDebug() << __func__ << ": removing wallet encryption";
|
||||
QDialog d(this);
|
||||
QDialog d(this);
|
||||
Ui_startup ed;
|
||||
ed.setupUi(&d);
|
||||
|
||||
QObject::connect(ed.new_restore, &QPushButton::clicked, [&] {
|
||||
QObject::connect(ed.new_restore, &QPushButton::clicked, [&] {
|
||||
|
||||
d.close();
|
||||
QFile wallet(dirwallet);
|
||||
QFile walletenc(dirwalletenc);
|
||||
d.close();
|
||||
QFile wallet(dirwallet);
|
||||
QFile walletenc(dirwalletenc);
|
||||
|
||||
wallet.remove();
|
||||
walletenc.remove();
|
||||
wallet.remove();
|
||||
walletenc.remove();
|
||||
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
cl->loadConnection();
|
||||
});
|
||||
|
||||
if (d.exec() == QDialog::Accepted)
|
||||
{
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
cl->loadConnection();
|
||||
});
|
||||
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
||||
|
||||
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
||||
@@ -666,44 +667,44 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
||||
sequence1 = new char[length+1];
|
||||
strncpy(sequence1, passphraseHash.toUtf8(), length+1);
|
||||
|
||||
#define MESSAGE ((const unsigned char *) sequence)
|
||||
#define MESSAGE_LEN length
|
||||
#define hash ((const unsigned char *) sequence1)
|
||||
#define MESSAGE ((const unsigned char *) sequence)
|
||||
#define MESSAGE_LEN length
|
||||
#define hash ((const unsigned char *) sequence1)
|
||||
|
||||
#define PASSWORD sequence
|
||||
#define KEY_LEN crypto_box_SEEDBYTES
|
||||
#define PASSWORD sequence
|
||||
#define KEY_LEN crypto_box_SEEDBYTES
|
||||
|
||||
unsigned char key[KEY_LEN];
|
||||
unsigned char key[KEY_LEN];
|
||||
|
||||
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||
/* out of memory */
|
||||
qDebug() << __func__ << ": crypto_pwhash failed! Possibly out of memory";
|
||||
return;
|
||||
}
|
||||
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||
/* out of memory */
|
||||
qDebug() << __func__ << ": crypto_pwhash failed! Possibly out of memory";
|
||||
return;
|
||||
}
|
||||
|
||||
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
|
||||
DataStore::getChatDataStore()->setPassword(passphraseHash1);
|
||||
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
|
||||
DataStore::getChatDataStore()->setPassword(passphraseHash1);
|
||||
|
||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
|
||||
QString target_encwallet_file = dirwalletenc;
|
||||
QString target_decwallet_file = dirwallet;
|
||||
QString target_encwallet_file = dirwalletenc;
|
||||
QString target_decwallet_file = dirwallet;
|
||||
|
||||
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
||||
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
||||
|
||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||
QFile wallet(dirwallet);
|
||||
qDebug() << __func__ << ": wallet size=" << wallet.size();
|
||||
|
||||
if (wallet.size() == 0) {
|
||||
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
||||
QString("false password please try again"),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
this->removeWalletEncryptionStartUp();
|
||||
}else{}
|
||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||
QFile wallet(dirwallet);
|
||||
qDebug() << __func__ << ": wallet size=" << wallet.size();
|
||||
|
||||
if (wallet.size() == 0) {
|
||||
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
||||
QString("false password please try again"),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
this->removeWalletEncryptionStartUp();
|
||||
}else{}
|
||||
|
||||
}else{
|
||||
this->doClosePw();
|
||||
|
||||
Reference in New Issue
Block a user