1
0

trezor: use only Bridge when available

fixes #5420
This commit is contained in:
SomberNight
2019-07-02 21:21:39 +02:00
parent 53893be4c9
commit fb76fcc886
2 changed files with 21 additions and 9 deletions

View File

@@ -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(),