add class Simple_Wallet
This commit is contained in:
parent
dc553ff108
commit
ccf1f0f5d1
|
@ -1335,7 +1335,37 @@ class Abstract_Wallet(PrintError):
|
||||||
return self.keystore.decrypt_message(index, message, password)
|
return self.keystore.decrypt_message(index, message, password)
|
||||||
|
|
||||||
|
|
||||||
class Imported_Wallet(Abstract_Wallet):
|
class Simple_Wallet(Abstract_Wallet):
|
||||||
|
# wallet with a single keystore
|
||||||
|
|
||||||
|
def get_keystore(self):
|
||||||
|
return self.keystore
|
||||||
|
|
||||||
|
def get_keystores(self):
|
||||||
|
return [self.keystore]
|
||||||
|
|
||||||
|
def is_watching_only(self):
|
||||||
|
return self.keystore.is_watching_only()
|
||||||
|
|
||||||
|
def can_change_password(self):
|
||||||
|
return self.keystore.can_change_password()
|
||||||
|
|
||||||
|
def check_password(self, password):
|
||||||
|
self.keystore.check_password(password)
|
||||||
|
|
||||||
|
def update_password(self, old_pw, new_pw, encrypt=False):
|
||||||
|
if old_pw is None and self.has_password():
|
||||||
|
raise InvalidPassword()
|
||||||
|
self.keystore.update_password(old_pw, new_pw)
|
||||||
|
self.save_keystore()
|
||||||
|
self.storage.set_password(new_pw, encrypt)
|
||||||
|
self.storage.write()
|
||||||
|
|
||||||
|
def save_keystore(self):
|
||||||
|
self.storage.put('keystore', self.keystore.dump())
|
||||||
|
|
||||||
|
|
||||||
|
class Imported_Wallet(Simple_Wallet):
|
||||||
# wallet made of imported addresses
|
# wallet made of imported addresses
|
||||||
|
|
||||||
wallet_type = 'imported'
|
wallet_type = 'imported'
|
||||||
|
@ -1614,7 +1644,7 @@ class Deterministic_Wallet(Abstract_Wallet):
|
||||||
return self.txin_type
|
return self.txin_type
|
||||||
|
|
||||||
|
|
||||||
class Simple_Deterministic_Wallet(Deterministic_Wallet):
|
class Simple_Deterministic_Wallet(Simple_Wallet, Deterministic_Wallet):
|
||||||
|
|
||||||
""" Deterministic Wallet with a single pubkey per address """
|
""" Deterministic Wallet with a single pubkey per address """
|
||||||
|
|
||||||
|
@ -1660,31 +1690,6 @@ class Simple_Deterministic_Wallet(Deterministic_Wallet):
|
||||||
def derive_pubkeys(self, c, i):
|
def derive_pubkeys(self, c, i):
|
||||||
return self.keystore.derive_pubkey(c, i)
|
return self.keystore.derive_pubkey(c, i)
|
||||||
|
|
||||||
def get_keystore(self):
|
|
||||||
return self.keystore
|
|
||||||
|
|
||||||
def get_keystores(self):
|
|
||||||
return [self.keystore]
|
|
||||||
|
|
||||||
def is_watching_only(self):
|
|
||||||
return self.keystore.is_watching_only()
|
|
||||||
|
|
||||||
def can_change_password(self):
|
|
||||||
return self.keystore.can_change_password()
|
|
||||||
|
|
||||||
def check_password(self, password):
|
|
||||||
self.keystore.check_password(password)
|
|
||||||
|
|
||||||
def update_password(self, old_pw, new_pw, encrypt=False):
|
|
||||||
if old_pw is None and self.has_password():
|
|
||||||
raise InvalidPassword()
|
|
||||||
self.keystore.update_password(old_pw, new_pw)
|
|
||||||
self.save_keystore()
|
|
||||||
self.storage.set_password(new_pw, encrypt)
|
|
||||||
self.storage.write()
|
|
||||||
|
|
||||||
def save_keystore(self):
|
|
||||||
self.storage.put('keystore', self.keystore.dump())
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue