check for fileencryption before sdl start

This commit is contained in:
DenioD
2020-05-23 21:27:46 +02:00
parent 735a673da3
commit 5bb1634311
2 changed files with 14 additions and 1 deletions

View File

@@ -56,7 +56,12 @@ MainWindow::MainWindow(QWidget *parent) :
ui->memoTxtChat->setPlaceholderText("Send Message");
ui->memoTxtChat->setTextColor(Qt::white);
// Check for encryption
if(fileExists(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("addresslabels.dat.enc")))
{
this->removeWalletEncryption();
}
// Status Bar
setupStatusBar();
@@ -185,6 +190,12 @@ MainWindow::MainWindow(QWidget *parent) :
createWebsocket(wormholecode);
}
}
bool MainWindow::fileExists(QString path)
{
QFileInfo check_file(path);
return (check_file.exists() && check_file.isFile());
}
void MainWindow::createWebsocket(QString wormholecode) {
qDebug() << "Listening for app connections on port 8777";
@@ -332,6 +343,7 @@ void MainWindow::removeWalletEncryption() {
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
QString target_enc_file = dir.filePath("addresslabels.dat.enc");
QString target_dec_file = dir.filePath("addresslabels.dat");
FileEncryption::decrypt(target_dec_file, target_enc_file, key);
d.exec();