aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaquee <jaquee.monero@gmail.com>2017-01-03 21:44:55 +0100
committerJaquee <jaquee.monero@gmail.com>2017-01-03 22:45:41 +0100
commitba8decca3f06deada9f949542563f85a9b1ef658 (patch)
treec04d52571257e583720a456e504ba923bbc8ea5d
parentd8f9e7360fdbab910283c465aafe36149b1d7f26 (diff)
downloadmonzero-gui-ba8decca3f06deada9f949542563f85a9b1ef658.tar.gz
monzero-gui-ba8decca3f06deada9f949542563f85a9b1ef658.tar.xz
monzero-gui-ba8decca3f06deada9f949542563f85a9b1ef658.zip
wizard: Ensure temporary wallet files are deleted
-rw-r--r--oshelper.cpp12
-rw-r--r--oshelper.h1
-rw-r--r--wizard/WizardCreateWallet.qml8
-rw-r--r--wizard/WizardMain.qml17
-rw-r--r--wizard/WizardRecoveryWallet.qml5
5 files changed, 27 insertions, 16 deletions
diff --git a/oshelper.cpp b/oshelper.cpp
index cecae38e..ecb85ec1 100644
--- a/oshelper.cpp
+++ b/oshelper.cpp
@@ -1,6 +1,8 @@
#include "oshelper.h"
#include <QTemporaryFile>
#include <QDir>
+#include <QDebug>
+#include <QString>
OSHelper::OSHelper(QObject *parent) : QObject(parent)
{
@@ -18,6 +20,16 @@ QString OSHelper::temporaryFilename() const
return tempFileName;
}
+bool OSHelper::removeTemporaryWallet(const QString &fileName) const
+{
+ // Temporary files should be deleted automatically by default, in case they wouldn't, we delete them manually as well
+ bool cache_deleted = QFile::remove(fileName);
+ bool address_deleted = QFile::remove(fileName + ".address.txt");
+ bool keys_deleted = QFile::remove(fileName +".keys");
+
+ return cache_deleted && address_deleted && keys_deleted;
+}
+
QString OSHelper::temporaryPath() const
{
return QDir::tempPath();
diff --git a/oshelper.h b/oshelper.h
index 809058cb..7a128136 100644
--- a/oshelper.h
+++ b/oshelper.h
@@ -13,6 +13,7 @@ public:
Q_INVOKABLE QString temporaryFilename() const;
Q_INVOKABLE QString temporaryPath() const;
+ Q_INVOKABLE bool removeTemporaryWallet(const QString &walletName) const;
signals:
diff --git a/wizard/WizardCreateWallet.qml b/wizard/WizardCreateWallet.qml
index 26169307..110eeb87 100644
--- a/wizard/WizardCreateWallet.qml
+++ b/wizard/WizardCreateWallet.qml
@@ -82,16 +82,16 @@ Item {
console.log("deleting wallet")
}
- var wallet_filename = oshelper.temporaryFilename();
- //var wallet = walletManager.createWallet(wallet_filename, "", settingsObject.language)
+ var tmp_wallet_filename = oshelper.temporaryFilename();
+ console.log("Creating temporary wallet", tmp_wallet_filename)
var testnet = appWindow.persistentSettings.testnet;
- var wallet = walletManager.createWallet(wallet_filename, "", settingsObject.wallet_language,
+ var wallet = walletManager.createWallet(tmp_wallet_filename, "", settingsObject.wallet_language,
testnet)
uiItem.wordsTextItem.memoText = wallet.seed
// saving wallet in "global" settings object
// TODO: wallet should have a property pointing to the file where it stored or loaded from
settingsObject.wallet = wallet
- settingsObject.wallet_filename = wallet_filename
+ settingsObject.tmp_wallet_filename = tmp_wallet_filename
}
WizardManageWalletUI {
diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml
index dc84a4a4..39232526 100644
--- a/wizard/WizardMain.qml
+++ b/wizard/WizardMain.qml
@@ -174,18 +174,14 @@ Rectangle {
//! actually writes the wallet
function applySettings() {
- console.log("Here we apply the settings");
- // here we need to actually move wallet to the new location
- console.log(settings.wallet_full_path);
-
+ // Save wallet files in user specified location
var new_wallet_filename = createWalletPath(settings.wallet_path,settings.account_name)
-
console.log("saving in wizard: "+ new_wallet_filename)
- // moving wallet files to the new destination, if user changed it
- if (new_wallet_filename !== settings.wallet_filename) {
- // using previously saved wallet;
- settings.wallet.store(new_wallet_filename);
- }
+ settings.wallet.store(new_wallet_filename);
+
+ // make sure temporary wallet files are deleted
+ console.log("Removing temporary wallet: "+ settings.tmp_wallet_filename)
+ oshelper.removeTemporaryWallet(settings.tmp_wallet_filename)
// protecting wallet with password
settings.wallet.setPassword(settings.wallet_password);
@@ -209,7 +205,6 @@ Rectangle {
appWindow.persistentSettings.restore_height = (isNaN(settings.restore_height))? 0 : settings.restore_height
appWindow.persistentSettings.is_recovering = (settings.is_recovering === undefined)? false : settings.is_recovering
-
}
// reading settings from persistent storage
diff --git a/wizard/WizardRecoveryWallet.qml b/wizard/WizardRecoveryWallet.qml
index 71e022c2..185a0cf1 100644
--- a/wizard/WizardRecoveryWallet.qml
+++ b/wizard/WizardRecoveryWallet.qml
@@ -73,11 +73,14 @@ Item {
function recoveryWallet(settingsObject) {
var testnet = appWindow.persistentSettings.testnet;
var restoreHeight = settingsObject.restore_height;
- var wallet = walletManager.recoveryWallet(oshelper.temporaryFilename(), settingsObject.words, testnet, restoreHeight);
+ var tmp_wallet_filename = oshelper.temporaryFilename()
+ console.log("Creating temporary wallet", tmp_wallet_filename)
+ var wallet = walletManager.recoveryWallet(tmp_wallet_filename, settingsObject.words, testnet, restoreHeight);
var success = wallet.status === Wallet.Status_Ok;
if (success) {
settingsObject['wallet'] = wallet;
settingsObject['is_recovering'] = true;
+ settingsObject['tmp_wallet_filename'] = tmp_wallet_filename
} else {
walletManager.closeWallet();
}