diff --git a/core/src/apps/binance/get_public_key.py b/core/src/apps/binance/get_public_key.py index 1ea37348d..61633d0b6 100644 --- a/core/src/apps/binance/get_public_key.py +++ b/core/src/apps/binance/get_public_key.py @@ -17,4 +17,4 @@ async def get_public_key(ctx, msg: BinanceGetPublicKey, keychain: Keychain): if msg.show_display: await layout.show_pubkey(ctx, pubkey) - return BinancePublicKey(pubkey) + return BinancePublicKey(public_key=pubkey) diff --git a/core/src/apps/common/signverify.py b/core/src/apps/common/signverify.py index a146582d5..c05f0e484 100644 --- a/core/src/apps/common/signverify.py +++ b/core/src/apps/common/signverify.py @@ -10,10 +10,10 @@ from apps.common.writers import write_bitcoin_varint if False: from typing import List - from apps.common.coininfo import CoinType + from apps.common.coininfo import CoinInfo -def message_digest(coin: CoinType, message: bytes) -> bytes: +def message_digest(coin: CoinInfo, message: bytes) -> bytes: if not utils.BITCOIN_ONLY and coin.decred: h = utils.HashWriter(blake256()) else: @@ -21,7 +21,7 @@ def message_digest(coin: CoinType, message: bytes) -> bytes: if not coin.signed_message_header: raise wire.DataError("Empty message header not allowed.") write_bitcoin_varint(h, len(coin.signed_message_header)) - h.extend(coin.signed_message_header) + h.extend(coin.signed_message_header.encode()) write_bitcoin_varint(h, len(message)) h.extend(message) ret = h.get_digest() @@ -44,9 +44,9 @@ async def require_confirm_sign_message( ctx: wire.Context, coin: str, message: bytes ) -> None: header = "Sign {} message".format(coin) - message = split_message(message) + message_lines = split_message(message) text = Text(header, new_lines=False) - text.normal(*message) + text.normal(*message_lines) await require_confirm(ctx, text) diff --git a/core/src/apps/eos/get_public_key.py b/core/src/apps/eos/get_public_key.py index a28ed01d0..9d2e30a6b 100644 --- a/core/src/apps/eos/get_public_key.py +++ b/core/src/apps/eos/get_public_key.py @@ -31,4 +31,4 @@ async def get_public_key( wif, public_key = _get_public_key(node) if msg.show_display: await require_get_public_key(ctx, wif) - return EosPublicKey(wif, public_key) + return EosPublicKey(wif_public_key=wif, raw_public_key=public_key) diff --git a/core/src/apps/management/get_next_u2f_counter.py b/core/src/apps/management/get_next_u2f_counter.py index c7d842dc1..86384e0be 100644 --- a/core/src/apps/management/get_next_u2f_counter.py +++ b/core/src/apps/management/get_next_u2f_counter.py @@ -19,4 +19,4 @@ async def get_next_u2f_counter( text.normal("the U2F counter?") await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall) - return NextU2FCounter(storage.device.next_u2f_counter()) + return NextU2FCounter(u2f_counter=storage.device.next_u2f_counter()) diff --git a/core/src/apps/management/recovery_device/homescreen.py b/core/src/apps/management/recovery_device/homescreen.py index 520c453d5..f1ca0c3a7 100644 --- a/core/src/apps/management/recovery_device/homescreen.py +++ b/core/src/apps/management/recovery_device/homescreen.py @@ -122,7 +122,7 @@ async def _finish_recovery_dry_run( await layout.show_dry_run_result(ctx, result, is_slip39) if result: - return Success("The seed is valid and matches the one in the device") + return Success(message="The seed is valid and matches the one in the device") else: raise wire.ProcessError("The seed does not match the one in the device") diff --git a/core/src/apps/ripple/sign_tx.py b/core/src/apps/ripple/sign_tx.py index cbf21af5a..10627d3c2 100644 --- a/core/src/apps/ripple/sign_tx.py +++ b/core/src/apps/ripple/sign_tx.py @@ -34,7 +34,7 @@ async def sign_tx(ctx, msg: RippleSignTx, keychain): signature = ecdsa_sign(node.private_key(), first_half_of_sha512(to_sign)) tx = serialize(msg, source_address, pubkey=node.public_key(), signature=signature) - return RippleSignedTx(signature, tx) + return RippleSignedTx(signature=signature, serialized_tx=tx) def check_fee(fee: int): diff --git a/core/src/apps/stellar/sign_tx.py b/core/src/apps/stellar/sign_tx.py index bd5747365..21f3fa63f 100644 --- a/core/src/apps/stellar/sign_tx.py +++ b/core/src/apps/stellar/sign_tx.py @@ -37,7 +37,7 @@ async def sign_tx(ctx, msg: StellarSignTx, keychain): signature = ed25519.sign(node.private_key(), digest) # Add the public key for verification that the right account was used for signing - return StellarSignedTx(pubkey, signature) + return StellarSignedTx(public_key=pubkey, signature=signature) async def _final(ctx, w: bytearray, msg: StellarSignTx): diff --git a/core/src/apps/webauthn/list_resident_credentials.py b/core/src/apps/webauthn/list_resident_credentials.py index 77c5ca609..3bf3cfac4 100644 --- a/core/src/apps/webauthn/list_resident_credentials.py +++ b/core/src/apps/webauthn/list_resident_credentials.py @@ -38,4 +38,4 @@ async def list_resident_credentials( ) for cred in resident_credentials.find_all() ] - return WebAuthnCredentials(creds) + return WebAuthnCredentials(credentials=creds) diff --git a/core/src/trezor/crypto/bech32.py b/core/src/trezor/crypto/bech32.py index 826dec678..f809c3031 100644 --- a/core/src/trezor/crypto/bech32.py +++ b/core/src/trezor/crypto/bech32.py @@ -21,7 +21,13 @@ """Reference implementation for Bech32 and segwit addresses.""" if False: - from typing import Iterable, List, Optional, Tuple + from typing import Iterable, List, Optional, Tuple, Union, TypeVar + + A = TypeVar("A") + B = TypeVar("B") + # usage: OptionalTuple[int, List[int]] is either (None, None) or (someint, somelist) + # but not (None, somelist) + OptionalTuple = Union[Tuple[None, None], Tuple[A, B]] CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" @@ -61,9 +67,7 @@ def bech32_encode(hrp: str, data: List[int]) -> str: return hrp + "1" + "".join([CHARSET[d] for d in combined]) -def bech32_decode( - bech: str, max_bech_len: int = 90 -) -> Tuple[Optional[str], Optional[List[int]]]: +def bech32_decode(bech: str, max_bech_len: int = 90) -> OptionalTuple[str, List[int]]: """Validate a Bech32 string, and determine HRP and data.""" if (any(ord(x) < 33 or ord(x) > 126 for x in bech)) or ( bech.lower() != bech and bech.upper() != bech @@ -107,7 +111,7 @@ def convertbits( return ret -def decode(hrp: str, addr: str) -> Tuple[Optional[int], Optional[List[int]]]: +def decode(hrp: str, addr: str) -> OptionalTuple[int, List[int]]: """Decode a segwit address.""" hrpgot, data = bech32_decode(addr) if data is None or hrpgot != hrp: