mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-21 02:19:51 +00:00
plugins: do not assume that handler belongs to keystore
This commit is contained in:
parent
8b729d0f83
commit
33c7787941
2 changed files with 7 additions and 7 deletions
|
@ -383,15 +383,14 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
self.scan_devices()
|
self.scan_devices()
|
||||||
return self.client_lookup(id_)
|
return self.client_lookup(id_)
|
||||||
|
|
||||||
def client_for_keystore(self, plugin, keystore, force_pair):
|
def client_for_keystore(self, plugin, handler, keystore, force_pair):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
devices = self.scan_devices()
|
devices = self.scan_devices()
|
||||||
xpub = keystore.xpub
|
xpub = keystore.xpub
|
||||||
derivation = keystore.get_derivation()
|
derivation = keystore.get_derivation()
|
||||||
handler = keystore.handler
|
|
||||||
client = self.client_by_xpub(plugin, xpub, handler, devices)
|
client = self.client_by_xpub(plugin, xpub, handler, devices)
|
||||||
if client is None and force_pair:
|
if client is None and force_pair:
|
||||||
info = self.select_device(handler, plugin, keystore, devices)
|
info = self.select_device(plugin, handler, keystore, devices)
|
||||||
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
|
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
@ -453,7 +452,7 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
|
|
||||||
return infos
|
return infos
|
||||||
|
|
||||||
def select_device(self, handler, plugin, keystore, devices=None):
|
def select_device(self, plugin, handler, keystore, devices=None):
|
||||||
'''Ask the user to select a device to use if there is more than one,
|
'''Ask the user to select a device to use if there is more than one,
|
||||||
and return the DeviceInfo for the device.'''
|
and return the DeviceInfo for the device.'''
|
||||||
while True:
|
while True:
|
||||||
|
@ -478,7 +477,7 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
info = infos[c]
|
info = infos[c]
|
||||||
# save new label
|
# save new label
|
||||||
keystore.set_label(info.label)
|
keystore.set_label(info.label)
|
||||||
keystore.handler.win.wallet.save_keystore()
|
handler.win.wallet.save_keystore()
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
|
|
|
@ -134,7 +134,8 @@ class TrezorCompatiblePlugin(HW_PluginBase):
|
||||||
# All client interaction should not be in the main GUI thread
|
# All client interaction should not be in the main GUI thread
|
||||||
assert self.main_thread != threading.current_thread()
|
assert self.main_thread != threading.current_thread()
|
||||||
devmgr = self.device_manager()
|
devmgr = self.device_manager()
|
||||||
client = devmgr.client_for_keystore(self, keystore, force_pair)
|
handler = keystore.handler
|
||||||
|
client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
|
||||||
# returns the client for a given keystore. can use xpub
|
# returns the client for a given keystore. can use xpub
|
||||||
if client:
|
if client:
|
||||||
client.used()
|
client.used()
|
||||||
|
@ -237,7 +238,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
|
||||||
def show_address(self, wallet, address):
|
def show_address(self, wallet, address):
|
||||||
client = self.get_client(wallet.keystore)
|
client = self.get_client(wallet.keystore)
|
||||||
if not client.atleast_version(1, 3):
|
if not client.atleast_version(1, 3):
|
||||||
wallet.handler.show_error(_("Your device firmware is too old"))
|
keystore.handler.show_error(_("Your device firmware is too old"))
|
||||||
return
|
return
|
||||||
change, index = wallet.get_address_index(address)
|
change, index = wallet.get_address_index(address)
|
||||||
derivation = wallet.keystore.derivation
|
derivation = wallet.keystore.derivation
|
||||||
|
|
Loading…
Add table
Reference in a new issue