From bf2baf798f576dec31ba77a87dca9d5deaaaa955 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Fri, 4 Feb 2022 16:12:32 +0100 Subject: [PATCH] feat(trezorctl): Support generating Electrum-compatible message signatures. --- python/.changelog.d/2100.added | 1 + python/src/trezorlib/cli/btc.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 python/.changelog.d/2100.added diff --git a/python/.changelog.d/2100.added b/python/.changelog.d/2100.added new file mode 100644 index 0000000000..554cbdad70 --- /dev/null +++ b/python/.changelog.d/2100.added @@ -0,0 +1 @@ +Support generating Electrum-compatible message signatures in CLI. diff --git a/python/src/trezorlib/cli/btc.py b/python/src/trezorlib/cli/btc.py index 697acbf05e..4166b6e2ef 100644 --- a/python/src/trezorlib/cli/btc.py +++ b/python/src/trezorlib/cli/btc.py @@ -333,6 +333,12 @@ def sign_tx(client: "TrezorClient", json_file: TextIO) -> None: @click.option("-c", "--coin", default=DEFAULT_COIN) @click.option("-n", "--address", required=True, help="BIP-32 path") @click.option("-t", "--script-type", type=ChoiceType(INPUT_SCRIPTS), default="address") +@click.option( + "-e", + "--electrum-compat", + is_flag=True, + help="Generate Electrum-compatible signature", +) @click.argument("message") @with_client def sign_message( @@ -341,10 +347,13 @@ def sign_message( address: str, message: str, script_type: messages.InputScriptType, + electrum_compat: bool, ) -> Dict[str, str]: """Sign message using address of given path.""" address_n = tools.parse_path(address) - res = btc.sign_message(client, coin, address_n, message, script_type) + res = btc.sign_message( + client, coin, address_n, message, script_type, electrum_compat + ) return { "message": message, "address": res.address,