electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit ccf1f0f5d12b5087f5a9f84364c9ebe2c73c6129
parent dc553ff108c1dbcadb193ad899dd7897f702107e
Author: ThomasV <thomasv@electrum.org>
Date:   Sun, 15 Oct 2017 10:14:55 +0200

add class Simple_Wallet

Diffstat:
Mlib/wallet.py | 59++++++++++++++++++++++++++++++++---------------------------
1 file changed, 32 insertions(+), 27 deletions(-)

diff --git a/lib/wallet.py b/lib/wallet.py @@ -1335,7 +1335,37 @@ class Abstract_Wallet(PrintError): 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_type = 'imported' @@ -1614,7 +1644,7 @@ class Deterministic_Wallet(Abstract_Wallet): 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 """ @@ -1660,31 +1690,6 @@ class Simple_Deterministic_Wallet(Deterministic_Wallet): def derive_pubkeys(self, 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())