mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-18 11:21:11 +00:00
client: add get_default_client convenience function
This commit is contained in:
parent
42583eaceb
commit
526f729420
@ -52,6 +52,25 @@ def get_buttonrequest_value(code):
|
|||||||
][0]
|
][0]
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_client(path=None, ui=None, **kwargs):
|
||||||
|
"""Get a client for a connected Trezor device.
|
||||||
|
|
||||||
|
Returns a TrezorClient instance with minimum fuss.
|
||||||
|
|
||||||
|
If no path is specified, finds first connected Trezor. Otherwise performs
|
||||||
|
a prefix-search for the specified device. If no UI is supplied, instantiates
|
||||||
|
the default CLI UI.
|
||||||
|
"""
|
||||||
|
from .transport import get_transport
|
||||||
|
from .ui import ClickUI
|
||||||
|
|
||||||
|
transport = get_transport(path, prefix_search=True)
|
||||||
|
if ui is None:
|
||||||
|
ui = ClickUI()
|
||||||
|
|
||||||
|
return TrezorClient(transport, ui, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class TrezorClient:
|
class TrezorClient:
|
||||||
"""Trezor client, a connection to a Trezor device.
|
"""Trezor client, a connection to a Trezor device.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user