From 15c716f73038f9a89ccc71f260853f8d7d1f0faa Mon Sep 17 00:00:00 2001 From: Boris Oncev Date: Thu, 19 Dec 2024 10:04:31 +0100 Subject: [PATCH] fix styling --- common/defs/misc/misc.json | 7 ------ core/src/apps/mintlayer/sign_tx/signer.py | 4 ---- core/src/apps/workflow_handlers.py | 2 +- python/src/trezorlib/cli/mintlayer.py | 28 +++++++++++++++++++---- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/common/defs/misc/misc.json b/common/defs/misc/misc.json index db4e6aae0..dbd09766d 100644 --- a/common/defs/misc/misc.json +++ b/common/defs/misc/misc.json @@ -103,12 +103,5 @@ "slip44": 501, "curve": "ed25519", "decimals": 9 - }, - { - "name": "Mintlayer", - "shortcut": "ML", - "slip44": 19788, - "curve": "secp256k1", - "decimals": 11 } ] diff --git a/core/src/apps/mintlayer/sign_tx/signer.py b/core/src/apps/mintlayer/sign_tx/signer.py index 929e35d19..720ffd5d8 100644 --- a/core/src/apps/mintlayer/sign_tx/signer.py +++ b/core/src/apps/mintlayer/sign_tx/signer.py @@ -93,9 +93,6 @@ def add_input( def add_output(self, txo: MintlayerTxOutput): self.outputs.append(txo) - def number_of_utxos(self) -> int: - return sum([1 for inp in self.inputs if inp.utxo is not None]) - class Mintlayer: def init_signing(self) -> None: @@ -164,7 +161,6 @@ def __init__( ) -> None: from trezor.messages import MintlayerTxRequest, MintlayerTxRequestDetailsType - self.progress = Progress() self.coininfo = find_coin_by_name(tx.coin_name) self.tx_info = TxInfo(tx=tx, inputs=[], outputs=[]) diff --git a/core/src/apps/workflow_handlers.py b/core/src/apps/workflow_handlers.py index 6e6bdfda7..7632f15f5 100644 --- a/core/src/apps/workflow_handlers.py +++ b/core/src/apps/workflow_handlers.py @@ -24,7 +24,7 @@ def _find_message_handler_module(msg_type: int) -> str: - collecting everything as strings instead of importing directly means that we don't need to load any of the modules into memory until we actually need them """ - from trezor import log, utils + from trezor import utils from trezor.enums import MessageType # debug diff --git a/python/src/trezorlib/cli/mintlayer.py b/python/src/trezorlib/cli/mintlayer.py index f95611e2a..108f4a1fb 100644 --- a/python/src/trezorlib/cli/mintlayer.py +++ b/python/src/trezorlib/cli/mintlayer.py @@ -17,12 +17,14 @@ def cli() -> None: @cli.command() +@click.option("-c", "--coin", required=True, help="coin name") @click.option("-n", "--address", required=True, help="BIP-32 path") @click.option("-d", "--show-display", is_flag=True) @click.option("-C", "--chunkify", is_flag=True) @with_client def get_address( client: "TrezorClient", + coin: str, address: str, show_display: bool, chunkify: bool, @@ -37,17 +39,20 @@ def get_address( return mintlayer.get_address( client, address_n, + coin, show_display, chunkify=chunkify, ) @cli.command() +@click.option("-c", "--coin", required=True, help="coin name") @click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/44h/0h/0h") @click.option("-d", "--show-display", is_flag=True) @with_client def get_public_key( client: "TrezorClient", + coin: str, address: str, show_display: bool, ) -> dict: @@ -60,6 +65,7 @@ def get_public_key( result = mintlayer.get_public_key( client, address_n, + coin, show_display=show_display, ) if isinstance(result, messages.MintlayerPublicKey): @@ -72,21 +78,29 @@ def get_public_key( @cli.command() +@click.option("-c", "--coin", required=True, help="coin name") @click.option("-n", "--address_n", required=True, help="BIP-32 path") -@click.option("-a", "--address", required=True, help="bech32 encoded address") +@click.option( + "-a", + "--address-type", + required=True, + help="Address type PUBLIC_KEY or PUBLIC_KEY_HASH", +) @click.argument("message") @with_client def sign_message( client: "TrezorClient", + coin: str, address_n: str, - address: str, + address_type: str, message: str, ) -> dict: """Sign message using address of given path.""" result = mintlayer.sign_message( client, + coin_name=coin, address_n=tools.parse_path(address_n), - address=address, + address_type=address_type, message=message.encode(), ) if isinstance(result, messages.MessageSignature): @@ -100,10 +114,13 @@ def sign_message( @cli.command() +@click.option("-c", "--coin", required=True, help="coin name") @click.option("-C", "--chunkify", is_flag=True) @click.argument("json_file", type=click.File()) @with_client -def sign_tx(client: "TrezorClient", json_file: TextIO, chunkify: bool) -> None: +def sign_tx( + client: "TrezorClient", coin: str, json_file: TextIO, chunkify: bool +) -> None: """Sign transaction. Transaction data must be provided in a JSON file. The structure of the JSON matches the shape of the relevant protobuf messages. See @@ -129,6 +146,7 @@ def sign_tx(client: "TrezorClient", json_file: TextIO, chunkify: bool) -> None: results = mintlayer.sign_tx( client, + coin, inputs, outputs, prev_txs=prev_txes, @@ -139,7 +157,7 @@ def sign_tx(client: "TrezorClient", json_file: TextIO, chunkify: bool) -> None: click.echo() click.echo("Signed signatures:") for res in results: - click.echo(f"signature index: {res.signature_index}") + click.echo(f"input index: {res.input_index}") click.echo("signature:") for sig in res.signatures: if sig.multisig_idx is not None: