wallet.has_seed

This commit is contained in:
ThomasV 2014-04-30 11:40:53 +02:00
parent 56e8ad3397
commit 9c37ed68f4
2 changed files with 37 additions and 26 deletions

View file

@ -1354,13 +1354,16 @@ class ElectrumWindow(QMainWindow):
def update_buttons_on_seed(self): def update_buttons_on_seed(self):
if not self.wallet.is_watching_only(): if self.wallet.has_seed():
self.seed_button.show() self.seed_button.show()
else:
self.seed_button.hide()
if not self.wallet.is_watching_only():
self.password_button.show() self.password_button.show()
self.send_button.setText(_("Send")) self.send_button.setText(_("Send"))
else: else:
self.password_button.hide() self.password_button.hide()
self.seed_button.hide()
self.send_button.setText(_("Create unsigned transaction")) self.send_button.setText(_("Create unsigned transaction"))
@ -1469,29 +1472,18 @@ class ElectrumWindow(QMainWindow):
@protected @protected
def show_seed_dialog(self, password): def show_seed_dialog(self, password):
if self.wallet.is_watching_only(): if not self.wallet.has_seed():
QMessageBox.information(self, _('Message'), _('This is a watching-only wallet'), _('OK')) QMessageBox.information(self, _('Message'), _('This wallet has no seed'), _('OK'))
return return
if self.wallet.seed: try:
try: mnemonic = self.wallet.get_mnemonic(password)
mnemonic = self.wallet.get_mnemonic(password) except Exception:
except Exception: QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK'))
QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK')) return
return from seed_dialog import SeedDialog
from seed_dialog import SeedDialog d = SeedDialog(self, mnemonic, self.wallet.imported_keys)
d = SeedDialog(self, mnemonic, self.wallet.imported_keys) d.exec_()
d.exec_()
else:
l = {}
for k in self.wallet.master_private_keys.keys():
pk = self.wallet.get_master_private_key(k, password)
l[k] = pk
from seed_dialog import PrivateKeysDialog
d = PrivateKeysDialog(self,l)
d.exec_()

View file

@ -244,12 +244,20 @@ class Abstract_Wallet:
pass pass
def load_accounts(self): def load_accounts(self):
self.accounts = {}
def synchronize(self):
pass pass
def get_pending_accounts(self):
return {}
def can_create_accounts(self): def can_create_accounts(self):
return False return False
def check_password(self, password):
pass
def set_up_to_date(self,b): def set_up_to_date(self,b):
with self.lock: self.up_to_date = b with self.lock: self.up_to_date = b
@ -266,8 +274,7 @@ class Abstract_Wallet:
def import_key(self, sec, password): def import_key(self, sec, password):
# check password self.check_password(password)
seed = self.get_seed(password)
try: try:
address = address_from_private_key(sec) address = address_from_private_key(sec)
except Exception: except Exception:
@ -1094,6 +1101,9 @@ class Abstract_Wallet:
self.verifier.stop() self.verifier.stop()
self.synchronizer.stop() self.synchronizer.stop()
def restore(self, cb):
pass
class Imported_Wallet(Abstract_Wallet): class Imported_Wallet(Abstract_Wallet):
@ -1105,6 +1115,9 @@ class Imported_Wallet(Abstract_Wallet):
n = self.imported_keys.values() n = self.imported_keys.values()
return n == [''] * len(n) return n == [''] * len(n)
def has_seed(self):
return False
class Deterministic_Wallet(Abstract_Wallet): class Deterministic_Wallet(Abstract_Wallet):
@ -1112,8 +1125,14 @@ class Deterministic_Wallet(Abstract_Wallet):
def __init__(self, storage): def __init__(self, storage):
Abstract_Wallet.__init__(self, storage) Abstract_Wallet.__init__(self, storage)
def has_seed(self):
return self.seed == ''
def is_watching_only(self): def is_watching_only(self):
return (self.seed == '') and (self.master_private_keys == {}) return self.has_seed()
def check_password(self, password):
self.get_seed(password)
def get_seed(self, password): def get_seed(self, password):
s = pw_decode(self.seed, password) s = pw_decode(self.seed, password)