mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-13 03:46:33 +02:00
Merge pull request #383
ba8decc
wizard: Ensure temporary wallet files are deleted (Jaquee)
This commit is contained in:
commit
6437723772
12
oshelper.cpp
12
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();
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
|
||||
Q_INVOKABLE QString temporaryFilename() const;
|
||||
Q_INVOKABLE QString temporaryPath() const;
|
||||
Q_INVOKABLE bool removeTemporaryWallet(const QString &walletName) const;
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -168,18 +168,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);
|
||||
@ -203,7 +199,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
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user