|
|
|
@ -159,7 +159,7 @@ def configure_logging(verbose: int):
|
|
|
|
|
def cli(ctx, path, verbose, is_json, passphrase_on_host, session_id):
|
|
|
|
|
configure_logging(verbose)
|
|
|
|
|
|
|
|
|
|
if session_id:
|
|
|
|
|
if session_id is not None:
|
|
|
|
|
try:
|
|
|
|
|
session_id = bytes.fromhex(session_id)
|
|
|
|
|
except ValueError:
|
|
|
|
@ -216,6 +216,11 @@ def list_devices(no_resolve):
|
|
|
|
|
for transport in enumerate_devices():
|
|
|
|
|
client = TrezorClient(transport, ui=ui.ClickUI())
|
|
|
|
|
click.echo("{} - {}".format(transport, format_device_name(client.features)))
|
|
|
|
|
try:
|
|
|
|
|
# firmwares <2.3.4 do not recognize EndSession
|
|
|
|
|
client.end_session()
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@ -241,8 +246,8 @@ def ping(client, message, button_protection):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
|
@with_client
|
|
|
|
|
def get_session(client):
|
|
|
|
|
@click.pass_obj
|
|
|
|
|
def get_session(obj):
|
|
|
|
|
"""Get a session ID for subsequent commands.
|
|
|
|
|
|
|
|
|
|
Unlocks Trezor with a passphrase and returns a session ID. Use this session ID with
|
|
|
|
@ -252,17 +257,20 @@ def get_session(client):
|
|
|
|
|
The session ID is valid until another client starts using Trezor, until the next
|
|
|
|
|
get-session call, or until Trezor is disconnected.
|
|
|
|
|
"""
|
|
|
|
|
from ..btc import get_address
|
|
|
|
|
from ..client import PASSPHRASE_TEST_PATH
|
|
|
|
|
|
|
|
|
|
if client.features.model == "1" and client.version < (1, 9, 0):
|
|
|
|
|
raise click.ClickException("Upgrade your firmware to enable session support.")
|
|
|
|
|
|
|
|
|
|
get_address(client, "Testnet", PASSPHRASE_TEST_PATH)
|
|
|
|
|
if client.session_id is None:
|
|
|
|
|
raise click.ClickException("Passphrase not enabled or firmware too old.")
|
|
|
|
|
else:
|
|
|
|
|
return client.session_id.hex()
|
|
|
|
|
# make sure session is not resumed
|
|
|
|
|
obj.session_id = None
|
|
|
|
|
|
|
|
|
|
with obj.client_context() as client:
|
|
|
|
|
if client.features.model == "1" and client.version < (1, 9, 0):
|
|
|
|
|
raise click.ClickException(
|
|
|
|
|
"Upgrade your firmware to enable session support."
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
client.ensure_unlocked()
|
|
|
|
|
if client.session_id is None:
|
|
|
|
|
raise click.ClickException("Passphrase not enabled or firmware too old.")
|
|
|
|
|
else:
|
|
|
|
|
return client.session_id.hex()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
|