Major refactoring
- separation between Wallet and key management (Keystore) - simplification of wallet classes - remove support for multiple accounts in the same wallet - add support for OP_RETURN to Trezor plugin - split multi-accounts wallets for backward compatibility
This commit is contained in:
@@ -37,8 +37,8 @@ class HW_PluginBase(BasePlugin):
|
||||
|
||||
def __init__(self, parent, config, name):
|
||||
BasePlugin.__init__(self, parent, config, name)
|
||||
self.device = self.wallet_class.device
|
||||
self.wallet_class.plugin = self
|
||||
self.device = self.keystore_class.device
|
||||
self.keystore_class.plugin = self
|
||||
|
||||
def is_enabled(self):
|
||||
return self.libraries_available
|
||||
@@ -48,33 +48,6 @@ class HW_PluginBase(BasePlugin):
|
||||
|
||||
@hook
|
||||
def close_wallet(self, wallet):
|
||||
if isinstance(wallet, self.wallet_class):
|
||||
if isinstance(wallet.get_keystore(), self.keystore_class):
|
||||
self.device_manager().unpair_wallet(wallet)
|
||||
|
||||
def on_restore_wallet(self, wallet, wizard):
|
||||
assert isinstance(wallet, self.wallet_class)
|
||||
msg = _("Enter the seed for your %s wallet:" % self.device)
|
||||
f = lambda x: wizard.run('on_restore_seed', x)
|
||||
wizard.enter_seed_dialog(run_next=f, title=_('Restore hardware wallet'), message=msg, is_valid=self.is_valid_seed)
|
||||
|
||||
def on_restore_seed(self, wallet, wizard, seed):
|
||||
f = lambda x: wizard.run('on_restore_passphrase', seed, x)
|
||||
wizard.request_passphrase(self.device, run_next=f)
|
||||
|
||||
def on_restore_passphrase(self, wallet, wizard, seed, passphrase):
|
||||
f = lambda x: wizard.run('on_restore_password', seed, passphrase, x)
|
||||
wizard.request_password(run_next=f)
|
||||
|
||||
def on_restore_password(self, wallet, wizard, seed, passphrase, password):
|
||||
# Restored wallets are not hardware wallets
|
||||
wallet_class = self.wallet_class.restore_wallet_class
|
||||
wallet.storage.put('wallet_type', wallet_class.wallet_type)
|
||||
wallet = wallet_class(wallet.storage)
|
||||
wallet.add_seed(seed, password)
|
||||
wallet.add_xprv_from_seed(seed, 'x/', password, passphrase)
|
||||
wallet.create_hd_account(password)
|
||||
wizard.create_addresses()
|
||||
|
||||
@staticmethod
|
||||
def is_valid_seed(seed):
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user