hardware: store derivation instead of account_id
This commit is contained in:
parent
664077397e
commit
428bc539b3
|
@ -176,8 +176,9 @@ class BaseWizard(object):
|
||||||
self.account_id_dialog(run_next=f)
|
self.account_id_dialog(run_next=f)
|
||||||
|
|
||||||
def on_hardware_account_id(self, account_id):
|
def on_hardware_account_id(self, account_id):
|
||||||
from keystore import load_keystore
|
from keystore import load_keystore, bip44_derivation
|
||||||
self.storage.put('account_id', int(account_id))
|
derivation = bip44_derivation(int(account_id))
|
||||||
|
self.storage.put('derivation', derivation)
|
||||||
name = self.storage.get('hardware_type')
|
name = self.storage.get('hardware_type')
|
||||||
plugin = self.plugins.get_plugin(name)
|
plugin = self.plugins.get_plugin(name)
|
||||||
plugin.on_create_wallet(self.storage, self)
|
plugin.on_create_wallet(self.storage, self)
|
||||||
|
|
|
@ -644,6 +644,8 @@ is_any_key = lambda x: is_old_mpk(x) or is_xprv(x) or is_xpub(x) or is_address_l
|
||||||
is_private_key = lambda x: is_xprv(x) or is_private_key_list(x)
|
is_private_key = lambda x: is_xprv(x) or is_private_key_list(x)
|
||||||
is_bip32_key = lambda x: is_xprv(x) or is_xpub(x)
|
is_bip32_key = lambda x: is_xprv(x) or is_xpub(x)
|
||||||
|
|
||||||
|
def bip44_derivation(account_id):
|
||||||
|
return "m/44'/0'/%d'"% int(account_id)
|
||||||
|
|
||||||
def from_seed(seed, password):
|
def from_seed(seed, password):
|
||||||
if is_old_seed(seed):
|
if is_old_seed(seed):
|
||||||
|
|
|
@ -36,6 +36,7 @@ import stat
|
||||||
from i18n import _
|
from i18n import _
|
||||||
from util import NotEnoughFunds, PrintError, profiler
|
from util import NotEnoughFunds, PrintError, profiler
|
||||||
from plugins import run_hook, plugin_loaders
|
from plugins import run_hook, plugin_loaders
|
||||||
|
from keystore import bip44_derivation
|
||||||
|
|
||||||
class WalletStorage(PrintError):
|
class WalletStorage(PrintError):
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ class WalletStorage(PrintError):
|
||||||
storage2.put('accounts', {'0': x})
|
storage2.put('accounts', {'0': x})
|
||||||
# need to save derivation and xpub too
|
# need to save derivation and xpub too
|
||||||
storage2.put('master_public_keys', {'x/': xpub})
|
storage2.put('master_public_keys', {'x/': xpub})
|
||||||
storage2.put('account_id', k)
|
storage2.put('derivation', bip44_derivation(k))
|
||||||
storage2.write()
|
storage2.write()
|
||||||
result.append(new_path)
|
result.append(new_path)
|
||||||
else:
|
else:
|
||||||
|
@ -218,7 +219,7 @@ class WalletStorage(PrintError):
|
||||||
self.put('hardware_type', wallet_type)
|
self.put('hardware_type', wallet_type)
|
||||||
xpub = self.get('master_public_keys')["x/0'"]
|
xpub = self.get('master_public_keys')["x/0'"]
|
||||||
self.put('master_public_keys', {'x/': xpub})
|
self.put('master_public_keys', {'x/': xpub})
|
||||||
self.put('account_id', 0)
|
self.put('derivation', bip44_derivation(0))
|
||||||
|
|
||||||
def convert_imported(self, test):
|
def convert_imported(self, test):
|
||||||
# '/x' is the internal ID for imported accounts
|
# '/x' is the internal ID for imported accounts
|
||||||
|
|
|
@ -23,10 +23,10 @@ class TrezorCompatibleKeyStore(Hardware_KeyStore):
|
||||||
|
|
||||||
def load(self, storage, name):
|
def load(self, storage, name):
|
||||||
self.xpub = storage.get('master_public_keys', {}).get(name)
|
self.xpub = storage.get('master_public_keys', {}).get(name)
|
||||||
self.account_id = int(storage.get('account_id'))
|
self.derivation = storage.get('derivation')
|
||||||
|
|
||||||
def get_derivation(self):
|
def get_derivation(self):
|
||||||
return "m/44'/0'/%d'"%self.account_id
|
return self.derivation
|
||||||
|
|
||||||
def get_client(self, force_pair=True):
|
def get_client(self, force_pair=True):
|
||||||
return self.plugin.get_client(self, force_pair)
|
return self.plugin.get_client(self, force_pair)
|
||||||
|
|
|
@ -291,7 +291,7 @@ def qt_plugin_class(base_plugin_class):
|
||||||
# Setup device and create accounts in separate thread; wait until done
|
# Setup device and create accounts in separate thread; wait until done
|
||||||
loop = QEventLoop()
|
loop = QEventLoop()
|
||||||
exc_info = []
|
exc_info = []
|
||||||
derivation = "m/44'/0'/%d'"%storage.get('account_id')
|
derivation = storage.get('derivation')
|
||||||
self.setup_device(derivation, thread, handler, on_done=loop.quit,
|
self.setup_device(derivation, thread, handler, on_done=loop.quit,
|
||||||
on_error=lambda info: exc_info.extend(info))
|
on_error=lambda info: exc_info.extend(info))
|
||||||
loop.exec_()
|
loop.exec_()
|
||||||
|
|
Loading…
Reference in New Issue