mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-10 03:42:05 +02:00
Merge pull request #1947
08ec5e9
wizard: fix restore from key and seed functionality (mmbyday)
This commit is contained in:
commit
64718235c7
22
js/Wizard.js
22
js/Wizard.js
@ -3,18 +3,18 @@
|
|||||||
function updateFromQrCode(address, payment_id, amount, tx_description, recipient_name, extra_parameters) {
|
function updateFromQrCode(address, payment_id, amount, tx_description, recipient_name, extra_parameters) {
|
||||||
// Switch to recover from keys
|
// Switch to recover from keys
|
||||||
recoverFromSeedMode = false
|
recoverFromSeedMode = false
|
||||||
spendkey.text = ""
|
spendKeyLine.text = ""
|
||||||
viewKeyLine.text = ""
|
viewKeyLine.text = ""
|
||||||
restoreHeightItem.text = ""
|
restoreHeight.text = ""
|
||||||
|
|
||||||
if(typeof extra_parameters.secret_view_key != "undefined") {
|
if(typeof extra_parameters.secret_view_key != "undefined") {
|
||||||
viewKeyLine.text = extra_parameters.secret_view_key
|
viewKeyLine.text = extra_parameters.secret_view_key
|
||||||
}
|
}
|
||||||
if(typeof extra_parameters.secret_spend_key != "undefined") {
|
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") {
|
if(typeof extra_parameters.restore_height != "undefined") {
|
||||||
restoreHeightItem.text = extra_parameters.restore_height
|
restoreHeight.text = extra_parameters.restore_height
|
||||||
}
|
}
|
||||||
addressLine.text = address
|
addressLine.text = address
|
||||||
|
|
||||||
@ -170,12 +170,14 @@ function checkSeed(seed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function restoreWalletCheckViewSpendAddress(walletmanager, nettype, viewkey, spendkey, addressline){
|
function restoreWalletCheckViewSpendAddress(walletmanager, nettype, viewkey, spendkey, addressline){
|
||||||
var addressOK = (viewkey.length > 0 || spendkey.length > 0) ? walletmanager.addressValid(addressline, nettype) : false
|
var results = [];
|
||||||
var viewKeyOK = (viewkey.length > 0) ? walletmanager.keyValid(viewkey, addressline, true, nettype) : true
|
// addressOK
|
||||||
// Spendkey is optional
|
results[0] = walletmanager.addressValid(addressline, nettype);
|
||||||
var spendKeyOK = (spendkey.length > 0) ? walletmanager.keyValid(spendkey, addressline, false, nettype) : true
|
// viewKeyOK
|
||||||
|
results[1] = walletmanager.keyValid(viewkey, addressline, true, nettype);
|
||||||
return addressOK && viewKeyOK && spendKeyOK
|
// spendKeyOK, Spendkey is optional
|
||||||
|
results[2] = walletmanager.keyValid(spendkey, addressline, false, nettype);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
//usage: getApproximateBlockchainHeight("March 18 2016") or getApproximateBlockchainHeight("2016-11-11")
|
//usage: getApproximateBlockchainHeight("March 18 2016") or getApproximateBlockchainHeight("2016-11-11")
|
||||||
|
@ -76,6 +76,9 @@ Rectangle {
|
|||||||
property string walletOptionsLocation: ''
|
property string walletOptionsLocation: ''
|
||||||
property string walletOptionsPassword: ''
|
property string walletOptionsPassword: ''
|
||||||
property string walletOptionsSeed: ''
|
property string walletOptionsSeed: ''
|
||||||
|
property string walletOptionsRecoverAddress: ''
|
||||||
|
property string walletOptionsRecoverViewkey: ''
|
||||||
|
property string walletOptionsRecoverSpendkey: ''
|
||||||
property string walletOptionsBackup: ''
|
property string walletOptionsBackup: ''
|
||||||
property int walletOptionsRestoreHeight: 0
|
property int walletOptionsRestoreHeight: 0
|
||||||
property string walletOptionsBootstrapAddress: persistentSettings.bootstrapNodeAddress
|
property string walletOptionsBootstrapAddress: persistentSettings.bootstrapNodeAddress
|
||||||
@ -307,7 +310,7 @@ Rectangle {
|
|||||||
oshelper.removeTemporaryWallet(wizardController.tmpWalletFilename)
|
oshelper.removeTemporaryWallet(wizardController.tmpWalletFilename)
|
||||||
|
|
||||||
// protecting wallet with password
|
// 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)
|
// Store password in session to be able to use password protected functions (e.g show seed)
|
||||||
appWindow.walletPassword = walletOptionsPassword
|
appWindow.walletPassword = walletOptionsPassword
|
||||||
@ -325,6 +328,40 @@ Rectangle {
|
|||||||
persistentSettings.is_recovering_from_device = (wizardController.walletOptionsIsRecoveringFromDevice === undefined) ? false : wizardController.walletOptionsIsRecoveringFromDevice
|
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() {
|
function createWalletFromDevice() {
|
||||||
// TODO: create wallet in temporary filename and a) move it to the path specified by user after the final
|
// 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
|
// page submitted or b) delete it when program closed before reaching final page
|
||||||
|
@ -128,7 +128,6 @@ Rectangle {
|
|||||||
|
|
||||||
onMenuClicked: {
|
onMenuClicked: {
|
||||||
wizardController.restart();
|
wizardController.restart();
|
||||||
wizardController.createWallet();
|
|
||||||
wizardStateView.state = "wizardRestoreWallet1"
|
wizardStateView.state = "wizardRestoreWallet1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,7 @@ Rectangle {
|
|||||||
viewKeyLine.error = !result[1] && viewKeyLineLength != 0
|
viewKeyLine.error = !result[1] && viewKeyLineLength != 0
|
||||||
spendKeyLine.error = !result[2] && spendKeyLineLength != 0
|
spendKeyLine.error = !result[2] && spendKeyLineLength != 0
|
||||||
|
|
||||||
return (!addressLine.error && !viewKeyLine.error && !spendKeyLine.error &&
|
return (result[0] && result[1] && result[2])
|
||||||
addressLineLength != 0 && viewKeyLineLength != 0 && spendKeyLineLength != 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkRestoreHeight() {
|
function checkRestoreHeight() {
|
||||||
@ -273,7 +272,17 @@ Rectangle {
|
|||||||
onNextClicked: {
|
onNextClicked: {
|
||||||
wizardController.walletOptionsName = wizardWalletInput.walletName.text;
|
wizardController.walletOptionsName = wizardWalletInput.walletName.text;
|
||||||
wizardController.walletOptionsLocation = wizardWalletInput.walletLocation.text;
|
wizardController.walletOptionsLocation = wizardWalletInput.walletLocation.text;
|
||||||
|
|
||||||
|
switch (wizardController.walletRestoreMode) {
|
||||||
|
case 'seed':
|
||||||
wizardController.walletOptionsSeed = seedInput.text;
|
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;
|
var _restoreHeight = 0;
|
||||||
if(restoreHeight.text){
|
if(restoreHeight.text){
|
||||||
@ -299,6 +308,7 @@ Rectangle {
|
|||||||
seedInput.text = "";
|
seedInput.text = "";
|
||||||
addressLine.text = "";
|
addressLine.text = "";
|
||||||
spendKeyLine.text = "";
|
spendKeyLine.text = "";
|
||||||
|
viewKeyLine.text = "";
|
||||||
restoreHeight.text = "";
|
restoreHeight.text = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onNextClicked: {
|
onNextClicked: {
|
||||||
|
wizardController.recoveryWallet();
|
||||||
wizardController.writeWallet();
|
wizardController.writeWallet();
|
||||||
wizardController.useMoneroClicked();
|
wizardController.useMoneroClicked();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user