commit ace127ee430711b4fa1f7f42e7606bf074510733
parent 95fce65e12420ca85a9d9e53279df513b7584590
Author: ThomasV <thomasv@gitorious>
Date: Thu, 1 May 2014 12:42:06 +0200
fix password dialog, for imported wallets
Diffstat:
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -1072,7 +1072,7 @@ class ElectrumWindow(QMainWindow):
menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")) )
menu.addAction(_("Edit label"), lambda: self.edit_label(True))
menu.addAction(_("Public keys"), lambda: self.show_public_keys(addr))
- if self.wallet.seed:
+ if not self.wallet.is_watching_only():
menu.addAction(_("Private key"), lambda: self.show_private_key(addr))
menu.addAction(_("Sign/verify message"), lambda: self.sign_verify_message(addr))
#menu.addAction(_("Encrypt/decrypt message"), lambda: self.encrypt_message(addr))
diff --git a/gui/qt/password_dialog.py b/gui/qt/password_dialog.py
@@ -73,8 +73,8 @@ def make_password_dialog(self, wallet, msg):
def run_password_dialog(self, wallet, parent):
- if wallet and not wallet.seed:
- QMessageBox.information(parent, _('Error'), _('No seed'), _('OK'))
+ if wallet.is_watching_only():
+ QMessageBox.information(parent, _('Error'), _('This is a watching-only wallet'), _('OK'))
return False, None, None
if not self.exec_():
@@ -116,7 +116,7 @@ class PasswordDialog(QDialog):
return
try:
- self.wallet.get_seed(password)
+ self.wallet.check_password(password)
except Exception:
QMessageBox.warning(self.parent, _('Error'), _('Incorrect Password'), _('OK'))
return False, None, None
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -374,13 +374,12 @@ class Abstract_Wallet:
if self.is_watching_only():
return []
- # first check the provided password
- seed = self.get_seed(password)
-
out = []
if address in self.imported_keys.keys():
+ self.check_password(password)
out.append( pw_decode( self.imported_keys[address], password ) )
else:
+ seed = self.get_seed(password)
account_id, sequence = self.get_address_index(address)
account = self.accounts[account_id]
xpubs = account.get_master_pubkeys()
@@ -948,12 +947,14 @@ class Abstract_Wallet:
def update_password(self, old_password, new_password):
- if new_password == '': new_password = None
- decoded = self.get_seed(old_password)
- self.seed = pw_encode( decoded, new_password)
- self.storage.put('seed', self.seed, True)
- self.use_encryption = (new_password != None)
- self.storage.put('use_encryption', self.use_encryption,True)
+ if new_password == '':
+ new_password = None
+
+ if self.has_seed():
+ decoded = self.get_seed(old_password)
+ self.seed = pw_encode( decoded, new_password)
+ self.storage.put('seed', self.seed, True)
+
for k in self.imported_keys.keys():
a = self.imported_keys[k]
b = pw_decode(a, old_password)
@@ -967,6 +968,9 @@ class Abstract_Wallet:
self.master_private_keys[k] = c
self.storage.put('master_private_keys', self.master_private_keys, True)
+ self.use_encryption = (new_password != None)
+ self.storage.put('use_encryption', self.use_encryption,True)
+
def freeze(self,addr):
if self.is_mine(addr) and addr not in self.frozen_addresses:
@@ -1651,13 +1655,12 @@ class OldWallet(Deterministic_Wallet):
if self.is_watching_only():
return []
- # first check the provided password
- seed = self.get_seed(password)
-
out = []
if address in self.imported_keys.keys():
+ self.check_password()
out.append( pw_decode( self.imported_keys[address], password ) )
else:
+ seed = self.get_seed(password)
account_id, sequence = self.get_address_index(address)
pk = self.accounts[0].get_private_key(seed, sequence)
out.append(pk)