diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2019-02-24 10:16:36 -0600 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2019-02-24 10:16:36 -0600 |
| commit | 64718235c7201bda4438d5f80ad840e059c5fb62 (patch) | |
| tree | 7fac09e20afe04f5b287e90c1647068ccd2a8ced /wizard | |
| parent | c2889c2b8173dda1e4fe50478c8d56ac00f2d255 (diff) | |
| parent | 08ec5e99ac805a1d255d13a4075874922b2b98b0 (diff) | |
| download | monzero-gui-64718235c7201bda4438d5f80ad840e059c5fb62.tar.gz monzero-gui-64718235c7201bda4438d5f80ad840e059c5fb62.tar.xz monzero-gui-64718235c7201bda4438d5f80ad840e059c5fb62.zip | |
Merge pull request #1947
08ec5e9 wizard: fix restore from key and seed functionality (mmbyday)
Diffstat (limited to 'wizard')
| -rw-r--r-- | wizard/WizardController.qml | 39 | ||||
| -rw-r--r-- | wizard/WizardHome.qml | 1 | ||||
| -rw-r--r-- | wizard/WizardRestoreWallet1.qml | 16 | ||||
| -rw-r--r-- | wizard/WizardRestoreWallet4.qml | 1 |
4 files changed, 52 insertions, 5 deletions
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(); } |
