electrum

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

commit fb76fcc886b7c999387a6676f479678df742fdaa
parent 53893be4c9224b6914df40248c94d065c2512643
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue,  2 Jul 2019 21:21:39 +0200

trezor: use only Bridge when available

fixes #5420

Diffstat:
Melectrum/base_wizard.py | 18++++++++++--------
Melectrum/plugins/trezor/trezor.py | 12+++++++++++-
2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py @@ -298,14 +298,16 @@ class BaseWizard(Logger): if not debug_msg: debug_msg = ' {}'.format(_('No exceptions encountered.')) if not devices: - msg = ''.join([ - _('No hardware device detected.') + '\n', - _('To trigger a rescan, press \'Next\'.') + '\n\n', - _('If your device is not detected on Windows, go to "Settings", "Devices", "Connected devices", and do "Remove device". Then, plug your device again.') + ' ', - _('On Linux, you might have to add a new permission to your udev rules.') + '\n\n', - _('Debug message') + '\n', - debug_msg - ]) + msg = (_('No hardware device detected.') + '\n' + + _('To trigger a rescan, press \'Next\'.') + '\n\n') + if sys.platform == 'win32': + msg += _('If your device is not detected on Windows, go to "Settings", "Devices", "Connected devices", ' + 'and do "Remove device". Then, plug your device again.') + '\n' + msg += _('While this is less than ideal, it might help if you run Electrum as Administrator.') + '\n' + else: + msg += _('On Linux, you might have to add a new permission to your udev rules.') + '\n' + msg += '\n\n' + msg += _('Debug message') + '\n' + debug_msg self.confirm_dialog(title=title, message=msg, run_next=lambda x: self.choose_hw_device(purpose, storage=storage)) return diff --git a/electrum/plugins/trezor/trezor.py b/electrum/plugins/trezor/trezor.py @@ -23,6 +23,7 @@ _logger = get_logger(__name__) try: import trezorlib import trezorlib.transport + from trezorlib.transport.bridge import BridgeTransport, call_bridge from .clientbase import TrezorClientBase @@ -137,7 +138,16 @@ class TrezorPlugin(HW_PluginBase): raise LibraryFoundButUnusable(library_version=version) def enumerate(self): - devices = trezorlib.transport.enumerate_devices() + # If there is a bridge, prefer that. + # On Windows, the bridge runs as Admin (and Electrum usually does not), + # so the bridge has better chances of finding devices. see #5420 + # This also avoids duplicate entries. + try: + call_bridge("enumerate") + except Exception: + devices = trezorlib.transport.enumerate_devices() + else: + devices = BridgeTransport.enumerate() return [Device(path=d.get_path(), interface_number=-1, id_=d.get_path(),