1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

python/trezorctl: improve file-based arguments

This commit is contained in:
matejcik 2020-08-05 12:03:06 +02:00
parent e585d35f34
commit 2678e64a99
12 changed files with 31 additions and 49 deletions

View File

@ -21,6 +21,7 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/
### Fixed ### Fixed
- correctly calculate hashes for very small firmwares [f#1082] - correctly calculate hashes for very small firmwares [f#1082]
- unified file arguments in trezorctl
## [0.12.0] - 2020-04-01 ## [0.12.0] - 2020-04-01
[0.12.0]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.6...python/v0.12.0 [0.12.0]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.6...python/v0.12.0

View File

@ -81,7 +81,7 @@ Binance Chain commands.
Commands: Commands:
get-address Get Binance address for specified path. get-address Get Binance address for specified path.
get-public-key Get Binance public key. get-public-key Get Binance public key.
sign-tx Sign Binance transaction sign-tx Sign Binance transaction.
Bitcoin and Bitcoin-like coins commands. Bitcoin and Bitcoin-like coins commands.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -50,16 +50,14 @@ def get_public_key(client, address, show_display):
@cli.command() @cli.command()
@click.argument("file", type=click.File("r"))
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option( @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"-f",
"--file",
type=click.File("r"),
required=True,
help="Transaction in JSON format",
)
@with_client @with_client
def sign_tx(client, address, file): def sign_tx(client, address, file):
"""Sign Binance transaction""" """Sign Binance transaction.
Transaction must be provided as a JSON file.
"""
address_n = tools.parse_path(address) address_n = tools.parse_path(address)
return binance.sign_tx(client, address_n, json.load(file)) return binance.sign_tx(client, address_n, json.load(file))

View File

@ -181,7 +181,7 @@ def get_public_node(client, coin, address, curve, script_type, show_display):
@cli.command() @cli.command()
@click.option("-c", "--coin", "_ignore", is_flag=True, hidden=True, expose_value=False) @click.option("-c", "--coin", is_flag=True, hidden=True, expose_value=False)
@click.argument("json_file", type=click.File()) @click.argument("json_file", type=click.File())
@with_client @with_client
def sign_tx(client, json_file): def sign_tx(client, json_file):

View File

@ -38,13 +38,8 @@ def cli():
@cli.command() @cli.command()
@click.option( @click.argument("file", type=click.File("r"))
"-f", @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"--file",
type=click.File("r"),
required=True,
help="Transaction in JSON format",
)
@click.option( @click.option(
"-p", "--protocol-magic", type=int, default=cardano.PROTOCOL_MAGICS["mainnet"] "-p", "--protocol-magic", type=int, default=cardano.PROTOCOL_MAGICS["mainnet"]
) )

View File

@ -41,14 +41,9 @@ def get_public_key(client, address, show_display):
@cli.command() @cli.command()
@click.argument("file", type=click.File("r"))
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option( @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"-f",
"--file",
type=click.File("r"),
required=True,
help="Transaction in JSON format",
)
@with_client @with_client
def sign_transaction(client, address, file): def sign_transaction(client, address, file):
"""Sign EOS transaction.""" """Sign EOS transaction."""

View File

@ -168,7 +168,7 @@ def find_best_firmware_version(
@click.command() @click.command()
# fmt: off # fmt: off
@click.option("-f", "--filename") @click.option("-f", "--filename", type=click.File("rb"))
@click.option("-u", "--url") @click.option("-u", "--url")
@click.option("-v", "--version") @click.option("-v", "--version")
@click.option("-s", "--skip-check", is_flag=True, help="Do not validate firmware integrity") @click.option("-s", "--skip-check", is_flag=True, help="Do not validate firmware integrity")
@ -224,7 +224,7 @@ def firmware_update(
model = client.features.model or "1" model = client.features.model or "1"
if filename: if filename:
data = open(filename, "rb").read() data = filename.read()
else: else:
if not url: if not url:
if version: if version:

View File

@ -52,11 +52,9 @@ def get_public_key(client, address, show_display):
@cli.command() @cli.command()
@click.argument("file", type=click.File("r"))
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option( @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"-f", "--file", type=click.File("r"), default="-", help="Transaction in JSON format"
)
# @click.option('-b', '--broadcast', help='Broadcast Lisk transaction')
@with_client @with_client
def sign_tx(client, address, file): def sign_tx(client, address, file):
"""Sign Lisk transaction.""" """Sign Lisk transaction."""

View File

@ -42,18 +42,16 @@ def get_address(client, address, network, show_display):
@cli.command() @cli.command()
@click.argument("file", type=click.File("r"))
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option( @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"-f",
"--file",
type=click.File("r"),
default="-",
help="Transaction in NIS (RequestPrepareAnnounce) format",
)
@click.option("-b", "--broadcast", help="NIS to announce transaction to") @click.option("-b", "--broadcast", help="NIS to announce transaction to")
@with_client @with_client
def sign_tx(client, address, file, broadcast): def sign_tx(client, address, file, broadcast):
"""Sign (and optionally broadcast) NEM transaction.""" """Sign (and optionally broadcast) NEM transaction.
Transaction file is expected in the NIS (RequestPrepareAnnounce) format.
"""
address_n = tools.parse_path(address) address_n = tools.parse_path(address)
transaction = nem.sign_tx(client, address_n, json.load(file)) transaction = nem.sign_tx(client, address_n, json.load(file))

View File

@ -40,10 +40,9 @@ def get_address(client, address, show_display):
@cli.command() @cli.command()
@click.argument("file", type=click.File("r"))
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option( @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"-f", "--file", type=click.File("r"), default="-", help="Transaction in JSON format"
)
@with_client @with_client
def sign_tx(client, address, file): def sign_tx(client, address, file):
"""Sign Ripple transaction""" """Sign Ripple transaction"""

View File

@ -104,7 +104,10 @@ def flags(client, flags):
@cli.command() @cli.command()
@click.option("-f", "--filename", default=None) @click.argument(
"filename", type=click.Path(dir_okay=False, readable=True), required=False
)
@click.option("-f", "--filename", is_flag=True, hidden=True, expose_value=False)
@with_client @with_client
def homescreen(client, filename): def homescreen(client, filename):
"""Set new homescreen.""" """Set new homescreen."""

View File

@ -50,14 +50,9 @@ def get_public_key(client, address, show_display):
@cli.command() @cli.command()
@click.argument("file", type=click.File("r"))
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option( @click.option("-f", "--file", is_flag=True, hidden=True, expose_value=False)
"-f",
"--file",
type=click.File("r"),
default="-",
help="Transaction in JSON format (byte fields should be hexlified)",
)
@with_client @with_client
def sign_tx(client, address, file): def sign_tx(client, address, file):
"""Sign Tezos transaction.""" """Sign Tezos transaction."""