1
0

During wallet creation, do not write seed on disk before it is encrypted

This commit is contained in:
thomasv
2013-12-13 17:30:34 +01:00
parent 60b6fd399d
commit f045490597
7 changed files with 115 additions and 97 deletions

View File

@@ -247,8 +247,7 @@ class InstallWizard(QDialog):
+_("Leave these fields empty if you want to disable encryption.")
from password_dialog import make_password_dialog, run_password_dialog
self.set_layout( make_password_dialog(self, wallet, msg) )
run_password_dialog(self, wallet, self)
return run_password_dialog(self, wallet, self)
def run(self):
@@ -269,13 +268,14 @@ class InstallWizard(QDialog):
return
if not self.verify_seed(wallet):
return
ok, _, password = self.password_dialog(wallet)
def create():
wallet.save_seed()
wallet.save_seed(password)
wallet.synchronize() # generate first addresses offline
self.waiting_dialog(create)
elif action == 'restore':
# ask for seed and gap.
seed = self.seed_dialog()
if not seed:
return
@@ -287,10 +287,11 @@ class InstallWizard(QDialog):
QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK'))
return
wallet.save_seed()
ok, _, password = self.password_dialog(wallet)
wallet.save_seed(password)
elif action == 'watching':
# ask for seed and gap.
mpk = self.mpk_dialog()
if not mpk:
return
@@ -318,6 +319,4 @@ class InstallWizard(QDialog):
else:
QMessageBox.information(None, _('Information'), _("This wallet was restored offline. It may contain more addresses than displayed."), _('OK'))
self.password_dialog(wallet)
return wallet

View File

@@ -75,37 +75,24 @@ def run_password_dialog(self, wallet, parent):
if not wallet.seed:
QMessageBox.information(parent, _('Error'), _('No seed'), _('OK'))
return
return False, None, None
if not self.exec_(): return
if not self.exec_():
return False, None, None
password = unicode(self.pw.text()) if wallet.use_encryption else None
new_password = unicode(self.new_pw.text())
new_password2 = unicode(self.conf_pw.text())
try:
wallet.get_seed(password)
except Exception:
QMessageBox.warning(parent, _('Error'), _('Incorrect Password'), _('OK'))
return
if new_password != new_password2:
QMessageBox.warning(parent, _('Error'), _('Passwords do not match'), _('OK'))
# Retry
run_password_dialog(self, wallet, parent)
return
return run_password_dialog(self, wallet, parent)
try:
wallet.update_password(password, new_password)
except Exception:
QMessageBox.warning(parent, _('Error'), _('Failed to update password'), _('OK'))
return
if new_password:
QMessageBox.information(parent, _('Success'), _('Password was updated successfully'), _('OK'))
else:
QMessageBox.information(parent, _('Success'), _('This wallet is not encrypted'), _('OK'))
if not new_password:
new_password = None
return True, password, new_password
@@ -123,7 +110,27 @@ class PasswordDialog(QDialog):
def run(self):
run_password_dialog(self, self.wallet, self.parent)
ok, password, new_password = run_password_dialog(self, self.wallet, self.parent)
if not ok:
return
try:
self.wallet.get_seed(password)
except Exception:
QMessageBox.warning(self.parent, _('Error'), _('Incorrect Password'), _('OK'))
return False, None, None
try:
self.wallet.update_password(password, new_password)
except:
QMessageBox.warning(self.parent, _('Error'), _('Failed to update password'), _('OK'))
return
if new_password:
QMessageBox.information(self.parent, _('Success'), _('Password was updated successfully'), _('OK'))
else:
QMessageBox.information(self.parent, _('Success'), _('This wallet is not encrypted'), _('OK'))