Browse Source

wallet.has_seed

283
ThomasV 11 years ago
parent
commit
9c37ed68f4
  1. 38
      gui/qt/main_window.py
  2. 25
      lib/wallet.py

38
gui/qt/main_window.py

@ -1354,13 +1354,16 @@ class ElectrumWindow(QMainWindow):
def update_buttons_on_seed(self):
if not self.wallet.is_watching_only():
if self.wallet.has_seed():
self.seed_button.show()
else:
self.seed_button.hide()
if not self.wallet.is_watching_only():
self.password_button.show()
self.send_button.setText(_("Send"))
else:
self.password_button.hide()
self.seed_button.hide()
self.send_button.setText(_("Create unsigned transaction"))
@ -1469,29 +1472,18 @@ class ElectrumWindow(QMainWindow):
@protected
def show_seed_dialog(self, password):
if self.wallet.is_watching_only():
QMessageBox.information(self, _('Message'), _('This is a watching-only wallet'), _('OK'))
if not self.wallet.has_seed():
QMessageBox.information(self, _('Message'), _('This wallet has no seed'), _('OK'))
return
if self.wallet.seed:
try:
mnemonic = self.wallet.get_mnemonic(password)
except Exception:
QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK'))
return
from seed_dialog import SeedDialog
d = SeedDialog(self, mnemonic, self.wallet.imported_keys)
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_()
try:
mnemonic = self.wallet.get_mnemonic(password)
except Exception:
QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK'))
return
from seed_dialog import SeedDialog
d = SeedDialog(self, mnemonic, self.wallet.imported_keys)
d.exec_()

25
lib/wallet.py

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

Loading…
Cancel
Save