aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/Wizard.js24
-rw-r--r--wizard/WizardController.qml39
-rw-r--r--wizard/WizardHome.qml1
-rw-r--r--wizard/WizardRestoreWallet1.qml16
-rw-r--r--wizard/WizardRestoreWallet4.qml1
5 files changed, 65 insertions, 16 deletions
diff --git a/js/Wizard.js b/js/Wizard.js
index 6f0633c7..220fd0a2 100644
--- a/js/Wizard.js
+++ b/js/Wizard.js
@@ -3,18 +3,18 @@
function updateFromQrCode(address, payment_id, amount, tx_description, recipient_name, extra_parameters) {
// Switch to recover from keys
recoverFromSeedMode = false
- spendkey.text = ""
+ spendKeyLine.text = ""
viewKeyLine.text = ""
- restoreHeightItem.text = ""
+ restoreHeight.text = ""
if(typeof extra_parameters.secret_view_key != "undefined") {
viewKeyLine.text = extra_parameters.secret_view_key
}
if(typeof extra_parameters.secret_spend_key != "undefined") {
- spendkey.text = extra_parameters.secret_spend_key
+ spendKeyLine.text = extra_parameters.secret_spend_key
}
if(typeof extra_parameters.restore_height != "undefined") {
- restoreHeightItem.text = extra_parameters.restore_height
+ restoreHeight.text = extra_parameters.restore_height
}
addressLine.text = address
@@ -170,12 +170,14 @@ function checkSeed(seed) {
}
function restoreWalletCheckViewSpendAddress(walletmanager, nettype, viewkey, spendkey, addressline){
- var addressOK = (viewkey.length > 0 || spendkey.length > 0) ? walletmanager.addressValid(addressline, nettype) : false
- var viewKeyOK = (viewkey.length > 0) ? walletmanager.keyValid(viewkey, addressline, true, nettype) : true
- // Spendkey is optional
- var spendKeyOK = (spendkey.length > 0) ? walletmanager.keyValid(spendkey, addressline, false, nettype) : true
-
- return addressOK && viewKeyOK && spendKeyOK
+ var results = [];
+ // addressOK
+ results[0] = walletmanager.addressValid(addressline, nettype);
+ // viewKeyOK
+ results[1] = walletmanager.keyValid(viewkey, addressline, true, nettype);
+ // spendKeyOK, Spendkey is optional
+ results[2] = walletmanager.keyValid(spendkey, addressline, false, nettype);
+ return results;
}
//usage: getApproximateBlockchainHeight("March 18 2016") or getApproximateBlockchainHeight("2016-11-11")
@@ -219,4 +221,4 @@ function getApproximateBlockchainHeight(_date){
else{
return 0;
}
-} \ No newline at end of file
+}
diff --git a/wizard/WizardController.qml b/wizard/WizardController.qml
index 75e30389..87d96f70 100644
--- a/wizard/WizardController.qml
+++ b/wizard/WizardController.qml
@@ -76,6 +76,9 @@ Rectangle {
property string walletOptionsLocation: ''
property string walletOptionsPassword: ''
property string walletOptionsSeed: ''
+ property string walletOptionsRecoverAddress: ''
+ property string walletOptionsRecoverViewkey: ''
+ property string walletOptionsRecoverSpendkey: ''
property string walletOptionsBackup: ''
property int walletOptionsRestoreHeight: 0
property string walletOptionsBootstrapAddress: persistentSettings.bootstrapNodeAddress
@@ -307,7 +310,7 @@ Rectangle {
oshelper.removeTemporaryWallet(wizardController.tmpWalletFilename)
// protecting wallet with password
- m_wallet.setPassword(walletOptionsPassword);
+ wizardController.m_wallet.setPassword(walletOptionsPassword);
// Store password in session to be able to use password protected functions (e.g show seed)
appWindow.walletPassword = walletOptionsPassword
@@ -325,6 +328,40 @@ Rectangle {
persistentSettings.is_recovering_from_device = (wizardController.walletOptionsIsRecoveringFromDevice === undefined) ? false : wizardController.walletOptionsIsRecoveringFromDevice
}
+ function recoveryWallet() {
+ var nettype = persistentSettings.nettype;
+ var kdfRounds = persistentSettings.kdfRounds;
+ var restoreHeight = wizardController.walletOptionsRestoreHeight;
+ var tmp_wallet_filename = oshelper.temporaryFilename()
+ console.log("Creating temporary wallet", tmp_wallet_filename)
+
+ // delete the temporary wallet object before creating new
+ if (typeof wizardController.m_wallet !== 'undefined') {
+ walletManager.closeWallet()
+ console.log("deleting temporary wallet")
+ }
+ var wallet = ''
+ // From seed or keys
+ if(wizardController.walletRestoreMode === 'seed')
+ wallet = walletManager.recoveryWallet(tmp_wallet_filename, wizardController.walletOptionsSeed, nettype, restoreHeight, kdfRounds)
+ else
+ wallet = walletManager.createWalletFromKeys(tmp_wallet_filename, wizardController.language_wallet, nettype,
+ wizardController.walletOptionsRecoverAddress, wizardController.walletOptionsRecoverViewkey,
+ wizardController.walletOptionsRecoverSpendkey, restoreHeight, kdfRounds)
+
+ var success = wallet.status === Wallet.Status_Ok;
+ if (success) {
+ wizardController.m_wallet = wallet;
+ wizardController.walletOptionsIsRecovering = true;
+ wizardController.tmpWalletFilename = tmp_wallet_filename
+ } else {
+ console.log(wallet.errorString)
+ appWindow.showStatusMessage(qsTr(wallet.errorString), 5);
+ walletManager.closeWallet();
+ }
+ return success;
+ }
+
function createWalletFromDevice() {
// TODO: create wallet in temporary filename and a) move it to the path specified by user after the final
// page submitted or b) delete it when program closed before reaching final page
diff --git a/wizard/WizardHome.qml b/wizard/WizardHome.qml
index 71b67ee2..10f07dd0 100644
--- a/wizard/WizardHome.qml
+++ b/wizard/WizardHome.qml
@@ -128,7 +128,6 @@ Rectangle {
onMenuClicked: {
wizardController.restart();
- wizardController.createWallet();
wizardStateView.state = "wizardRestoreWallet1"
}
}
diff --git a/wizard/WizardRestoreWallet1.qml b/wizard/WizardRestoreWallet1.qml
index 8b426969..cff87b4d 100644
--- a/wizard/WizardRestoreWallet1.qml
+++ b/wizard/WizardRestoreWallet1.qml
@@ -75,8 +75,7 @@ Rectangle {
viewKeyLine.error = !result[1] && viewKeyLineLength != 0
spendKeyLine.error = !result[2] && spendKeyLineLength != 0
- return (!addressLine.error && !viewKeyLine.error && !spendKeyLine.error &&
- addressLineLength != 0 && viewKeyLineLength != 0 && spendKeyLineLength != 0)
+ return (result[0] && result[1] && result[2])
}
function checkRestoreHeight() {
@@ -273,7 +272,17 @@ Rectangle {
onNextClicked: {
wizardController.walletOptionsName = wizardWalletInput.walletName.text;
wizardController.walletOptionsLocation = wizardWalletInput.walletLocation.text;
- wizardController.walletOptionsSeed = seedInput.text;
+
+ switch (wizardController.walletRestoreMode) {
+ case 'seed':
+ wizardController.walletOptionsSeed = seedInput.text;
+ break;
+ default: // walletRestoreMode = keys or qr
+ wizardController.walletOptionsRecoverAddress = addressLine.text;
+ wizardController.walletOptionsRecoverViewkey = viewKeyLine.text
+ wizardController.walletOptionsRecoverSpendkey = spendKeyLine.text;
+ break;
+ }
var _restoreHeight = 0;
if(restoreHeight.text){
@@ -299,6 +308,7 @@ Rectangle {
seedInput.text = "";
addressLine.text = "";
spendKeyLine.text = "";
+ viewKeyLine.text = "";
restoreHeight.text = "";
}
}
diff --git a/wizard/WizardRestoreWallet4.qml b/wizard/WizardRestoreWallet4.qml
index a0f8ce8f..d141bf04 100644
--- a/wizard/WizardRestoreWallet4.qml
+++ b/wizard/WizardRestoreWallet4.qml
@@ -75,6 +75,7 @@ Rectangle {
}
}
onNextClicked: {
+ wizardController.recoveryWallet();
wizardController.writeWallet();
wizardController.useMoneroClicked();
}