diff options
| author | mmbyday <mmbyday@protonmail.com> | 2019-02-22 18:26:51 -0800 |
|---|---|---|
| committer | mmbyday <mmbyday@protonmail.com> | 2019-02-23 10:02:51 -0800 |
| commit | 08ec5e99ac805a1d255d13a4075874922b2b98b0 (patch) | |
| tree | 7fac09e20afe04f5b287e90c1647068ccd2a8ced /wizard/WizardController.qml | |
| parent | c2889c2b8173dda1e4fe50478c8d56ac00f2d255 (diff) | |
| download | monzero-gui-08ec5e99ac805a1d255d13a4075874922b2b98b0.tar.gz monzero-gui-08ec5e99ac805a1d255d13a4075874922b2b98b0.tar.xz monzero-gui-08ec5e99ac805a1d255d13a4075874922b2b98b0.zip | |
wizard: fix restore from key and seed functionality
Diffstat (limited to 'wizard/WizardController.qml')
| -rw-r--r-- | wizard/WizardController.qml | 39 |
1 files changed, 38 insertions, 1 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 |
