From 73a28e12f2fab9921d87a0a53a59cd8ed0a19e6f Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 14 Jan 2021 14:18:12 +0100 Subject: [PATCH] fix(core): create protobuf messages correctly --- core/src/apps/base.py | 27 +++++++++++++------------- core/src/apps/ethereum/sign_message.py | 8 ++++---- core/src/apps/nem/sign_tx.py | 8 ++++---- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/core/src/apps/base.py b/core/src/apps/base.py index 4b26af5ed..a89f75392 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -35,19 +35,20 @@ if False: def get_features() -> Features: - f = Features() - f.vendor = "trezor.io" - f.language = "en-US" - f.major_version = utils.VERSION_MAJOR - f.minor_version = utils.VERSION_MINOR - f.patch_version = utils.VERSION_PATCH - f.revision = utils.GITREV.encode() - f.model = utils.MODEL - f.device_id = storage.device.get_device_id() - f.label = storage.device.get_label() - f.pin_protection = config.has_pin() - f.unlocked = config.is_unlocked() - f.passphrase_protection = storage.device.is_passphrase_enabled() + f = Features( + vendor="trezor.io", + language="en-US", + major_version=utils.VERSION_MAJOR, + minor_version=utils.VERSION_MINOR, + patch_version=utils.VERSION_PATCH, + revision=utils.GITREV.encode(), + model=utils.MODEL, + device_id=storage.device.get_device_id(), + label=storage.device.get_label(), + pin_protection=config.has_pin(), + unlocked=config.is_unlocked(), + passphrase_protection=storage.device.is_passphrase_enabled(), + ) if utils.BITCOIN_ONLY: f.capabilities = [ diff --git a/core/src/apps/ethereum/sign_message.py b/core/src/apps/ethereum/sign_message.py index 0d1a4c89c..b8394e946 100644 --- a/core/src/apps/ethereum/sign_message.py +++ b/core/src/apps/ethereum/sign_message.py @@ -32,7 +32,7 @@ async def sign_message(ctx, msg, keychain): secp256k1.CANONICAL_SIG_ETHEREUM, ) - sig = EthereumMessageSignature() - sig.address = address.address_from_bytes(node.ethereum_pubkeyhash()) - sig.signature = signature[1:] + bytearray([signature[0]]) - return sig + return EthereumMessageSignature( + address=address.address_from_bytes(node.ethereum_pubkeyhash()), + signature=signature[1:] + bytearray([signature[0]]), + ) diff --git a/core/src/apps/nem/sign_tx.py b/core/src/apps/nem/sign_tx.py index 33ba3533e..bb211dde8 100644 --- a/core/src/apps/nem/sign_tx.py +++ b/core/src/apps/nem/sign_tx.py @@ -72,7 +72,7 @@ async def sign_tx(ctx, msg: NEMSignTx, keychain): signature = ed25519.sign(node.private_key(), tx, NEM_HASH_ALG) - resp = NEMSignedTx() - resp.data = tx - resp.signature = signature - return resp + return NEMSignedTx( + data=tx, + signature=signature, + )