diff --git a/core/src/apps/base.py b/core/src/apps/base.py index e3b73efa3..c707662bd 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -1,23 +1,25 @@ import storage.cache import storage.device from trezor import config, utils, wire, workflow -from trezor.messages import MessageType -from trezor.messages.Success import Success +from trezor.enums import MessageType +from trezor.messages import Success from . import workflow_handlers if False: - import protobuf + from trezor import protobuf from typing import NoReturn - from trezor.messages.Features import Features - from trezor.messages.Initialize import Initialize - from trezor.messages.EndSession import EndSession - from trezor.messages.GetFeatures import GetFeatures - from trezor.messages.Cancel import Cancel - from trezor.messages.LockDevice import LockDevice - from trezor.messages.Ping import Ping - from trezor.messages.DoPreauthorized import DoPreauthorized - from trezor.messages.CancelAuthorization import CancelAuthorization + from trezor.messages import ( + Features, + Initialize, + EndSession, + GetFeatures, + Cancel, + LockDevice, + Ping, + DoPreauthorized, + CancelAuthorization, + ) def get_features() -> Features: @@ -25,8 +27,8 @@ def get_features() -> Features: import storage.sd_salt from trezor import sdcard - from trezor.messages import Capability - from trezor.messages.Features import Features + from trezor.enums import Capability + from trezor.messages import Features from apps.common import mnemonic, safety_checks @@ -125,16 +127,16 @@ async def handle_EndSession(ctx: wire.Context, msg: EndSession) -> Success: async def handle_Ping(ctx: wire.Context, msg: Ping) -> Success: if msg.button_protection: from trezor.ui.layouts import confirm_action - from trezor.messages.ButtonRequestType import ProtectCall + from trezor.enums import ButtonRequestType as B - await confirm_action(ctx, "ping", "Confirm", "ping", br_code=ProtectCall) + await confirm_action(ctx, "ping", "Confirm", "ping", br_code=B.ProtectCall) return Success(message=msg.message) async def handle_DoPreauthorized( ctx: wire.Context, msg: DoPreauthorized ) -> protobuf.MessageType: - from trezor.messages.PreauthorizedRequest import PreauthorizedRequest + from trezor.messages import PreauthorizedRequest from apps.common import authorization if not authorization.is_set(): diff --git a/core/src/apps/binance/get_address.py b/core/src/apps/binance/get_address.py index b9bd5e1eb..d885fbff5 100644 --- a/core/src/apps/binance/get_address.py +++ b/core/src/apps/binance/get_address.py @@ -1,5 +1,4 @@ -from trezor.messages.BinanceAddress import BinanceAddress -from trezor.messages.BinanceGetAddress import BinanceGetAddress +from trezor.messages import BinanceAddress, BinanceGetAddress from trezor.ui.layouts import show_address from apps.common import paths diff --git a/core/src/apps/binance/get_public_key.py b/core/src/apps/binance/get_public_key.py index b62a99d1e..54735a66f 100644 --- a/core/src/apps/binance/get_public_key.py +++ b/core/src/apps/binance/get_public_key.py @@ -1,7 +1,6 @@ from ubinascii import hexlify -from trezor.messages.BinanceGetPublicKey import BinanceGetPublicKey -from trezor.messages.BinancePublicKey import BinancePublicKey +from trezor.messages import BinanceGetPublicKey, BinancePublicKey from trezor.ui.layouts import show_pubkey from apps.common import paths diff --git a/core/src/apps/binance/helpers.py b/core/src/apps/binance/helpers.py index bd0cdda73..dad3fe496 100644 --- a/core/src/apps/binance/helpers.py +++ b/core/src/apps/binance/helpers.py @@ -2,11 +2,13 @@ from micropython import const from trezor.crypto import bech32 from trezor.crypto.scripts import sha256_ripemd160_digest -from trezor.messages.BinanceCancelMsg import BinanceCancelMsg -from trezor.messages.BinanceInputOutput import BinanceInputOutput -from trezor.messages.BinanceOrderMsg import BinanceOrderMsg -from trezor.messages.BinanceSignTx import BinanceSignTx -from trezor.messages.BinanceTransferMsg import BinanceTransferMsg +from trezor.messages import ( + BinanceCancelMsg, + BinanceInputOutput, + BinanceOrderMsg, + BinanceSignTx, + BinanceTransferMsg, +) ENVELOPE_BLUEPRINT = '{{"account_number":"{account_number}","chain_id":"{chain_id}","data":null,"memo":"{memo}","msgs":[{msgs}],"sequence":"{sequence}","source":"{source}"}}' MSG_TRANSFER_BLUEPRINT = '{{"inputs":[{inputs}],"outputs":[{outputs}]}}' @@ -20,11 +22,11 @@ DECIMALS = const(8) def produce_json_for_signing(envelope: BinanceSignTx, msg) -> str: - if isinstance(msg, BinanceTransferMsg): + if BinanceTransferMsg.is_type_of(msg): json_msg = produce_transfer_json(msg) - elif isinstance(msg, BinanceOrderMsg): + elif BinanceOrderMsg.is_type_of(msg): json_msg = produce_neworder_json(msg) - elif isinstance(msg, BinanceCancelMsg): + elif BinanceCancelMsg.is_type_of(msg): json_msg = produce_cancel_json(msg) else: raise ValueError("input message unrecognized, is of type " + type(msg).__name__) diff --git a/core/src/apps/binance/layout.py b/core/src/apps/binance/layout.py index 4fd5c7c63..e68e37d32 100644 --- a/core/src/apps/binance/layout.py +++ b/core/src/apps/binance/layout.py @@ -1,11 +1,10 @@ from trezor import ui +from trezor.enums import BinanceOrderSide, ButtonRequestType from trezor.messages import ( BinanceCancelMsg, BinanceInputOutput, BinanceOrderMsg, - BinanceOrderSide, BinanceTransferMsg, - ButtonRequestType, ) from trezor.strings import format_amount from trezor.ui.components.tt.scroll import Paginated diff --git a/core/src/apps/binance/sign_tx.py b/core/src/apps/binance/sign_tx.py index 07f7ba298..d400d9556 100644 --- a/core/src/apps/binance/sign_tx.py +++ b/core/src/apps/binance/sign_tx.py @@ -1,12 +1,14 @@ from trezor import wire from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha256 -from trezor.messages import MessageType -from trezor.messages.BinanceCancelMsg import BinanceCancelMsg -from trezor.messages.BinanceOrderMsg import BinanceOrderMsg -from trezor.messages.BinanceSignedTx import BinanceSignedTx -from trezor.messages.BinanceTransferMsg import BinanceTransferMsg -from trezor.messages.BinanceTxRequest import BinanceTxRequest +from trezor.enums import MessageType +from trezor.messages import ( + BinanceCancelMsg, + BinanceOrderMsg, + BinanceSignedTx, + BinanceTransferMsg, + BinanceTxRequest, +) from apps.common import paths from apps.common.keychain import Keychain, auto_keychain @@ -37,11 +39,11 @@ async def sign_tx(ctx, envelope, keychain: Keychain): msg_json = helpers.produce_json_for_signing(envelope, msg) - if isinstance(msg, BinanceTransferMsg): + if BinanceTransferMsg.is_type_of(msg): await layout.require_confirm_transfer(ctx, msg) - elif isinstance(msg, BinanceOrderMsg): + elif BinanceOrderMsg.is_type_of(msg): await layout.require_confirm_order(ctx, msg) - elif isinstance(msg, BinanceCancelMsg): + elif BinanceCancelMsg.is_type_of(msg): await layout.require_confirm_cancel(ctx, msg) else: raise ValueError("input message unrecognized, is of type " + type(msg).__name__) diff --git a/core/src/apps/bitcoin/addresses.py b/core/src/apps/bitcoin/addresses.py index 166f51675..de7a400eb 100644 --- a/core/src/apps/bitcoin/addresses.py +++ b/core/src/apps/bitcoin/addresses.py @@ -1,8 +1,8 @@ from trezor import wire from trezor.crypto import base58, cashaddr from trezor.crypto.hashlib import sha256 -from trezor.messages import InputScriptType -from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType +from trezor.enums import InputScriptType +from trezor.messages import MultisigRedeemScriptType from apps.common import address_type from apps.common.coininfo import CoinInfo @@ -13,11 +13,10 @@ from .scripts import output_script_multisig, output_script_native_p2wpkh_or_p2ws if False: from trezor.crypto import bip32 - from trezor.messages.TxInputType import EnumTypeInputScriptType def get_address( - script_type: EnumTypeInputScriptType, + script_type: InputScriptType, coin: CoinInfo, node: bip32.HDNode, multisig: MultisigRedeemScriptType | None = None, diff --git a/core/src/apps/bitcoin/authorization.py b/core/src/apps/bitcoin/authorization.py index cebcc48ef..4a360fc53 100644 --- a/core/src/apps/bitcoin/authorization.py +++ b/core/src/apps/bitcoin/authorization.py @@ -1,17 +1,19 @@ from micropython import const from trezor import wire -from trezor.messages.AuthorizeCoinJoin import AuthorizeCoinJoin +from trezor.messages import AuthorizeCoinJoin from apps.common import authorization from .common import BIP32_WALLET_DEPTH if False: - import protobuf - from trezor.messages.GetOwnershipProof import GetOwnershipProof - from trezor.messages.SignTx import SignTx - from trezor.messages.TxInput import TxInput + from trezor.messages import ( + GetOwnershipProof, + SignTx, + TxInput, + ) + from trezor.protobuf import MessageType from apps.common.coininfo import CoinInfo @@ -52,8 +54,8 @@ class CoinJoinAuthorization: return True -def from_cached_message(auth_msg: protobuf.MessageType) -> CoinJoinAuthorization: - if not isinstance(auth_msg, AuthorizeCoinJoin): +def from_cached_message(auth_msg: MessageType) -> CoinJoinAuthorization: + if not AuthorizeCoinJoin.is_type_of(auth_msg): raise wire.ProcessError("Appropriate params was not found") return CoinJoinAuthorization(auth_msg) diff --git a/core/src/apps/bitcoin/authorize_coinjoin.py b/core/src/apps/bitcoin/authorize_coinjoin.py index 03277dcc3..31be154c8 100644 --- a/core/src/apps/bitcoin/authorize_coinjoin.py +++ b/core/src/apps/bitcoin/authorize_coinjoin.py @@ -1,8 +1,7 @@ from micropython import const -from trezor import ui, wire -from trezor.messages.AuthorizeCoinJoin import AuthorizeCoinJoin -from trezor.messages.Success import Success +from trezor import ui +from trezor.messages import AuthorizeCoinJoin, Success from trezor.strings import format_amount from trezor.ui.layouts import confirm_action, confirm_coinjoin @@ -15,6 +14,7 @@ from .keychain import validate_path_against_script_type, with_keychain from .sign_tx.layout import format_coin_amount if False: + from trezor import wire from apps.common.coininfo import CoinInfo from apps.common.keychain import Keychain diff --git a/core/src/apps/bitcoin/common.py b/core/src/apps/bitcoin/common.py index 2a989bc22..cc81c220f 100644 --- a/core/src/apps/bitcoin/common.py +++ b/core/src/apps/bitcoin/common.py @@ -3,13 +3,12 @@ from micropython import const from trezor import wire from trezor.crypto import bech32, bip32, der from trezor.crypto.curve import secp256k1 -from trezor.messages import InputScriptType, OutputScriptType +from trezor.enums import InputScriptType, OutputScriptType from trezor.utils import ensure if False: from apps.common.coininfo import CoinInfo - from trezor.messages.TxInput import EnumTypeInputScriptType, TxInput - from trezor.messages.TxOutput import EnumTypeOutputScriptType + from trezor.messages import TxInput BITCOIN_NAMES = ("Bitcoin", "Regtest", "Testnet") @@ -34,9 +33,7 @@ MULTISIG_OUTPUT_SCRIPT_TYPES = ( OutputScriptType.PAYTOWITNESS, ) -CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES: dict[ - EnumTypeOutputScriptType, EnumTypeInputScriptType -] = { +CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES: dict[OutputScriptType, InputScriptType] = { OutputScriptType.PAYTOADDRESS: InputScriptType.SPENDADDRESS, OutputScriptType.PAYTOMULTISIG: InputScriptType.SPENDMULTISIG, OutputScriptType.PAYTOP2SHWITNESS: InputScriptType.SPENDP2SHWITNESS, diff --git a/core/src/apps/bitcoin/get_address.py b/core/src/apps/bitcoin/get_address.py index 9dfd5b86e..fd2709803 100644 --- a/core/src/apps/bitcoin/get_address.py +++ b/core/src/apps/bitcoin/get_address.py @@ -1,6 +1,6 @@ from trezor.crypto import bip32 -from trezor.messages import InputScriptType -from trezor.messages.Address import Address +from trezor.enums import InputScriptType +from trezor.messages import Address from trezor.ui.layouts import show_address from apps.common.layout import address_n_to_str @@ -11,8 +11,8 @@ from .keychain import validate_path_against_script_type, with_keychain from .multisig import multisig_pubkey_index if False: - from trezor.messages.GetAddress import GetAddress - from trezor.messages.HDNodeType import HDNodeType + from trezor.messages import GetAddress + from trezor.messages import HDNodeType from trezor import wire from apps.common.keychain import Keychain from apps.common.coininfo import CoinInfo diff --git a/core/src/apps/bitcoin/get_ownership_id.py b/core/src/apps/bitcoin/get_ownership_id.py index 97c426866..479dbd05f 100644 --- a/core/src/apps/bitcoin/get_ownership_id.py +++ b/core/src/apps/bitcoin/get_ownership_id.py @@ -1,6 +1,5 @@ from trezor import wire -from trezor.messages.GetOwnershipId import GetOwnershipId -from trezor.messages.OwnershipId import OwnershipId +from trezor.messages import GetOwnershipId, OwnershipId from apps.common.paths import validate_path diff --git a/core/src/apps/bitcoin/get_ownership_proof.py b/core/src/apps/bitcoin/get_ownership_proof.py index 06b12451b..e85311d62 100644 --- a/core/src/apps/bitcoin/get_ownership_proof.py +++ b/core/src/apps/bitcoin/get_ownership_proof.py @@ -1,8 +1,7 @@ from ubinascii import hexlify from trezor import ui, wire -from trezor.messages.GetOwnershipProof import GetOwnershipProof -from trezor.messages.OwnershipProof import OwnershipProof +from trezor.messages import GetOwnershipProof, OwnershipProof from trezor.ui.layouts import confirm_action, confirm_hex from apps.common.paths import validate_path diff --git a/core/src/apps/bitcoin/get_public_key.py b/core/src/apps/bitcoin/get_public_key.py index e87b04a30..2d4b27e16 100644 --- a/core/src/apps/bitcoin/get_public_key.py +++ b/core/src/apps/bitcoin/get_public_key.py @@ -1,13 +1,12 @@ from trezor import wire -from trezor.messages import InputScriptType -from trezor.messages.HDNodeType import HDNodeType -from trezor.messages.PublicKey import PublicKey +from trezor.enums import InputScriptType +from trezor.messages import HDNodeType, PublicKey from apps.common import coininfo, paths from apps.common.keychain import get_keychain if False: - from trezor.messages.GetPublicKey import GetPublicKey + from trezor.messages import GetPublicKey async def get_public_key(ctx: wire.Context, msg: GetPublicKey) -> PublicKey: diff --git a/core/src/apps/bitcoin/keychain.py b/core/src/apps/bitcoin/keychain.py index 8078ae06c..75ca1071c 100644 --- a/core/src/apps/bitcoin/keychain.py +++ b/core/src/apps/bitcoin/keychain.py @@ -1,7 +1,7 @@ import gc from trezor import wire -from trezor.messages import InputScriptType as I +from trezor.enums import InputScriptType from apps.common import coininfo from apps.common.keychain import get_keychain @@ -14,9 +14,7 @@ if False: from typing import Awaitable, Callable, Iterable, TypeVar from typing_extensions import Protocol - from protobuf import MessageType - - from trezor.messages.TxInputType import EnumTypeInputScriptType + from trezor.protobuf import MessageType from apps.common.keychain import Keychain, MsgOut, Handler from apps.common.paths import Bip32Path @@ -27,7 +25,7 @@ if False: class MsgWithAddressScriptType(Protocol): # XXX should be Bip32Path but that fails address_n: list[int] = ... - script_type: EnumTypeInputScriptType = ... + script_type: InputScriptType = ... MsgIn = TypeVar("MsgIn", bound=MsgWithCoinName) HandlerWithCoinInfo = Callable[..., Awaitable[MsgOut]] @@ -68,7 +66,7 @@ def validate_path_against_script_type( coin: coininfo.CoinInfo, msg: MsgWithAddressScriptType | None = None, address_n: Bip32Path | None = None, - script_type: EnumTypeInputScriptType | None = None, + script_type: InputScriptType | None = None, multisig: bool = False, ) -> bool: patterns = [] @@ -76,19 +74,22 @@ def validate_path_against_script_type( if msg is not None: assert address_n is None and script_type is None address_n = msg.address_n - script_type = msg.script_type or I.SPENDADDRESS + script_type = msg.script_type or InputScriptType.SPENDADDRESS multisig = bool(getattr(msg, "multisig", False)) else: assert address_n is not None and script_type is not None - if script_type == I.SPENDADDRESS and not multisig: + if script_type == InputScriptType.SPENDADDRESS and not multisig: patterns.append(PATTERN_BIP44) if coin.coin_name in BITCOIN_NAMES: patterns.append(PATTERN_GREENADDRESS_A) patterns.append(PATTERN_GREENADDRESS_B) - elif script_type in (I.SPENDADDRESS, I.SPENDMULTISIG) and multisig: + elif ( + script_type in (InputScriptType.SPENDADDRESS, InputScriptType.SPENDMULTISIG) + and multisig + ): patterns.append(PATTERN_BIP45) patterns.append(PATTERN_PURPOSE48_RAW) if coin.coin_name in BITCOIN_NAMES: @@ -98,7 +99,7 @@ def validate_path_against_script_type( patterns.append(PATTERN_UNCHAINED_UNHARDENED) patterns.append(PATTERN_UNCHAINED_DEPRECATED) - elif coin.segwit and script_type == I.SPENDP2SHWITNESS: + elif coin.segwit and script_type == InputScriptType.SPENDP2SHWITNESS: patterns.append(PATTERN_BIP49) if multisig: patterns.append(PATTERN_PURPOSE48_P2SHSEGWIT) @@ -107,7 +108,7 @@ def validate_path_against_script_type( patterns.append(PATTERN_GREENADDRESS_B) patterns.append(PATTERN_CASA) - elif coin.segwit and script_type == I.SPENDWITNESS: + elif coin.segwit and script_type == InputScriptType.SPENDWITNESS: patterns.append(PATTERN_BIP84) if multisig: patterns.append(PATTERN_PURPOSE48_SEGWIT) diff --git a/core/src/apps/bitcoin/multisig.py b/core/src/apps/bitcoin/multisig.py index 59cb80363..b3ba48e98 100644 --- a/core/src/apps/bitcoin/multisig.py +++ b/core/src/apps/bitcoin/multisig.py @@ -1,8 +1,7 @@ from trezor import wire from trezor.crypto import bip32 from trezor.crypto.hashlib import sha256 -from trezor.messages.HDNodeType import HDNodeType -from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType +from trezor.messages import HDNodeType, MultisigRedeemScriptType from trezor.utils import HashWriter from apps.common import paths diff --git a/core/src/apps/bitcoin/ownership.py b/core/src/apps/bitcoin/ownership.py index 793d6023e..cbf5907b9 100644 --- a/core/src/apps/bitcoin/ownership.py +++ b/core/src/apps/bitcoin/ownership.py @@ -10,8 +10,8 @@ from .scripts import read_bip322_signature_proof, write_bip322_signature_proof from .verification import SignatureVerifier if False: - from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType - from trezor.messages.TxInputType import EnumTypeInputScriptType + from trezor.enums import InputScriptType + from trezor.messages import MultisigRedeemScriptType from apps.common.coininfo import CoinInfo # This module implements the SLIP-0019 proof of ownership format, see @@ -26,7 +26,7 @@ _OWNERSHIP_ID_KEY_PATH = [b"SLIP-0019", b"Ownership identification key"] def generate_proof( node: bip32.HDNode, - script_type: EnumTypeInputScriptType, + script_type: InputScriptType, multisig: MultisigRedeemScriptType | None, coin: CoinInfo, user_confirmed: bool, diff --git a/core/src/apps/bitcoin/scripts.py b/core/src/apps/bitcoin/scripts.py index 4fdeaf946..7b25e42c8 100644 --- a/core/src/apps/bitcoin/scripts.py +++ b/core/src/apps/bitcoin/scripts.py @@ -1,7 +1,7 @@ from trezor import utils, wire from trezor.crypto import base58, cashaddr from trezor.crypto.hashlib import sha256 -from trezor.messages import InputScriptType +from trezor.enums import InputScriptType from apps.common import address_type from apps.common.readers import read_bitcoin_varint @@ -22,9 +22,7 @@ from .writers import ( ) if False: - from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType - from trezor.messages.TxInput import TxInput - from trezor.messages.TxInput import EnumTypeInputScriptType + from trezor.messages import MultisigRedeemScriptType, TxInput from apps.common.coininfo import CoinInfo @@ -32,7 +30,7 @@ if False: def input_derive_script( - script_type: EnumTypeInputScriptType, + script_type: InputScriptType, multisig: MultisigRedeemScriptType | None, coin: CoinInfo, hash_type: int, @@ -521,7 +519,7 @@ def output_script_paytoopreturn(data: bytes) -> bytearray: def write_bip322_signature_proof( w: Writer, - script_type: EnumTypeInputScriptType, + script_type: InputScriptType, multisig: MultisigRedeemScriptType | None, coin: CoinInfo, public_key: bytes, diff --git a/core/src/apps/bitcoin/scripts_decred.py b/core/src/apps/bitcoin/scripts_decred.py index 2782ea679..6befe1c54 100644 --- a/core/src/apps/bitcoin/scripts_decred.py +++ b/core/src/apps/bitcoin/scripts_decred.py @@ -1,7 +1,7 @@ from trezor import utils, wire from trezor.crypto import base58 from trezor.crypto.base58 import blake256d_32 -from trezor.messages import InputScriptType +from trezor.enums import InputScriptType from apps.common.writers import write_bytes_fixed, write_uint64_le @@ -15,14 +15,13 @@ from .scripts import ( # noqa: F401 from .writers import write_op_push if False: - from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType - from trezor.messages.TxInput import EnumTypeInputScriptType + from trezor.messages import MultisigRedeemScriptType from apps.common.coininfo import CoinInfo def input_derive_script( - script_type: EnumTypeInputScriptType, + script_type: InputScriptType, multisig: MultisigRedeemScriptType | None, coin: CoinInfo, hash_type: int, diff --git a/core/src/apps/bitcoin/sign_message.py b/core/src/apps/bitcoin/sign_message.py index 8eb17a1a5..7dd2e0c5d 100644 --- a/core/src/apps/bitcoin/sign_message.py +++ b/core/src/apps/bitcoin/sign_message.py @@ -1,7 +1,7 @@ from trezor import wire from trezor.crypto.curve import secp256k1 -from trezor.messages.InputScriptType import SPENDADDRESS, SPENDP2SHWITNESS, SPENDWITNESS -from trezor.messages.MessageSignature import MessageSignature +from trezor.enums import InputScriptType +from trezor.messages import MessageSignature from trezor.ui.layouts import confirm_signverify from apps.common.paths import validate_path @@ -11,7 +11,7 @@ from .addresses import get_address from .keychain import with_keychain if False: - from trezor.messages.SignMessage import SignMessage + from trezor.messages import SignMessage from apps.common.coininfo import CoinInfo from apps.common.keychain import Keychain @@ -23,7 +23,7 @@ async def sign_message( ) -> MessageSignature: message = msg.message address_n = msg.address_n - script_type = msg.script_type or 0 + script_type = msg.script_type or InputScriptType.SPENDADDRESS await validate_path(ctx, keychain, address_n) await confirm_signverify(ctx, coin.coin_shortcut, decode_message(message)) @@ -35,11 +35,11 @@ async def sign_message( digest = message_digest(coin, message) signature = secp256k1.sign(seckey, digest) - if script_type == SPENDADDRESS: + if script_type == InputScriptType.SPENDADDRESS: pass - elif script_type == SPENDP2SHWITNESS: + elif script_type == InputScriptType.SPENDP2SHWITNESS: signature = bytes([signature[0] + 4]) + signature[1:] - elif script_type == SPENDWITNESS: + elif script_type == InputScriptType.SPENDWITNESS: signature = bytes([signature[0] + 8]) + signature[1:] else: raise wire.ProcessError("Unsupported script type") diff --git a/core/src/apps/bitcoin/sign_tx/__init__.py b/core/src/apps/bitcoin/sign_tx/__init__.py index 39b880f87..0eb522b30 100644 --- a/core/src/apps/bitcoin/sign_tx/__init__.py +++ b/core/src/apps/bitcoin/sign_tx/__init__.py @@ -1,15 +1,6 @@ -import gc - from trezor import utils, wire -from trezor.messages.RequestType import TXFINISHED -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckPrevExtraData import TxAckPrevExtraData -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxRequest import TxRequest +from trezor.enums import RequestType +from trezor.messages import TxRequest from ..common import BITCOIN_NAMES from ..keychain import with_keychain @@ -21,7 +12,15 @@ if not utils.BITCOIN_ONLY: if False: from typing import Protocol, Union - from protobuf import FieldCache + from trezor.messages import ( + SignTx, + TxAckInput, + TxAckOutput, + TxAckPrevMeta, + TxAckPrevInput, + TxAckPrevOutput, + TxAckPrevExtraData, + ) from apps.common.coininfo import CoinInfo from apps.common.keychain import Keychain @@ -76,26 +75,14 @@ async def sign_tx( signer = signer_class(msg, keychain, coin, approver).signer() res: TxAckType | bool | None = None - - gc.collect() - field_cache: FieldCache = {} - TxRequest.cache_subordinate_types(field_cache) - SignTx.cache_subordinate_types(field_cache) - TxAckInput.cache_subordinate_types(field_cache) - TxAckOutput.cache_subordinate_types(field_cache) - TxAckPrevExtraData.cache_subordinate_types(field_cache) - TxAckPrevInput.cache_subordinate_types(field_cache) - TxAckPrevMeta.cache_subordinate_types(field_cache) - TxAckPrevOutput.cache_subordinate_types(field_cache) - while True: req = signer.send(res) if isinstance(req, tuple): request_class, req = req - assert isinstance(req, TxRequest) - if req.request_type == TXFINISHED: + assert TxRequest.is_type_of(req) + if req.request_type == RequestType.TXFINISHED: return req - res = await ctx.call(req, request_class, field_cache) + res = await ctx.call(req, request_class) elif isinstance(req, helpers.UiConfirm): res = await req.confirm_dialog(ctx) progress.report_init() diff --git a/core/src/apps/bitcoin/sign_tx/approvers.py b/core/src/apps/bitcoin/sign_tx/approvers.py index 757bd0ba5..56b67293d 100644 --- a/core/src/apps/bitcoin/sign_tx/approvers.py +++ b/core/src/apps/bitcoin/sign_tx/approvers.py @@ -1,7 +1,7 @@ from micropython import const from trezor import wire -from trezor.messages import OutputScriptType +from trezor.enums import OutputScriptType from apps.common import safety_checks @@ -11,9 +11,9 @@ from . import helpers, tx_weight from .tx_info import OriginalTxInfo, TxInfo if False: - from trezor.messages.SignTx import SignTx - from trezor.messages.TxInput import TxInput - from trezor.messages.TxOutput import TxOutput + from trezor.messages import SignTx + from trezor.messages import TxInput + from trezor.messages import TxOutput from apps.common.coininfo import CoinInfo diff --git a/core/src/apps/bitcoin/sign_tx/bitcoin.py b/core/src/apps/bitcoin/sign_tx/bitcoin.py index bcf4e4780..3b03d02cc 100644 --- a/core/src/apps/bitcoin/sign_tx/bitcoin.py +++ b/core/src/apps/bitcoin/sign_tx/bitcoin.py @@ -2,10 +2,8 @@ from micropython import const from trezor import wire from trezor.crypto.hashlib import sha256 -from trezor.messages import InputScriptType, OutputScriptType -from trezor.messages.TxRequest import TxRequest -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType +from trezor.enums import InputScriptType, OutputScriptType +from trezor.messages import TxRequest, TxRequestDetailsType, TxRequestSerializedType from trezor.utils import HashWriter, empty_bytearray, ensure from apps.common.writers import write_bitcoin_varint @@ -21,12 +19,14 @@ from .tx_info import OriginalTxInfo, TxInfo if False: from trezor.crypto import bip32 - from trezor.messages.SignTx import SignTx - from trezor.messages.TxInput import TxInput - from trezor.messages.TxOutput import TxOutput - from trezor.messages.PrevTx import PrevTx - from trezor.messages.PrevInput import PrevInput - from trezor.messages.PrevOutput import PrevOutput + from trezor.messages import ( + PrevInput, + PrevOutput, + PrevTx, + SignTx, + TxInput, + TxOutput, + ) from apps.common.coininfo import CoinInfo from apps.common.keychain import Keychain diff --git a/core/src/apps/bitcoin/sign_tx/bitcoinlike.py b/core/src/apps/bitcoin/sign_tx/bitcoinlike.py index 1f25a39a5..9f10a9c70 100644 --- a/core/src/apps/bitcoin/sign_tx/bitcoinlike.py +++ b/core/src/apps/bitcoin/sign_tx/bitcoinlike.py @@ -1,9 +1,7 @@ from micropython import const from trezor import wire -from trezor.messages.PrevTx import PrevTx -from trezor.messages.SignTx import SignTx -from trezor.messages.TxInput import TxInput +from trezor.messages import PrevTx, SignTx, TxInput from apps.common.writers import write_bitcoin_varint diff --git a/core/src/apps/bitcoin/sign_tx/decred.py b/core/src/apps/bitcoin/sign_tx/decred.py index d13b50813..2751b63d7 100644 --- a/core/src/apps/bitcoin/sign_tx/decred.py +++ b/core/src/apps/bitcoin/sign_tx/decred.py @@ -2,8 +2,8 @@ from micropython import const from trezor import wire from trezor.crypto.hashlib import blake256 -from trezor.messages import DecredStakingSpendType, InputScriptType -from trezor.messages.PrevOutput import PrevOutput +from trezor.enums import DecredStakingSpendType, InputScriptType +from trezor.messages import PrevOutput from trezor.utils import HashWriter, ensure from apps.common.writers import write_bitcoin_varint @@ -24,11 +24,13 @@ OUTPUT_SCRIPT_NULL_SSTXCHANGE = ( ) if False: - from trezor.messages.SignTx import SignTx - from trezor.messages.TxInput import TxInput - from trezor.messages.TxOutput import TxOutput - from trezor.messages.PrevTx import PrevTx - from trezor.messages.PrevInput import PrevInput + from trezor.messages import ( + SignTx, + TxInput, + TxOutput, + PrevTx, + PrevInput, + ) from apps.common.coininfo import CoinInfo from apps.common.keychain import Keychain @@ -226,7 +228,7 @@ class Decred(Bitcoin): script_pubkey: bytes, ) -> None: writers.write_uint64(w, txo.amount) - if isinstance(txo, PrevOutput): + if PrevOutput.is_type_of(txo): if txo.decred_script_version is None: raise wire.DataError("Script version must be provided") writers.write_uint16(w, txo.decred_script_version) diff --git a/core/src/apps/bitcoin/sign_tx/hash143.py b/core/src/apps/bitcoin/sign_tx/hash143.py index 5ea4338a9..70c0dba1f 100644 --- a/core/src/apps/bitcoin/sign_tx/hash143.py +++ b/core/src/apps/bitcoin/sign_tx/hash143.py @@ -1,8 +1,5 @@ from trezor.crypto.hashlib import sha256 -from trezor.messages.PrevTx import PrevTx -from trezor.messages.SignTx import SignTx -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput +from trezor.messages import PrevTx, SignTx, TxInput, TxOutput from trezor.utils import HashWriter from apps.common import coininfo diff --git a/core/src/apps/bitcoin/sign_tx/helpers.py b/core/src/apps/bitcoin/sign_tx/helpers.py index 667975a11..0f17f54f5 100644 --- a/core/src/apps/bitcoin/sign_tx/helpers.py +++ b/core/src/apps/bitcoin/sign_tx/helpers.py @@ -1,27 +1,20 @@ from trezor import utils, wire -from trezor.messages import InputScriptType, OutputScriptType -from trezor.messages.PrevInput import PrevInput -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.PrevTx import PrevTx -from trezor.messages.RequestType import ( - TXEXTRADATA, - TXFINISHED, - TXINPUT, - TXMETA, - TXORIGINPUT, - TXORIGOUTPUT, - TXOUTPUT, +from trezor.enums import InputScriptType, OutputScriptType, RequestType +from trezor.messages import ( + PrevInput, + PrevOutput, + PrevTx, + SignTx, + TxAckInput, + TxAckOutput, + TxAckPrevExtraData, + TxAckPrevInput, + TxAckPrevMeta, + TxAckPrevOutput, + TxInput, + TxOutput, + TxRequest, ) -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckPrevExtraData import TxAckPrevExtraData -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxRequest import TxRequest from apps.common import paths from apps.common.coininfo import CoinInfo @@ -32,7 +25,7 @@ from . import layout if False: from typing import Any, Awaitable - from trezor.messages.SignTx import EnumTypeAmountUnit + from trezor.enums import AmountUnit # Machine instructions @@ -45,9 +38,7 @@ class UiConfirm: class UiConfirmOutput(UiConfirm): - def __init__( - self, output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit - ): + def __init__(self, output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit): self.output = output self.coin = coin self.amount_unit = amount_unit @@ -59,9 +50,7 @@ class UiConfirmOutput(UiConfirm): class UiConfirmDecredSSTXSubmission(UiConfirm): - def __init__( - self, output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit - ): + def __init__(self, output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit): self.output = output self.coin = coin self.amount_unit = amount_unit @@ -91,7 +80,7 @@ class UiConfirmModifyOutput(UiConfirm): txo: TxOutput, orig_txo: TxOutput, coin: CoinInfo, - amount_unit: EnumTypeAmountUnit, + amount_unit: AmountUnit, ): self.txo = txo self.orig_txo = orig_txo @@ -112,7 +101,7 @@ class UiConfirmModifyFee(UiConfirm): user_fee_change: int, total_fee_new: int, coin: CoinInfo, - amount_unit: EnumTypeAmountUnit, + amount_unit: AmountUnit, ): self.user_fee_change = user_fee_change self.total_fee_new = total_fee_new @@ -129,7 +118,7 @@ class UiConfirmModifyFee(UiConfirm): class UiConfirmTotal(UiConfirm): def __init__( - self, spending: int, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit + self, spending: int, fee: int, coin: CoinInfo, amount_unit: AmountUnit ): self.spending = spending self.fee = fee @@ -146,7 +135,7 @@ class UiConfirmTotal(UiConfirm): class UiConfirmJointTotal(UiConfirm): def __init__( - self, spending: int, total: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit + self, spending: int, total: int, coin: CoinInfo, amount_unit: AmountUnit ): self.spending = spending self.total = total @@ -162,7 +151,7 @@ class UiConfirmJointTotal(UiConfirm): class UiConfirmFeeOverThreshold(UiConfirm): - def __init__(self, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit): + def __init__(self, fee: int, coin: CoinInfo, amount_unit: AmountUnit): self.fee = fee self.coin = coin self.amount_unit = amount_unit @@ -208,11 +197,11 @@ class UiConfirmNonDefaultLocktime(UiConfirm): __eq__ = utils.obj_eq -def confirm_output(output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[None]: # type: ignore +def confirm_output(output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[None]: # type: ignore return (yield UiConfirmOutput(output, coin, amount_unit)) -def confirm_decred_sstx_submission(output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[None]: # type: ignore +def confirm_decred_sstx_submission(output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[None]: # type: ignore return (yield UiConfirmDecredSSTXSubmission(output, coin, amount_unit)) @@ -220,23 +209,23 @@ def confirm_replacement(description: str, txid: bytes) -> Awaitable[Any]: # typ return (yield UiConfirmReplacement(description, txid)) -def confirm_modify_output(txo: TxOutput, orig_txo: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore +def confirm_modify_output(txo: TxOutput, orig_txo: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore return (yield UiConfirmModifyOutput(txo, orig_txo, coin, amount_unit)) -def confirm_modify_fee(user_fee_change: int, total_fee_new: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore +def confirm_modify_fee(user_fee_change: int, total_fee_new: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore return (yield UiConfirmModifyFee(user_fee_change, total_fee_new, coin, amount_unit)) -def confirm_total(spending: int, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[None]: # type: ignore +def confirm_total(spending: int, fee: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[None]: # type: ignore return (yield UiConfirmTotal(spending, fee, coin, amount_unit)) -def confirm_joint_total(spending: int, total: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore +def confirm_joint_total(spending: int, total: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore return (yield UiConfirmJointTotal(spending, total, coin, amount_unit)) -def confirm_feeoverthreshold(fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore +def confirm_feeoverthreshold(fee: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore return (yield UiConfirmFeeOverThreshold(fee, coin, amount_unit)) @@ -254,7 +243,7 @@ def confirm_nondefault_locktime(lock_time: int, lock_time_disabled: bool) -> Awa def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevTx]: # type: ignore assert tx_req.details is not None - tx_req.request_type = TXMETA + tx_req.request_type = RequestType.TXMETA tx_req.details.tx_hash = tx_hash ack = yield TxAckPrevMeta, tx_req _clear_tx_request(tx_req) @@ -265,7 +254,7 @@ def request_tx_extra_data( # type: ignore tx_req: TxRequest, offset: int, size: int, tx_hash: bytes | None = None ) -> Awaitable[bytearray]: assert tx_req.details is not None - tx_req.request_type = TXEXTRADATA + tx_req.request_type = RequestType.TXEXTRADATA tx_req.details.extra_data_offset = offset tx_req.details.extra_data_len = size tx_req.details.tx_hash = tx_hash @@ -277,10 +266,10 @@ def request_tx_extra_data( # type: ignore def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[TxInput]: # type: ignore assert tx_req.details is not None if tx_hash: - tx_req.request_type = TXORIGINPUT + tx_req.request_type = RequestType.TXORIGINPUT tx_req.details.tx_hash = tx_hash else: - tx_req.request_type = TXINPUT + tx_req.request_type = RequestType.TXINPUT tx_req.details.request_index = i ack = yield TxAckInput, tx_req _clear_tx_request(tx_req) @@ -289,7 +278,7 @@ def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | def request_tx_prev_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevInput]: # type: ignore assert tx_req.details is not None - tx_req.request_type = TXINPUT + tx_req.request_type = RequestType.TXINPUT tx_req.details.request_index = i tx_req.details.tx_hash = tx_hash ack = yield TxAckPrevInput, tx_req @@ -300,10 +289,10 @@ def request_tx_prev_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: by def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[TxOutput]: # type: ignore assert tx_req.details is not None if tx_hash: - tx_req.request_type = TXORIGOUTPUT + tx_req.request_type = RequestType.TXORIGOUTPUT tx_req.details.tx_hash = tx_hash else: - tx_req.request_type = TXOUTPUT + tx_req.request_type = RequestType.TXOUTPUT tx_req.details.request_index = i ack = yield TxAckOutput, tx_req _clear_tx_request(tx_req) @@ -312,7 +301,7 @@ def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes def request_tx_prev_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevOutput]: # type: ignore assert tx_req.details is not None - tx_req.request_type = TXOUTPUT + tx_req.request_type = RequestType.TXOUTPUT tx_req.details.request_index = i tx_req.details.tx_hash = tx_hash ack = yield TxAckPrevOutput, tx_req @@ -322,7 +311,7 @@ def request_tx_prev_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: b def request_tx_finish(tx_req: TxRequest) -> Awaitable[None]: # type: ignore - tx_req.request_type = TXFINISHED + tx_req.request_type = RequestType.TXFINISHED yield None, tx_req _clear_tx_request(tx_req) diff --git a/core/src/apps/bitcoin/sign_tx/layout.py b/core/src/apps/bitcoin/sign_tx/layout.py index fdb3caae7..7eea0e692 100644 --- a/core/src/apps/bitcoin/sign_tx/layout.py +++ b/core/src/apps/bitcoin/sign_tx/layout.py @@ -1,7 +1,7 @@ from micropython import const from ubinascii import hexlify -from trezor.messages import AmountUnit, ButtonRequestType, OutputScriptType +from trezor.enums import AmountUnit, ButtonRequestType, OutputScriptType from trezor.strings import format_amount from trezor.ui import layouts @@ -10,8 +10,7 @@ from . import omni if False: from trezor import wire - from trezor.messages.SignTx import EnumTypeAmountUnit - from trezor.messages.TxOutput import TxOutput + from trezor.messages import TxOutput from trezor.ui.layouts import LayoutType from apps.common.coininfo import CoinInfo @@ -19,9 +18,7 @@ if False: _LOCKTIME_TIMESTAMP_MIN_VALUE = const(500_000_000) -def format_coin_amount( - amount: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit -) -> str: +def format_coin_amount(amount: int, coin: CoinInfo, amount_unit: AmountUnit) -> str: decimals, shortcut = coin.decimals, coin.coin_shortcut if amount_unit == AmountUnit.SATOSHI: decimals = 0 @@ -37,7 +34,7 @@ def format_coin_amount( async def confirm_output( - ctx: wire.Context, output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit + ctx: wire.Context, output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit ) -> None: if output.script_type == OutputScriptType.PAYTOOPRETURN: data = output.op_return_data @@ -71,7 +68,7 @@ async def confirm_output( async def confirm_decred_sstx_submission( - ctx: wire.Context, output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit + ctx: wire.Context, output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit ) -> None: assert output.address is not None address_short = addresses.address_short(coin, output.address) @@ -94,7 +91,7 @@ async def confirm_modify_output( txo: TxOutput, orig_txo: TxOutput, coin: CoinInfo, - amount_unit: EnumTypeAmountUnit, + amount_unit: AmountUnit, ) -> None: assert txo.address is not None address_short = addresses.address_short(coin, txo.address) @@ -113,7 +110,7 @@ async def confirm_modify_fee( user_fee_change: int, total_fee_new: int, coin: CoinInfo, - amount_unit: EnumTypeAmountUnit, + amount_unit: AmountUnit, ) -> None: await layouts.confirm_modify_fee( ctx, @@ -128,7 +125,7 @@ async def confirm_joint_total( spending: int, total: int, coin: CoinInfo, - amount_unit: EnumTypeAmountUnit, + amount_unit: AmountUnit, ) -> None: await layouts.confirm_joint_total( ctx, @@ -142,7 +139,7 @@ async def confirm_total( spending: int, fee: int, coin: CoinInfo, - amount_unit: EnumTypeAmountUnit, + amount_unit: AmountUnit, ) -> None: await layouts.confirm_total( ctx, @@ -152,7 +149,7 @@ async def confirm_total( async def confirm_feeoverthreshold( - ctx: wire.Context, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit + ctx: wire.Context, fee: int, coin: CoinInfo, amount_unit: AmountUnit ) -> None: fee_amount = format_coin_amount(fee, coin, amount_unit) await layouts.confirm_metadata( diff --git a/core/src/apps/bitcoin/sign_tx/matchcheck.py b/core/src/apps/bitcoin/sign_tx/matchcheck.py index 128982a79..a75bfd939 100644 --- a/core/src/apps/bitcoin/sign_tx/matchcheck.py +++ b/core/src/apps/bitcoin/sign_tx/matchcheck.py @@ -7,8 +7,7 @@ from ..common import BIP32_WALLET_DEPTH if False: from typing import Any, Generic, TypeVar - from trezor.messages.TxInput import TxInput - from trezor.messages.TxOutput import TxOutput + from trezor.messages import TxInput, TxOutput T = TypeVar("T") else: diff --git a/core/src/apps/bitcoin/sign_tx/tx_info.py b/core/src/apps/bitcoin/sign_tx/tx_info.py index a071c809f..5ab229625 100644 --- a/core/src/apps/bitcoin/sign_tx/tx_info.py +++ b/core/src/apps/bitcoin/sign_tx/tx_info.py @@ -10,12 +10,14 @@ from .matchcheck import MultisigFingerprintChecker, WalletPathChecker if False: from typing import Protocol - from trezor.messages.SignTx import SignTx - from trezor.messages.PrevTx import PrevTx - from trezor.messages.TxInput import TxInput - from trezor.messages.TxOutput import TxOutput - from trezor.messages.PrevInput import PrevInput - from trezor.messages.PrevOutput import PrevOutput + from trezor.messages import ( + PrevInput, + PrevOutput, + PrevTx, + SignTx, + TxInput, + TxOutput, + ) from .hash143 import Hash143 from apps.common.coininfo import CoinInfo diff --git a/core/src/apps/bitcoin/sign_tx/tx_weight.py b/core/src/apps/bitcoin/sign_tx/tx_weight.py index 5996ed0ef..d6f15d31c 100644 --- a/core/src/apps/bitcoin/sign_tx/tx_weight.py +++ b/core/src/apps/bitcoin/sign_tx/tx_weight.py @@ -7,10 +7,10 @@ from micropython import const -from trezor.messages import InputScriptType +from trezor.enums import InputScriptType if False: - from trezor.messages.TxInput import TxInput + from trezor.messages import TxInput # transaction header size: 4 byte version _TXSIZE_HEADER = const(4) diff --git a/core/src/apps/bitcoin/sign_tx/zcash.py b/core/src/apps/bitcoin/sign_tx/zcash.py index e86071b06..295d3fc17 100644 --- a/core/src/apps/bitcoin/sign_tx/zcash.py +++ b/core/src/apps/bitcoin/sign_tx/zcash.py @@ -3,11 +3,8 @@ from micropython import const from trezor import wire from trezor.crypto.hashlib import blake2b -from trezor.messages import InputScriptType -from trezor.messages.PrevTx import PrevTx -from trezor.messages.SignTx import SignTx -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput +from trezor.enums import InputScriptType +from trezor.messages import PrevTx, SignTx, TxInput, TxOutput from trezor.utils import HashWriter, ensure from apps.common.coininfo import CoinInfo diff --git a/core/src/apps/bitcoin/verify_message.py b/core/src/apps/bitcoin/verify_message.py index 4e60b48e5..c7623c0bb 100644 --- a/core/src/apps/bitcoin/verify_message.py +++ b/core/src/apps/bitcoin/verify_message.py @@ -1,7 +1,7 @@ from trezor import wire from trezor.crypto.curve import secp256k1 -from trezor.messages.InputScriptType import SPENDADDRESS, SPENDP2SHWITNESS, SPENDWITNESS -from trezor.messages.Success import Success +from trezor.enums import InputScriptType +from trezor.messages import Success from trezor.ui.layouts import confirm_signverify from apps.common import coins @@ -16,8 +16,7 @@ from .addresses import ( ) if False: - from trezor.messages.VerifyMessage import VerifyMessage - from trezor.messages.TxInputType import EnumTypeInputScriptType + from trezor.messages import VerifyMessage async def verify_message(ctx: wire.Context, msg: VerifyMessage) -> Success: @@ -32,14 +31,14 @@ async def verify_message(ctx: wire.Context, msg: VerifyMessage) -> Success: recid = signature[0] if recid >= 27 and recid <= 34: # p2pkh - script_type: EnumTypeInputScriptType = SPENDADDRESS + script_type = InputScriptType.SPENDADDRESS elif recid >= 35 and recid <= 38: # segwit-in-p2sh - script_type = SPENDP2SHWITNESS + script_type = InputScriptType.SPENDP2SHWITNESS signature = bytes([signature[0] - 4]) + signature[1:] elif recid >= 39 and recid <= 42: # native segwit - script_type = SPENDWITNESS + script_type = InputScriptType.SPENDWITNESS signature = bytes([signature[0] - 8]) + signature[1:] else: raise wire.ProcessError("Invalid signature") @@ -49,13 +48,13 @@ async def verify_message(ctx: wire.Context, msg: VerifyMessage) -> Success: if not pubkey: raise wire.ProcessError("Invalid signature") - if script_type == SPENDADDRESS: + if script_type == InputScriptType.SPENDADDRESS: addr = address_pkh(pubkey, coin) if coin.cashaddr_prefix is not None: addr = address_to_cashaddr(addr, coin) - elif script_type == SPENDP2SHWITNESS: + elif script_type == InputScriptType.SPENDP2SHWITNESS: addr = address_p2wpkh_in_p2sh(pubkey, coin) - elif script_type == SPENDWITNESS: + elif script_type == InputScriptType.SPENDWITNESS: addr = address_p2wpkh(pubkey, coin) else: raise wire.ProcessError("Invalid signature") diff --git a/core/src/apps/bitcoin/writers.py b/core/src/apps/bitcoin/writers.py index 3327b4839..226939f68 100644 --- a/core/src/apps/bitcoin/writers.py +++ b/core/src/apps/bitcoin/writers.py @@ -15,10 +15,12 @@ from apps.common.writers import ( # noqa: F401 ) if False: - from trezor.messages.TxInput import TxInput - from trezor.messages.TxOutput import TxOutput - from trezor.messages.PrevInput import PrevInput - from trezor.messages.PrevOutput import PrevOutput + from trezor.messages import ( + PrevInput, + PrevOutput, + TxInput, + TxOutput, + ) from trezor.utils import HashWriter from apps.common.writers import Writer diff --git a/core/src/apps/cardano/address.py b/core/src/apps/cardano/address.py index 7fae9bfeb..5cf2b88ca 100644 --- a/core/src/apps/cardano/address.py +++ b/core/src/apps/cardano/address.py @@ -1,6 +1,6 @@ from trezor import wire from trezor.crypto import base58, hashlib -from trezor.messages import CardanoAddressType +from trezor.enums import CardanoAddressType from .byron_address import derive_byron_address, validate_byron_address from .helpers import INVALID_ADDRESS, NETWORK_MISMATCH, bech32, network_ids @@ -9,12 +9,9 @@ from .helpers.utils import derive_public_key, variable_length_encode from .seed import is_byron_path, is_shelley_path if False: - from trezor.messages.CardanoBlockchainPointerType import ( + from trezor.messages import ( CardanoBlockchainPointerType, - ) - from trezor.messages.CardanoAddressParametersType import ( CardanoAddressParametersType, - EnumTypeCardanoAddressType, ) from . import seed @@ -86,7 +83,7 @@ def get_address_bytes_unsafe(address: str) -> bytes: return address_bytes -def _get_address_type(address: bytes) -> EnumTypeCardanoAddressType: +def _get_address_type(address: bytes) -> CardanoAddressType: return address[0] >> 4 # type: ignore @@ -106,7 +103,7 @@ def _validate_address_size(address_bytes: bytes) -> None: def _validate_address_bech32_hrp( - address_str: str, address_type: EnumTypeCardanoAddressType, network_id: int + address_str: str, address_type: CardanoAddressType, network_id: int ) -> None: valid_hrp = _get_bech32_hrp_for_address(address_type, network_id) bech32_hrp = bech32.get_hrp(address_str) @@ -116,7 +113,7 @@ def _validate_address_bech32_hrp( def _get_bech32_hrp_for_address( - address_type: EnumTypeCardanoAddressType, network_id: int + address_type: CardanoAddressType, network_id: int ) -> str: if address_type == CardanoAddressType.BYRON: # Byron address uses base58 encoding @@ -235,10 +232,8 @@ def _derive_shelley_address( return address -def _create_address_header( - address_type: EnumTypeCardanoAddressType, network_id: int -) -> bytes: - header = address_type << 4 | network_id +def _create_address_header(address_type: CardanoAddressType, network_id: int) -> bytes: + header: int = address_type << 4 | network_id return header.to_bytes(1, "little") diff --git a/core/src/apps/cardano/auxiliary_data.py b/core/src/apps/cardano/auxiliary_data.py index dc0ec7920..da0379e16 100644 --- a/core/src/apps/cardano/auxiliary_data.py +++ b/core/src/apps/cardano/auxiliary_data.py @@ -1,6 +1,6 @@ from trezor.crypto import hashlib from trezor.crypto.curve import ed25519 -from trezor.messages import CardanoAddressType +from trezor.enums import CardanoAddressType from apps.common import cbor @@ -15,10 +15,10 @@ if False: from typing import Union from trezor import wire - from trezor.messages.CardanoCatalystRegistrationParametersType import ( + from trezor.messages import ( CardanoCatalystRegistrationParametersType, + CardanoTxAuxiliaryDataType, ) - from trezor.messages.CardanoTxAuxiliaryDataType import CardanoTxAuxiliaryDataType CatalystRegistrationPayload = dict[int, Union[bytes, int]] CatalystRegistrationSignature = dict[int, bytes] diff --git a/core/src/apps/cardano/certificates.py b/core/src/apps/cardano/certificates.py index 212c96db7..caea2ac1a 100644 --- a/core/src/apps/cardano/certificates.py +++ b/core/src/apps/cardano/certificates.py @@ -1,4 +1,4 @@ -from trezor.messages import CardanoCertificateType, CardanoPoolRelayType +from trezor.enums import CardanoCertificateType, CardanoPoolRelayType from apps.common import cbor @@ -11,13 +11,13 @@ from .helpers import INVALID_CERTIFICATE, LOVELACE_MAX_SUPPLY from .helpers.paths import SCHEMA_STAKING_ANY_ACCOUNT if False: - from trezor.messages.CardanoTxCertificateType import CardanoTxCertificateType - from trezor.messages.CardanoPoolParametersType import CardanoPoolParametersType - from trezor.messages.CardanoPoolRelayParametersType import ( + from trezor.messages import ( + CardanoPoolMetadataType, + CardanoPoolOwnerType, + CardanoPoolParametersType, CardanoPoolRelayParametersType, + CardanoTxCertificateType, ) - from trezor.messages.CardanoPoolOwnerType import CardanoPoolOwnerType - from trezor.messages.CardanoPoolMetadataType import CardanoPoolMetadataType from apps.common.cbor import CborSequence diff --git a/core/src/apps/cardano/get_address.py b/core/src/apps/cardano/get_address.py index 03ddcc6da..eee172c41 100644 --- a/core/src/apps/cardano/get_address.py +++ b/core/src/apps/cardano/get_address.py @@ -1,5 +1,5 @@ from trezor import log, wire -from trezor.messages.CardanoAddress import CardanoAddress +from trezor.messages import CardanoAddress from apps.common import paths from apps.common.layout import address_n_to_str, show_qr @@ -17,10 +17,10 @@ from .layout import ( from .sign_tx import validate_network_info if False: - from trezor.messages.CardanoAddressParametersType import ( + from trezor.messages import ( CardanoAddressParametersType, + CardanoGetAddress, ) - from trezor.messages.CardanoGetAddress import CardanoGetAddress @seed.with_keychain diff --git a/core/src/apps/cardano/get_public_key.py b/core/src/apps/cardano/get_public_key.py index 84e30ddc0..3246c41af 100644 --- a/core/src/apps/cardano/get_public_key.py +++ b/core/src/apps/cardano/get_public_key.py @@ -1,8 +1,7 @@ from ubinascii import hexlify from trezor import log, wire -from trezor.messages.CardanoPublicKey import CardanoPublicKey -from trezor.messages.HDNodeType import HDNodeType +from trezor.messages import CardanoPublicKey, HDNodeType from trezor.ui.layouts import show_pubkey from apps.common import paths @@ -12,7 +11,7 @@ from .helpers.paths import SCHEMA_PUBKEY from .helpers.utils import derive_public_key if False: - from trezor.messages.CardanoGetPublicKey import CardanoGetPublicKey + from trezor.messages import CardanoGetPublicKey @seed.with_keychain diff --git a/core/src/apps/cardano/helpers/staking_use_cases.py b/core/src/apps/cardano/helpers/staking_use_cases.py index 66774df4c..cf413af6f 100644 --- a/core/src/apps/cardano/helpers/staking_use_cases.py +++ b/core/src/apps/cardano/helpers/staking_use_cases.py @@ -1,13 +1,11 @@ -from trezor.messages import CardanoAddressType +from trezor.enums import CardanoAddressType from ..address import get_public_key_hash from ..seed import is_shelley_path from .utils import to_account_path if False: - from trezor.messages.CardanoAddressParametersType import ( - CardanoAddressParametersType, - ) + from trezor.messages import CardanoAddressParametersType from ..seed import Keychain diff --git a/core/src/apps/cardano/layout.py b/core/src/apps/cardano/layout.py index 85d99ed1a..0478d36ce 100644 --- a/core/src/apps/cardano/layout.py +++ b/core/src/apps/cardano/layout.py @@ -2,11 +2,7 @@ import math from ubinascii import hexlify from trezor import ui -from trezor.messages import ( - ButtonRequestType, - CardanoAddressType, - CardanoCertificateType, -) +from trezor.enums import ButtonRequestType, CardanoAddressType, CardanoCertificateType from trezor.strings import format_amount from trezor.ui.components.tt.button import ButtonDefault from trezor.ui.components.tt.scroll import Paginated @@ -33,16 +29,15 @@ from .helpers.utils import ( if False: from trezor import wire - from trezor.messages.CardanoBlockchainPointerType import ( + from trezor.messages import ( CardanoBlockchainPointerType, + CardanoTxCertificateType, + CardanoTxWithdrawalType, + CardanoPoolParametersType, + CardanoPoolOwnerType, + CardanoPoolMetadataType, + CardanoAssetGroupType, ) - from trezor.messages.CardanoTxCertificateType import CardanoTxCertificateType - from trezor.messages.CardanoTxWithdrawalType import CardanoTxWithdrawalType - from trezor.messages.CardanoPoolParametersType import CardanoPoolParametersType - from trezor.messages.CardanoPoolOwnerType import CardanoPoolOwnerType - from trezor.messages.CardanoPoolMetadataType import CardanoPoolMetadataType - from trezor.messages.CardanoAssetGroupType import CardanoAssetGroupType - from trezor.messages.CardanoAddressParametersType import EnumTypeCardanoAddressType ADDRESS_TYPE_NAMES = { @@ -137,7 +132,7 @@ async def show_warning_path(ctx: wire.Context, path: list[int], title: str) -> N async def show_warning_tx_no_staking_info( - ctx: wire.Context, address_type: EnumTypeCardanoAddressType, amount: int + ctx: wire.Context, address_type: CardanoAddressType, amount: int ) -> None: page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN) page1.normal("Change " + ADDRESS_TYPE_NAMES[address_type].lower()) @@ -441,7 +436,7 @@ async def show_auxiliary_data_hash( async def show_address( ctx: wire.Context, address: str, - address_type: EnumTypeCardanoAddressType, + address_type: CardanoAddressType, path: list[int], network: str | None = None, ) -> bool: diff --git a/core/src/apps/cardano/sign_tx.py b/core/src/apps/cardano/sign_tx.py index da6355515..c50d71bc8 100644 --- a/core/src/apps/cardano/sign_tx.py +++ b/core/src/apps/cardano/sign_tx.py @@ -1,11 +1,13 @@ from trezor import log, wire from trezor.crypto import hashlib from trezor.crypto.curve import ed25519 -from trezor.messages import CardanoAddressType, CardanoCertificateType -from trezor.messages.CardanoAddressParametersType import CardanoAddressParametersType -from trezor.messages.CardanoSignedTx import CardanoSignedTx -from trezor.messages.CardanoSignedTxChunk import CardanoSignedTxChunk -from trezor.messages.CardanoSignedTxChunkAck import CardanoSignedTxChunkAck +from trezor.enums import CardanoAddressType, CardanoCertificateType +from trezor.messages import ( + CardanoAddressParametersType, + CardanoSignedTx, + CardanoSignedTxChunk, + CardanoSignedTxChunkAck, +) from apps.common import cbor, safety_checks from apps.common.paths import validate_path @@ -72,12 +74,14 @@ from .seed import is_byron_path, is_shelley_path if False: from typing import Any, Optional, Union - from trezor.messages.CardanoSignTx import CardanoSignTx - from trezor.messages.CardanoTxCertificateType import CardanoTxCertificateType - from trezor.messages.CardanoTxInputType import CardanoTxInputType - from trezor.messages.CardanoTxOutputType import CardanoTxOutputType - from trezor.messages.CardanoTxWithdrawalType import CardanoTxWithdrawalType - from trezor.messages.CardanoAssetGroupType import CardanoAssetGroupType + from trezor.messages import ( + CardanoAssetGroupType, + CardanoSignTx, + CardanoTxCertificateType, + CardanoTxInputType, + CardanoTxOutputType, + CardanoTxWithdrawalType, + ) from apps.common.cbor import CborSequence from apps.common.paths import PathSchema diff --git a/core/src/apps/common/__init__.py b/core/src/apps/common/__init__.py index de5d104e8..784ea372c 100644 --- a/core/src/apps/common/__init__.py +++ b/core/src/apps/common/__init__.py @@ -1,19 +1,17 @@ from micropython import const from trezor import workflow -from trezor.messages import ButtonRequestType -from trezor.messages.ButtonAck import ButtonAck -from trezor.messages.ButtonRequest import ButtonRequest +from trezor.enums import ButtonRequestType +from trezor.messages import ButtonAck, ButtonRequest if False: from trezor import wire - from trezor.messages.ButtonRequest import EnumTypeButtonRequestType HARDENED = const(0x8000_0000) async def button_request( - ctx: wire.GenericContext, code: EnumTypeButtonRequestType = ButtonRequestType.Other + ctx: wire.GenericContext, code: ButtonRequestType = ButtonRequestType.Other ) -> None: workflow.close_others() await ctx.call(ButtonRequest(code=code), ButtonAck) diff --git a/core/src/apps/common/authorization.py b/core/src/apps/common/authorization.py index 156f821b2..715e862aa 100644 --- a/core/src/apps/common/authorization.py +++ b/core/src/apps/common/authorization.py @@ -1,4 +1,3 @@ -import protobuf import storage.cache from trezor import protobuf from trezor.enums import MessageType diff --git a/core/src/apps/common/confirm.py b/core/src/apps/common/confirm.py index d93040e1a..b56b8e799 100644 --- a/core/src/apps/common/confirm.py +++ b/core/src/apps/common/confirm.py @@ -1,5 +1,5 @@ from trezor import wire -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.confirm import ( CONFIRMED, INFO, @@ -19,13 +19,12 @@ if False: from trezor import ui from trezor.ui.components.tt.confirm import ButtonContent, ButtonStyleType from trezor.ui.loader import LoaderStyleType - from trezor.messages.ButtonRequest import EnumTypeButtonRequestType async def confirm( ctx: wire.GenericContext, content: ui.Component, - code: EnumTypeButtonRequestType = ButtonRequestType.Other, + code: ButtonRequestType = ButtonRequestType.Other, confirm: ButtonContent | None = Confirm.DEFAULT_CONFIRM, confirm_style: ButtonStyleType = Confirm.DEFAULT_CONFIRM_STYLE, cancel: ButtonContent | None = Confirm.DEFAULT_CANCEL, @@ -60,7 +59,7 @@ async def info_confirm( ctx: wire.GenericContext, content: ui.Component, info_func: Callable, - code: EnumTypeButtonRequestType = ButtonRequestType.Other, + code: ButtonRequestType = ButtonRequestType.Other, confirm: ButtonContent = InfoConfirm.DEFAULT_CONFIRM, confirm_style: ButtonStyleType = InfoConfirm.DEFAULT_CONFIRM_STYLE, cancel: ButtonContent = InfoConfirm.DEFAULT_CANCEL, @@ -87,7 +86,7 @@ async def info_confirm( async def hold_to_confirm( ctx: wire.GenericContext, content: ui.Component, - code: EnumTypeButtonRequestType = ButtonRequestType.Other, + code: ButtonRequestType = ButtonRequestType.Other, confirm: str = HoldToConfirm.DEFAULT_CONFIRM, confirm_style: ButtonStyleType = HoldToConfirm.DEFAULT_CONFIRM_STYLE, loader_style: LoaderStyleType = HoldToConfirm.DEFAULT_LOADER_STYLE, diff --git a/core/src/apps/common/keychain.py b/core/src/apps/common/keychain.py index ec6162574..52d4a669f 100644 --- a/core/src/apps/common/keychain.py +++ b/core/src/apps/common/keychain.py @@ -16,7 +16,7 @@ if False: ) from typing_extensions import Protocol - from protobuf import MessageType + from trezor.protobuf import MessageType T = TypeVar("T") diff --git a/core/src/apps/common/layout.py b/core/src/apps/common/layout.py index 909014566..2dda573e6 100644 --- a/core/src/apps/common/layout.py +++ b/core/src/apps/common/layout.py @@ -1,7 +1,7 @@ from micropython import const from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.button import ButtonDefault from trezor.ui.components.tt.text import Text from trezor.ui.container import Container diff --git a/core/src/apps/common/mnemonic.py b/core/src/apps/common/mnemonic.py index 90e5b3ccd..1ab467827 100644 --- a/core/src/apps/common/mnemonic.py +++ b/core/src/apps/common/mnemonic.py @@ -1,9 +1,6 @@ import storage.device from trezor import ui, utils, workflow -from trezor.messages import BackupType - -if False: - from trezor.messages.ResetDevice import EnumTypeBackupType +from trezor.enums import BackupType def get() -> tuple[bytes | None, int]: @@ -14,7 +11,7 @@ def get_secret() -> bytes | None: return storage.device.get_mnemonic_secret() -def get_type() -> EnumTypeBackupType: +def get_type() -> BackupType: return storage.device.get_backup_type() diff --git a/core/src/apps/common/passphrase.py b/core/src/apps/common/passphrase.py index bcdb6e6ec..27faa698c 100644 --- a/core/src/apps/common/passphrase.py +++ b/core/src/apps/common/passphrase.py @@ -2,7 +2,7 @@ from micropython import const import storage.device from trezor import wire, workflow -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from . import button_request @@ -35,8 +35,7 @@ async def _request_from_user(ctx: wire.Context) -> str: async def _request_on_host(ctx: wire.Context) -> str: - from trezor.messages.PassphraseAck import PassphraseAck - from trezor.messages.PassphraseRequest import PassphraseRequest + from trezor.messages import PassphraseAck, PassphraseRequest from trezor.ui import ICON_CONFIG from trezor.ui.components.tt.text import Text diff --git a/core/src/apps/common/request_pin.py b/core/src/apps/common/request_pin.py index debfd5826..0f08c631a 100644 --- a/core/src/apps/common/request_pin.py +++ b/core/src/apps/common/request_pin.py @@ -3,7 +3,7 @@ import utime import storage.cache import storage.sd_salt from trezor import config, ui, wire -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.popup import Popup from . import button_request diff --git a/core/src/apps/common/safety_checks.py b/core/src/apps/common/safety_checks.py index 2c19d9771..6cfae81ac 100644 --- a/core/src/apps/common/safety_checks.py +++ b/core/src/apps/common/safety_checks.py @@ -2,13 +2,10 @@ import storage.cache import storage.device from storage.cache import APP_COMMON_SAFETY_CHECKS_TEMPORARY from storage.device import SAFETY_CHECK_LEVEL_PROMPT, SAFETY_CHECK_LEVEL_STRICT -from trezor.messages import SafetyCheckLevel +from trezor.enums import SafetyCheckLevel -if False: - from trezor.messages.ApplySettings import EnumTypeSafetyCheckLevel - -def read_setting() -> EnumTypeSafetyCheckLevel: +def read_setting() -> SafetyCheckLevel: """ Returns the effective safety check level. """ @@ -25,7 +22,7 @@ def read_setting() -> EnumTypeSafetyCheckLevel: raise ValueError("Unknown SafetyCheckLevel") -def apply_setting(level: EnumTypeSafetyCheckLevel) -> None: +def apply_setting(level: SafetyCheckLevel) -> None: """ Changes the safety level settings. """ diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py index c8f8f33de..3c3d67c0d 100644 --- a/core/src/apps/debug/__init__.py +++ b/core/src/apps/debug/__init__.py @@ -8,21 +8,25 @@ if __debug__: from trezor import log, loop, wire from trezor.ui import display - from trezor.messages import MessageType - from trezor.messages.DebugLinkLayout import DebugLinkLayout - from trezor.messages.Success import Success + from trezor.enums import MessageType + from trezor.messages import ( + DebugLinkLayout, + Success, + ) from apps import workflow_handlers if False: from trezor.ui import Layout - from trezor.messages.DebugLinkDecision import DebugLinkDecision - from trezor.messages.DebugLinkGetState import DebugLinkGetState - from trezor.messages.DebugLinkRecordScreen import DebugLinkRecordScreen - from trezor.messages.DebugLinkReseedRandom import DebugLinkReseedRandom - from trezor.messages.DebugLinkState import DebugLinkState - from trezor.messages.DebugLinkEraseSdCard import DebugLinkEraseSdCard - from trezor.messages.DebugLinkWatchLayout import DebugLinkWatchLayout + from trezor.messages import ( + DebugLinkDecision, + DebugLinkEraseSdCard, + DebugLinkGetState, + DebugLinkRecordScreen, + DebugLinkReseedRandom, + DebugLinkState, + DebugLinkWatchLayout, + ) reset_current_words = loop.chan() reset_word_index = loop.chan() @@ -56,7 +60,7 @@ if __debug__: layout_change_chan.publish(storage.current_content) async def dispatch_debuglink_decision(msg: DebugLinkDecision) -> None: - from trezor.messages import DebugSwipeDirection + from trezor.enums import DebugSwipeDirection from trezor.ui import Result from trezor.ui.components.tt import confirm, swipe @@ -87,7 +91,7 @@ if __debug__: if storage.layout_watcher is LAYOUT_WATCHER_LAYOUT: await DEBUG_CONTEXT.write(DebugLinkLayout(lines=content)) else: - from trezor.messages.DebugLinkState import DebugLinkState + from trezor.messages import DebugLinkState await DEBUG_CONTEXT.write(DebugLinkState(layout_lines=content)) storage.layout_watcher = LAYOUT_WATCHER_NONE @@ -137,7 +141,7 @@ if __debug__: async def dispatch_DebugLinkGetState( ctx: wire.Context, msg: DebugLinkGetState ) -> DebugLinkState | None: - from trezor.messages.DebugLinkState import DebugLinkState + from trezor.messages import DebugLinkState from apps.common import mnemonic, passphrase m = DebugLinkState() diff --git a/core/src/apps/debug/load_device.py b/core/src/apps/debug/load_device.py index 4da3e4337..1d4330f4c 100644 --- a/core/src/apps/debug/load_device.py +++ b/core/src/apps/debug/load_device.py @@ -2,8 +2,8 @@ import storage import storage.device from trezor import config, wire from trezor.crypto import bip39, slip39 -from trezor.messages import BackupType -from trezor.messages.Success import Success +from trezor.enums import BackupType +from trezor.messages import Success from trezor.ui.layouts import confirm_action from apps.management import backup_types diff --git a/core/src/apps/eos/actions/__init__.py b/core/src/apps/eos/actions/__init__.py index c47b827f4..52ab80bd9 100644 --- a/core/src/apps/eos/actions/__init__.py +++ b/core/src/apps/eos/actions/__init__.py @@ -1,6 +1,5 @@ from trezor.crypto.hashlib import sha256 -from trezor.messages.EosTxActionAck import EosTxActionAck -from trezor.messages.EosTxActionRequest import EosTxActionRequest +from trezor.messages import EosTxActionAck, EosTxActionRequest from trezor.utils import HashWriter from .. import helpers, writers diff --git a/core/src/apps/eos/actions/layout.py b/core/src/apps/eos/actions/layout.py index 8c1181beb..127f9248e 100644 --- a/core/src/apps/eos/actions/layout.py +++ b/core/src/apps/eos/actions/layout.py @@ -2,7 +2,7 @@ from micropython import const from ubinascii import hexlify from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.scroll import Paginated from trezor.ui.components.tt.text import Text from trezor.utils import chunks @@ -12,21 +12,23 @@ from ..layout import require_confirm if False: from trezor import wire - from trezor.messages.EosAuthorization import EosAuthorization - from trezor.messages.EosActionBuyRam import EosActionBuyRam - from trezor.messages.EosActionBuyRamBytes import EosActionBuyRamBytes - from trezor.messages.EosActionCommon import EosActionCommon - from trezor.messages.EosActionDelegate import EosActionDelegate - from trezor.messages.EosActionDeleteAuth import EosActionDeleteAuth - from trezor.messages.EosActionLinkAuth import EosActionLinkAuth - from trezor.messages.EosActionNewAccount import EosActionNewAccount - from trezor.messages.EosActionRefund import EosActionRefund - from trezor.messages.EosActionSellRam import EosActionSellRam - from trezor.messages.EosActionTransfer import EosActionTransfer - from trezor.messages.EosActionUndelegate import EosActionUndelegate - from trezor.messages.EosActionUnlinkAuth import EosActionUnlinkAuth - from trezor.messages.EosActionUpdateAuth import EosActionUpdateAuth - from trezor.messages.EosActionVoteProducer import EosActionVoteProducer + from trezor.messages import ( + EosActionBuyRam, + EosActionBuyRamBytes, + EosActionCommon, + EosActionDelegate, + EosActionDeleteAuth, + EosActionLinkAuth, + EosActionNewAccount, + EosActionRefund, + EosActionSellRam, + EosActionTransfer, + EosActionUndelegate, + EosActionUnlinkAuth, + EosActionUpdateAuth, + EosActionVoteProducer, + EosAuthorization, + ) _LINE_LENGTH = const(17) _LINE_PLACEHOLDER = "{:<" + str(_LINE_LENGTH) + "}" diff --git a/core/src/apps/eos/get_public_key.py b/core/src/apps/eos/get_public_key.py index bdba59e24..efb793c62 100644 --- a/core/src/apps/eos/get_public_key.py +++ b/core/src/apps/eos/get_public_key.py @@ -1,7 +1,6 @@ from trezor import wire from trezor.crypto.curve import secp256k1 -from trezor.messages.EosGetPublicKey import EosGetPublicKey -from trezor.messages.EosPublicKey import EosPublicKey +from trezor.messages import EosGetPublicKey, EosPublicKey from apps.common import paths from apps.common.keychain import Keychain, auto_keychain diff --git a/core/src/apps/eos/helpers.py b/core/src/apps/eos/helpers.py index 01173889e..6afe9f075 100644 --- a/core/src/apps/eos/helpers.py +++ b/core/src/apps/eos/helpers.py @@ -1,6 +1,6 @@ from trezor import wire from trezor.crypto import base58 -from trezor.messages.EosAsset import EosAsset +from trezor.messages import EosAsset def base58_encode(prefix: str, sig_prefix: str, data: bytes) -> str: diff --git a/core/src/apps/eos/layout.py b/core/src/apps/eos/layout.py index 686d54efe..ba70504d6 100644 --- a/core/src/apps/eos/layout.py +++ b/core/src/apps/eos/layout.py @@ -1,5 +1,5 @@ from trezor import ui, wire -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.text import Text from apps.common.confirm import require_confirm diff --git a/core/src/apps/eos/sign_tx.py b/core/src/apps/eos/sign_tx.py index 514e99a8f..10e2845e3 100644 --- a/core/src/apps/eos/sign_tx.py +++ b/core/src/apps/eos/sign_tx.py @@ -1,10 +1,7 @@ from trezor import wire from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha256 -from trezor.messages.EosSignedTx import EosSignedTx -from trezor.messages.EosSignTx import EosSignTx -from trezor.messages.EosTxActionAck import EosTxActionAck -from trezor.messages.EosTxActionRequest import EosTxActionRequest +from trezor.messages import EosSignedTx, EosSignTx, EosTxActionAck, EosTxActionRequest from trezor.utils import HashWriter from apps.common import paths diff --git a/core/src/apps/eos/writers.py b/core/src/apps/eos/writers.py index aca117d7c..b5e159148 100644 --- a/core/src/apps/eos/writers.py +++ b/core/src/apps/eos/writers.py @@ -10,22 +10,24 @@ from apps.common.writers import ( ) if False: - from trezor.messages.EosActionBuyRam import EosActionBuyRam - from trezor.messages.EosActionBuyRamBytes import EosActionBuyRamBytes - from trezor.messages.EosActionCommon import EosActionCommon - from trezor.messages.EosActionDelegate import EosActionDelegate - from trezor.messages.EosActionDeleteAuth import EosActionDeleteAuth - from trezor.messages.EosActionLinkAuth import EosActionLinkAuth - from trezor.messages.EosActionNewAccount import EosActionNewAccount - from trezor.messages.EosActionRefund import EosActionRefund - from trezor.messages.EosActionSellRam import EosActionSellRam - from trezor.messages.EosActionTransfer import EosActionTransfer - from trezor.messages.EosActionUndelegate import EosActionUndelegate - from trezor.messages.EosActionUpdateAuth import EosActionUpdateAuth - from trezor.messages.EosActionVoteProducer import EosActionVoteProducer - from trezor.messages.EosAsset import EosAsset - from trezor.messages.EosAuthorization import EosAuthorization - from trezor.messages.EosTxHeader import EosTxHeader + from trezor.messages import ( + EosActionBuyRam, + EosActionBuyRamBytes, + EosActionCommon, + EosActionDelegate, + EosActionDeleteAuth, + EosActionLinkAuth, + EosActionNewAccount, + EosActionRefund, + EosActionSellRam, + EosActionTransfer, + EosActionUndelegate, + EosActionUpdateAuth, + EosActionVoteProducer, + EosAsset, + EosAuthorization, + EosTxHeader, + ) from trezor.utils import Writer diff --git a/core/src/apps/ethereum/get_address.py b/core/src/apps/ethereum/get_address.py index 971425ea2..a2ced53d5 100644 --- a/core/src/apps/ethereum/get_address.py +++ b/core/src/apps/ethereum/get_address.py @@ -1,6 +1,6 @@ from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha3_256 -from trezor.messages.EthereumAddress import EthereumAddress +from trezor.messages import EthereumAddress from trezor.ui.layouts import show_address from apps.common import paths diff --git a/core/src/apps/ethereum/get_public_key.py b/core/src/apps/ethereum/get_public_key.py index 909bc1502..4f8e04fde 100644 --- a/core/src/apps/ethereum/get_public_key.py +++ b/core/src/apps/ethereum/get_public_key.py @@ -1,7 +1,6 @@ from ubinascii import hexlify -from trezor.messages.EthereumPublicKey import EthereumPublicKey -from trezor.messages.HDNodeType import HDNodeType +from trezor.messages import EthereumPublicKey, HDNodeType from trezor.ui.layouts import show_pubkey from apps.common import coins, paths diff --git a/core/src/apps/ethereum/keychain.py b/core/src/apps/ethereum/keychain.py index 5e79fecf3..545419848 100644 --- a/core/src/apps/ethereum/keychain.py +++ b/core/src/apps/ethereum/keychain.py @@ -11,7 +11,7 @@ if False: from protobuf import MessageType - from trezor.messages.EthereumSignTx import EthereumSignTx + from trezor.messages import EthereumSignTx from apps.common.keychain import MsgOut, Handler, HandlerWithKeychain diff --git a/core/src/apps/ethereum/layout.py b/core/src/apps/ethereum/layout.py index e4872d673..aeea41ff3 100644 --- a/core/src/apps/ethereum/layout.py +++ b/core/src/apps/ethereum/layout.py @@ -1,7 +1,7 @@ from ubinascii import hexlify from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.strings import format_amount from trezor.ui.components.tt.text import Text from trezor.utils import chunks diff --git a/core/src/apps/ethereum/sign_message.py b/core/src/apps/ethereum/sign_message.py index 52c81166a..c04c87a03 100644 --- a/core/src/apps/ethereum/sign_message.py +++ b/core/src/apps/ethereum/sign_message.py @@ -1,6 +1,6 @@ from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha3_256 -from trezor.messages.EthereumMessageSignature import EthereumMessageSignature +from trezor.messages import EthereumMessageSignature from trezor.ui.layouts import confirm_signverify from trezor.utils import HashWriter diff --git a/core/src/apps/ethereum/sign_tx.py b/core/src/apps/ethereum/sign_tx.py index 714721e10..a1ac332d3 100644 --- a/core/src/apps/ethereum/sign_tx.py +++ b/core/src/apps/ethereum/sign_tx.py @@ -2,9 +2,7 @@ from trezor import wire from trezor.crypto import rlp from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha3_256 -from trezor.messages.EthereumSignTx import EthereumSignTx -from trezor.messages.EthereumTxAck import EthereumTxAck -from trezor.messages.EthereumTxRequest import EthereumTxRequest +from trezor.messages import EthereumSignTx, EthereumTxAck, EthereumTxRequest from trezor.utils import HashWriter from apps.common import paths diff --git a/core/src/apps/ethereum/verify_message.py b/core/src/apps/ethereum/verify_message.py index 4c3a66058..f69ccc00a 100644 --- a/core/src/apps/ethereum/verify_message.py +++ b/core/src/apps/ethereum/verify_message.py @@ -1,7 +1,7 @@ from trezor import wire from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha3_256 -from trezor.messages.Success import Success +from trezor.messages import Success from trezor.ui.layouts import confirm_signverify from apps.common.signverify import decode_message diff --git a/core/src/apps/lisk/get_address.py b/core/src/apps/lisk/get_address.py index 3a506c413..c6824a0ce 100644 --- a/core/src/apps/lisk/get_address.py +++ b/core/src/apps/lisk/get_address.py @@ -1,4 +1,4 @@ -from trezor.messages.LiskAddress import LiskAddress +from trezor.messages import LiskAddress from trezor.ui.layouts import show_address from apps.common import paths diff --git a/core/src/apps/lisk/get_public_key.py b/core/src/apps/lisk/get_public_key.py index 8fe023209..5c2c93a1a 100644 --- a/core/src/apps/lisk/get_public_key.py +++ b/core/src/apps/lisk/get_public_key.py @@ -1,6 +1,6 @@ from ubinascii import hexlify -from trezor.messages.LiskPublicKey import LiskPublicKey +from trezor.messages import LiskPublicKey from trezor.ui.layouts import show_pubkey from apps.common import paths diff --git a/core/src/apps/lisk/layout.py b/core/src/apps/lisk/layout.py index 55ee1b5d5..cb26efb62 100644 --- a/core/src/apps/lisk/layout.py +++ b/core/src/apps/lisk/layout.py @@ -1,7 +1,7 @@ from ubinascii import hexlify from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.strings import format_amount from trezor.ui.components.tt.text import Text from trezor.ui.layouts import show_pubkey diff --git a/core/src/apps/lisk/sign_message.py b/core/src/apps/lisk/sign_message.py index 3690cd832..52c164fc7 100644 --- a/core/src/apps/lisk/sign_message.py +++ b/core/src/apps/lisk/sign_message.py @@ -1,6 +1,6 @@ from trezor.crypto.curve import ed25519 from trezor.crypto.hashlib import sha256 -from trezor.messages.LiskMessageSignature import LiskMessageSignature +from trezor.messages import LiskMessageSignature from trezor.ui.layouts import confirm_signverify from trezor.utils import HashWriter diff --git a/core/src/apps/lisk/sign_tx.py b/core/src/apps/lisk/sign_tx.py index b92278fac..404610808 100644 --- a/core/src/apps/lisk/sign_tx.py +++ b/core/src/apps/lisk/sign_tx.py @@ -3,8 +3,8 @@ import ustruct from trezor import wire from trezor.crypto.curve import ed25519 from trezor.crypto.hashlib import sha256 -from trezor.messages import LiskTransactionType -from trezor.messages.LiskSignedTx import LiskSignedTx +from trezor.enums import LiskTransactionType +from trezor.messages import LiskSignedTx from trezor.utils import HashWriter from apps.common import paths diff --git a/core/src/apps/lisk/verify_message.py b/core/src/apps/lisk/verify_message.py index e52875e6c..72c18d130 100644 --- a/core/src/apps/lisk/verify_message.py +++ b/core/src/apps/lisk/verify_message.py @@ -1,6 +1,6 @@ from trezor import wire from trezor.crypto.curve import ed25519 -from trezor.messages.Success import Success +from trezor.messages import Success from trezor.ui.layouts import confirm_signverify from apps.common.signverify import decode_message diff --git a/core/src/apps/management/apply_flags.py b/core/src/apps/management/apply_flags.py index 679826a71..66aa05920 100644 --- a/core/src/apps/management/apply_flags.py +++ b/core/src/apps/management/apply_flags.py @@ -1,7 +1,7 @@ import storage.device from storage.device import set_flags from trezor import wire -from trezor.messages.Success import Success +from trezor.messages import Success async def apply_flags(ctx, msg): diff --git a/core/src/apps/management/apply_settings.py b/core/src/apps/management/apply_settings.py index cfef5b5db..af3dd6ee5 100644 --- a/core/src/apps/management/apply_settings.py +++ b/core/src/apps/management/apply_settings.py @@ -1,7 +1,7 @@ import storage.device from trezor import ui, wire -from trezor.messages import ButtonRequestType, SafetyCheckLevel -from trezor.messages.Success import Success +from trezor.enums import ButtonRequestType, SafetyCheckLevel +from trezor.messages import Success from trezor.strings import format_duration_ms from trezor.ui.layouts import confirm_action @@ -9,7 +9,7 @@ from apps.base import reload_settings_from_storage from apps.common import safety_checks if False: - from trezor.messages.ApplySettings import ApplySettings, EnumTypeSafetyCheckLevel + from trezor.messages import ApplySettings def validate_homescreen(homescreen: bytes) -> None: @@ -182,7 +182,7 @@ async def require_confirm_change_autolock_delay(ctx, delay_ms): ) -async def require_confirm_safety_checks(ctx, level: EnumTypeSafetyCheckLevel) -> None: +async def require_confirm_safety_checks(ctx, level: SafetyCheckLevel) -> None: if level == SafetyCheckLevel.PromptAlways: await confirm_action( ctx, diff --git a/core/src/apps/management/backup_device.py b/core/src/apps/management/backup_device.py index fa5c399f7..20a73f2a3 100644 --- a/core/src/apps/management/backup_device.py +++ b/core/src/apps/management/backup_device.py @@ -1,7 +1,7 @@ import storage import storage.device from trezor import wire -from trezor.messages.Success import Success +from trezor.messages import Success from apps.common import mnemonic diff --git a/core/src/apps/management/backup_types.py b/core/src/apps/management/backup_types.py index 0f0248c45..442c83f39 100644 --- a/core/src/apps/management/backup_types.py +++ b/core/src/apps/management/backup_types.py @@ -1,9 +1,5 @@ from trezor.crypto.slip39 import Share -from trezor.messages import BackupType - -if False: - from trezor.messages.ResetDevice import EnumTypeBackupType - +from trezor.enums import BackupType _BIP39_WORD_COUNTS = (12, 18, 24) _SLIP39_WORD_COUNTS = (20, 33) @@ -22,13 +18,11 @@ def is_slip39_word_count(word_count: int) -> bool: raise RuntimeError -def is_slip39_backup_type(backup_type: EnumTypeBackupType) -> bool: +def is_slip39_backup_type(backup_type: BackupType) -> bool: return backup_type in (BackupType.Slip39_Basic, BackupType.Slip39_Advanced) -def infer_backup_type( - is_slip39: bool, share: Share | None = None -) -> EnumTypeBackupType: +def infer_backup_type(is_slip39: bool, share: Share | None = None) -> BackupType: if not is_slip39: # BIP-39 return BackupType.Bip39 elif not share or share.group_count < 1: # invalid parameters diff --git a/core/src/apps/management/change_pin.py b/core/src/apps/management/change_pin.py index 13842e8d3..0230c7086 100644 --- a/core/src/apps/management/change_pin.py +++ b/core/src/apps/management/change_pin.py @@ -1,6 +1,6 @@ from storage.device import is_initialized from trezor import config, wire -from trezor.messages.Success import Success +from trezor.messages import Success from trezor.ui.layouts import confirm_action, show_success from apps.common.request_pin import ( @@ -11,7 +11,7 @@ from apps.common.request_pin import ( ) if False: - from trezor.messages.ChangePin import ChangePin + from trezor.messages import ChangePin async def change_pin(ctx: wire.Context, msg: ChangePin) -> Success: diff --git a/core/src/apps/management/change_wipe_code.py b/core/src/apps/management/change_wipe_code.py index 845a2f7d1..86f4ef5e7 100644 --- a/core/src/apps/management/change_wipe_code.py +++ b/core/src/apps/management/change_wipe_code.py @@ -1,6 +1,6 @@ from storage.device import is_initialized from trezor import config, ui, wire -from trezor.messages.Success import Success +from trezor.messages import Success from trezor.ui.components.tt.text import Text from trezor.ui.layouts import show_success from trezor.ui.popup import Popup @@ -13,7 +13,7 @@ from apps.common.request_pin import ( ) if False: - from trezor.messages.ChangeWipeCode import ChangeWipeCode + from trezor.messages import ChangeWipeCode async def change_wipe_code(ctx: wire.Context, msg: ChangeWipeCode) -> Success: diff --git a/core/src/apps/management/get_next_u2f_counter.py b/core/src/apps/management/get_next_u2f_counter.py index ba366b50b..78415ee7c 100644 --- a/core/src/apps/management/get_next_u2f_counter.py +++ b/core/src/apps/management/get_next_u2f_counter.py @@ -1,8 +1,7 @@ import storage.device from trezor import ui, wire -from trezor.messages import ButtonRequestType -from trezor.messages.GetNextU2FCounter import GetNextU2FCounter -from trezor.messages.NextU2FCounter import NextU2FCounter +from trezor.enums import ButtonRequestType +from trezor.messages import GetNextU2FCounter, NextU2FCounter from trezor.ui.components.tt.text import Text from apps.common.confirm import require_confirm diff --git a/core/src/apps/management/recovery_device/__init__.py b/core/src/apps/management/recovery_device/__init__.py index 5be59a72d..94a58f7e3 100644 --- a/core/src/apps/management/recovery_device/__init__.py +++ b/core/src/apps/management/recovery_device/__init__.py @@ -2,8 +2,8 @@ import storage import storage.device import storage.recovery from trezor import config, ui, wire, workflow -from trezor.messages import ButtonRequestType -from trezor.messages.Success import Success +from trezor.enums import ButtonRequestType +from trezor.messages import Success from trezor.ui.components.tt.text import Text from apps.common.confirm import require_confirm @@ -16,7 +16,7 @@ from apps.common.request_pin import ( from .homescreen import recovery_homescreen, recovery_process if False: - from trezor.messages.RecoveryDevice import RecoveryDevice + from trezor.messages import RecoveryDevice # List of RecoveryDevice fields that can be set when doing dry-run recovery. @@ -91,10 +91,7 @@ def _validate(msg: RecoveryDevice) -> None: async def _continue_dialog(ctx: wire.Context, msg: RecoveryDevice) -> None: if not msg.dry_run: text = Text("Recovery mode", ui.ICON_RECOVERY, new_lines=False) - text.bold("Do you really want to") - text.br() - text.bold("recover a wallet?") - + text.bold("Do you really want to recover a wallet?") text.br() text.br_half() text.normal("By continuing you agree") diff --git a/core/src/apps/management/recovery_device/homescreen.py b/core/src/apps/management/recovery_device/homescreen.py index 1da176fe1..8d5e2f68e 100644 --- a/core/src/apps/management/recovery_device/homescreen.py +++ b/core/src/apps/management/recovery_device/homescreen.py @@ -5,9 +5,9 @@ import storage.recovery_shares from trezor import strings, utils, wire, workflow from trezor.crypto import slip39 from trezor.crypto.hashlib import sha256 +from trezor.enums import BackupType, MessageType from trezor.errors import MnemonicError -from trezor.messages import BackupType, MessageType -from trezor.messages.Success import Success +from trezor.messages import Success from trezor.ui.layouts import show_success from apps.common import mnemonic @@ -16,9 +16,6 @@ from apps.homescreen.homescreen import homescreen from .. import backup_types from . import layout, recover -if False: - from trezor.messages.ResetDevice import EnumTypeBackupType - async def recovery_homescreen() -> None: if not storage.recovery.is_in_progress(): @@ -94,7 +91,7 @@ async def _continue_recovery_process(ctx: wire.GenericContext) -> Success: async def _finish_recovery_dry_run( - ctx: wire.GenericContext, secret: bytes, backup_type: EnumTypeBackupType + ctx: wire.GenericContext, secret: bytes, backup_type: BackupType ) -> Success: if backup_type is None: raise RuntimeError @@ -127,7 +124,7 @@ async def _finish_recovery_dry_run( async def _finish_recovery( - ctx: wire.GenericContext, secret: bytes, backup_type: EnumTypeBackupType + ctx: wire.GenericContext, secret: bytes, backup_type: BackupType ) -> Success: if backup_type is None: raise RuntimeError @@ -162,7 +159,7 @@ async def _request_word_count(ctx: wire.GenericContext, dry_run: bool) -> int: async def _process_words( ctx: wire.GenericContext, words: str -) -> tuple[bytes | None, EnumTypeBackupType]: +) -> tuple[bytes | None, BackupType]: word_count = len(words.split(" ")) is_slip39 = backup_types.is_slip39_word_count(word_count) diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py index fc8fa3ccb..06f14909c 100644 --- a/core/src/apps/management/recovery_device/layout.py +++ b/core/src/apps/management/recovery_device/layout.py @@ -1,7 +1,7 @@ import storage.recovery from trezor import strings, ui, wire from trezor.crypto.slip39 import MAX_SHARE_COUNT -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.scroll import Paginated from trezor.ui.components.tt.text import Text from trezor.ui.components.tt.word_select import WordSelector @@ -18,7 +18,7 @@ from .recover import RecoveryAborted if False: from typing import Callable, Iterable - from trezor.messages.ResetDevice import EnumTypeBackupType + from trezor.enums import BackupType async def confirm_abort(ctx: wire.GenericContext, dry_run: bool = False) -> None: @@ -61,7 +61,7 @@ async def request_word_count(ctx: wire.GenericContext, dry_run: bool) -> int: async def request_mnemonic( - ctx: wire.GenericContext, word_count: int, backup_type: EnumTypeBackupType | None + ctx: wire.GenericContext, word_count: int, backup_type: BackupType | None ) -> str | None: await button_request(ctx, code=ButtonRequestType.MnemonicInput) diff --git a/core/src/apps/management/recovery_device/recover.py b/core/src/apps/management/recovery_device/recover.py index f0b62a5b3..38e904234 100644 --- a/core/src/apps/management/recovery_device/recover.py +++ b/core/src/apps/management/recovery_device/recover.py @@ -6,7 +6,7 @@ from trezor.errors import MnemonicError from .. import backup_types if False: - from trezor.messages.ResetDevice import EnumTypeBackupType + from trezor.enums import BackupType from typing import Union @@ -92,7 +92,7 @@ def process_slip39(words: str) -> tuple[bytes | None, slip39.Share]: if False: - Slip39State = Union[tuple[int, EnumTypeBackupType], tuple[None, None]] + Slip39State = Union[tuple[int, BackupType], tuple[None, None]] def load_slip39_state() -> Slip39State: diff --git a/core/src/apps/management/recovery_device/word_validity.py b/core/src/apps/management/recovery_device/word_validity.py index b7dc5918c..8058bc61d 100644 --- a/core/src/apps/management/recovery_device/word_validity.py +++ b/core/src/apps/management/recovery_device/word_validity.py @@ -1,11 +1,8 @@ import storage.recovery -from trezor.messages import BackupType +from trezor.enums import BackupType from . import recover -if False: - from trezor.messages.ResetDevice import EnumTypeBackupType - class WordValidityResult(Exception): pass @@ -23,7 +20,7 @@ class ThresholdReached(WordValidityResult): pass -def check(backup_type: EnumTypeBackupType | None, partial_mnemonic: list[str]) -> None: +def check(backup_type: BackupType | None, partial_mnemonic: list[str]) -> None: # we can't perform any checks if the backup type was not yet decided if backup_type is None: return diff --git a/core/src/apps/management/reset_device/__init__.py b/core/src/apps/management/reset_device/__init__.py index b59389da6..5241713cf 100644 --- a/core/src/apps/management/reset_device/__init__.py +++ b/core/src/apps/management/reset_device/__init__.py @@ -2,10 +2,8 @@ import storage import storage.device from trezor import config, wire from trezor.crypto import bip39, hashlib, random, slip39 -from trezor.messages import BackupType -from trezor.messages.EntropyAck import EntropyAck -from trezor.messages.EntropyRequest import EntropyRequest -from trezor.messages.Success import Success +from trezor.enums import BackupType +from trezor.messages import EntropyAck, EntropyRequest, Success from trezor.ui.layouts import confirm_backup, confirm_reset_device from trezor.ui.loader import LoadingAnimation @@ -17,7 +15,7 @@ if __debug__: import storage.debug if False: - from trezor.messages.ResetDevice import ResetDevice + from trezor.messages import ResetDevice _DEFAULT_BACKUP_TYPE = BackupType.Bip39 diff --git a/core/src/apps/management/reset_device/layout.py b/core/src/apps/management/reset_device/layout.py index 67e3c983a..186c3c49c 100644 --- a/core/src/apps/management/reset_device/layout.py +++ b/core/src/apps/management/reset_device/layout.py @@ -2,7 +2,7 @@ import ubinascii from trezor import ui, utils from trezor.crypto import random -from trezor.messages import BackupType, ButtonRequestType +from trezor.enums import BackupType, ButtonRequestType from trezor.ui.components.tt.button import Button, ButtonDefault from trezor.ui.components.tt.checklist import Checklist from trezor.ui.components.tt.info import InfoConfirm diff --git a/core/src/apps/management/sd_protect.py b/core/src/apps/management/sd_protect.py index cd954cff8..111136c10 100644 --- a/core/src/apps/management/sd_protect.py +++ b/core/src/apps/management/sd_protect.py @@ -2,8 +2,8 @@ import storage.device import storage.sd_salt from trezor import config, wire from trezor.crypto import random -from trezor.messages import SdProtectOperationType -from trezor.messages.Success import Success +from trezor.enums import SdProtectOperationType +from trezor.messages import Success from trezor.ui.layouts import confirm_action, show_success from apps.common.request_pin import ( @@ -15,7 +15,7 @@ from apps.common.sdcard import confirm_retry_sd, ensure_sdcard if False: from typing import Awaitable - from trezor.messages.SdProtect import SdProtect + from trezor.messages import SdProtect def _make_salt() -> tuple[bytes, bytes, bytes]: diff --git a/core/src/apps/management/set_u2f_counter.py b/core/src/apps/management/set_u2f_counter.py index ad1437a1e..bcf6c39bd 100644 --- a/core/src/apps/management/set_u2f_counter.py +++ b/core/src/apps/management/set_u2f_counter.py @@ -1,8 +1,7 @@ import storage.device from trezor import ui, wire -from trezor.messages import ButtonRequestType -from trezor.messages.SetU2FCounter import SetU2FCounter -from trezor.messages.Success import Success +from trezor.enums import ButtonRequestType +from trezor.messages import SetU2FCounter, Success from trezor.ui.components.tt.text import Text from apps.common.confirm import require_confirm diff --git a/core/src/apps/management/wipe_device.py b/core/src/apps/management/wipe_device.py index d5b2dc189..425e90528 100644 --- a/core/src/apps/management/wipe_device.py +++ b/core/src/apps/management/wipe_device.py @@ -1,7 +1,7 @@ import storage from trezor import ui -from trezor.messages import ButtonRequestType -from trezor.messages.Success import Success +from trezor.enums import ButtonRequestType +from trezor.messages import Success from trezor.ui.layouts import confirm_action from .apply_settings import reload_settings_from_storage diff --git a/core/src/apps/misc/cipher_key_value.py b/core/src/apps/misc/cipher_key_value.py index 173f1d18f..343065413 100644 --- a/core/src/apps/misc/cipher_key_value.py +++ b/core/src/apps/misc/cipher_key_value.py @@ -1,15 +1,16 @@ from trezor import wire from trezor.crypto import aes, hmac -from trezor.messages.CipheredKeyValue import CipheredKeyValue +from trezor.messages import CipheredKeyValue from trezor.ui.layouts import confirm_action from apps.common.keychain import get_keychain from apps.common.paths import AlwaysMatchingSchema if False: - from trezor.messages.CipherKeyValue import CipherKeyValue from trezor.wire import Context + from trezor.messages import CipherKeyValue + # This module implements the SLIP-0011 symmetric encryption of key-value pairs using a # deterministic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0011.md. diff --git a/core/src/apps/misc/get_ecdh_session_key.py b/core/src/apps/misc/get_ecdh_session_key.py index b3a0a6885..754371cc3 100644 --- a/core/src/apps/misc/get_ecdh_session_key.py +++ b/core/src/apps/misc/get_ecdh_session_key.py @@ -2,7 +2,7 @@ from ustruct import pack, unpack from trezor import ui, wire from trezor.crypto.hashlib import sha256 -from trezor.messages.ECDHSessionKey import ECDHSessionKey +from trezor.messages import ECDHSessionKey from trezor.ui.layouts import confirm_hex from apps.common import HARDENED @@ -12,8 +12,7 @@ from apps.common.paths import AlwaysMatchingSchema from .sign_identity import serialize_identity, serialize_identity_without_proto if False: - from trezor.messages.GetECDHSessionKey import GetECDHSessionKey - from trezor.messages.IdentityType import IdentityType + from trezor.messages import GetECDHSessionKey, IdentityType from apps.common.paths import Bip32Path diff --git a/core/src/apps/misc/get_entropy.py b/core/src/apps/misc/get_entropy.py index a1d8d102f..b8876fda3 100644 --- a/core/src/apps/misc/get_entropy.py +++ b/core/src/apps/misc/get_entropy.py @@ -1,11 +1,11 @@ from trezor.crypto import random -from trezor.messages import ButtonRequestType -from trezor.messages.Entropy import Entropy +from trezor.enums import ButtonRequestType +from trezor.messages import Entropy from trezor.ui.layouts import confirm_action if False: from trezor.wire import Context - from trezor.messages.GetEntropy import GetEntropy + from trezor.messages import GetEntropy async def get_entropy(ctx: Context, msg: GetEntropy) -> Entropy: diff --git a/core/src/apps/misc/sign_identity.py b/core/src/apps/misc/sign_identity.py index 8c307762e..c4c2b4017 100644 --- a/core/src/apps/misc/sign_identity.py +++ b/core/src/apps/misc/sign_identity.py @@ -2,7 +2,7 @@ from ustruct import pack, unpack from trezor import wire from trezor.crypto.hashlib import sha256 -from trezor.messages.SignedIdentity import SignedIdentity +from trezor.messages import SignedIdentity from trezor.ui.layouts import confirm_sign_identity from apps.common import HARDENED, coininfo @@ -10,8 +10,7 @@ from apps.common.keychain import get_keychain from apps.common.paths import AlwaysMatchingSchema if False: - from trezor.messages.IdentityType import IdentityType - from trezor.messages.SignIdentity import SignIdentity + from trezor.messages import IdentityType, SignIdentity from apps.common.paths import Bip32Path diff --git a/core/src/apps/monero/diag.py b/core/src/apps/monero/diag.py index 50de2687a..18ccb2f00 100644 --- a/core/src/apps/monero/diag.py +++ b/core/src/apps/monero/diag.py @@ -36,7 +36,7 @@ if __debug__: PREV_MEM = free def retit(**kwargs): - from trezor.messages.Failure import Failure + from trezor.messages import Failure return Failure(**kwargs) diff --git a/core/src/apps/monero/get_address.py b/core/src/apps/monero/get_address.py index 1ee3daf15..e2b3a177b 100644 --- a/core/src/apps/monero/get_address.py +++ b/core/src/apps/monero/get_address.py @@ -1,4 +1,4 @@ -from trezor.messages.MoneroAddress import MoneroAddress +from trezor.messages import MoneroAddress from apps.common import paths from apps.common.keychain import auto_keychain diff --git a/core/src/apps/monero/get_tx_keys.py b/core/src/apps/monero/get_tx_keys.py index 748fdebc4..9c3911f99 100644 --- a/core/src/apps/monero/get_tx_keys.py +++ b/core/src/apps/monero/get_tx_keys.py @@ -16,8 +16,7 @@ using the view key, which the host possess. """ from trezor import utils -from trezor.messages.MoneroGetTxKeyAck import MoneroGetTxKeyAck -from trezor.messages.MoneroGetTxKeyRequest import MoneroGetTxKeyRequest +from trezor.messages import MoneroGetTxKeyAck, MoneroGetTxKeyRequest from apps.common import paths from apps.common.keychain import auto_keychain diff --git a/core/src/apps/monero/get_watch_only.py b/core/src/apps/monero/get_watch_only.py index ca621036c..2a9ab0a6d 100644 --- a/core/src/apps/monero/get_watch_only.py +++ b/core/src/apps/monero/get_watch_only.py @@ -1,5 +1,4 @@ -from trezor.messages.MoneroGetWatchKey import MoneroGetWatchKey -from trezor.messages.MoneroWatchKey import MoneroWatchKey +from trezor.messages import MoneroGetWatchKey, MoneroWatchKey from apps.common import paths from apps.common.keychain import auto_keychain diff --git a/core/src/apps/monero/key_image_sync.py b/core/src/apps/monero/key_image_sync.py index 526d0d016..9ecec2367 100644 --- a/core/src/apps/monero/key_image_sync.py +++ b/core/src/apps/monero/key_image_sync.py @@ -1,14 +1,14 @@ import gc from trezor import log, wire -from trezor.messages.MoneroExportedKeyImage import MoneroExportedKeyImage -from trezor.messages.MoneroKeyImageExportInitAck import MoneroKeyImageExportInitAck -from trezor.messages.MoneroKeyImageSyncFinalAck import MoneroKeyImageSyncFinalAck -from trezor.messages.MoneroKeyImageSyncFinalRequest import ( +from trezor.messages import ( + MoneroExportedKeyImage, + MoneroKeyImageExportInitAck, + MoneroKeyImageSyncFinalAck, MoneroKeyImageSyncFinalRequest, + MoneroKeyImageSyncStepAck, + MoneroKeyImageSyncStepRequest, ) -from trezor.messages.MoneroKeyImageSyncStepAck import MoneroKeyImageSyncStepAck -from trezor.messages.MoneroKeyImageSyncStepRequest import MoneroKeyImageSyncStepRequest from apps.common import paths from apps.common.keychain import auto_keychain diff --git a/core/src/apps/monero/layout/common.py b/core/src/apps/monero/layout/common.py index f155374bd..e20bff1c8 100644 --- a/core/src/apps/monero/layout/common.py +++ b/core/src/apps/monero/layout/common.py @@ -1,5 +1,5 @@ from trezor import strings, ui, utils -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.text import Text from apps.common import button_request diff --git a/core/src/apps/monero/layout/confirms.py b/core/src/apps/monero/layout/confirms.py index d9e8e0a9e..fd9c21922 100644 --- a/core/src/apps/monero/layout/confirms.py +++ b/core/src/apps/monero/layout/confirms.py @@ -1,7 +1,7 @@ from ubinascii import hexlify from trezor import ui, wire -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.text import Text from trezor.ui.layouts import confirm_action from trezor.ui.popup import Popup @@ -15,8 +15,8 @@ DUMMY_PAYMENT_ID = b"\x00\x00\x00\x00\x00\x00\x00\x00" if False: from apps.monero.signing.state import State - from trezor.messages.MoneroTransactionData import MoneroTransactionData - from trezor.messages.MoneroTransactionDestinationEntry import ( + from trezor.messages import ( + MoneroTransactionData, MoneroTransactionDestinationEntry, ) @@ -248,7 +248,7 @@ async def show_address( ctx, address: str, desc: str = "Confirm address", network: str = None ): from apps.common.confirm import confirm - from trezor.messages import ButtonRequestType + from trezor.enums import ButtonRequestType from trezor.ui.components.tt.button import ButtonDefault from trezor.ui.components.tt.scroll import Paginated diff --git a/core/src/apps/monero/live_refresh.py b/core/src/apps/monero/live_refresh.py index d0a3342cf..a0203dd85 100644 --- a/core/src/apps/monero/live_refresh.py +++ b/core/src/apps/monero/live_refresh.py @@ -2,12 +2,14 @@ import gc import storage.cache from trezor import log -from trezor.messages import MessageType -from trezor.messages.MoneroLiveRefreshFinalAck import MoneroLiveRefreshFinalAck -from trezor.messages.MoneroLiveRefreshStartAck import MoneroLiveRefreshStartAck -from trezor.messages.MoneroLiveRefreshStartRequest import MoneroLiveRefreshStartRequest -from trezor.messages.MoneroLiveRefreshStepAck import MoneroLiveRefreshStepAck -from trezor.messages.MoneroLiveRefreshStepRequest import MoneroLiveRefreshStepRequest +from trezor.enums import MessageType +from trezor.messages import ( + MoneroLiveRefreshFinalAck, + MoneroLiveRefreshStartAck, + MoneroLiveRefreshStartRequest, + MoneroLiveRefreshStepAck, + MoneroLiveRefreshStepRequest, +) from apps.common import paths from apps.common.keychain import auto_keychain diff --git a/core/src/apps/monero/sign_tx.py b/core/src/apps/monero/sign_tx.py index 9df21a640..108bb3e61 100644 --- a/core/src/apps/monero/sign_tx.py +++ b/core/src/apps/monero/sign_tx.py @@ -1,7 +1,7 @@ import gc from trezor import log, utils, wire -from trezor.messages import MessageType +from trezor.enums import MessageType from apps.common.keychain import auto_keychain from apps.monero.signing.state import State diff --git a/core/src/apps/monero/signing/offloading_keys.py b/core/src/apps/monero/signing/offloading_keys.py index 8fee2a8a4..4101c4752 100644 --- a/core/src/apps/monero/signing/offloading_keys.py +++ b/core/src/apps/monero/signing/offloading_keys.py @@ -6,11 +6,9 @@ from apps.monero.xmr import crypto if False: from apps.monero.xmr.types import Sc25519 - from trezor.messages.MoneroTransactionSourceEntry import ( - MoneroTransactionSourceEntry, - ) - from trezor.messages.MoneroTransactionDestinationEntry import ( + from trezor.messages import ( MoneroTransactionDestinationEntry, + MoneroTransactionSourceEntry, ) diff --git a/core/src/apps/monero/signing/step_01_init_transaction.py b/core/src/apps/monero/signing/step_01_init_transaction.py index 87d0a37c1..4e9fe2dc5 100644 --- a/core/src/apps/monero/signing/step_01_init_transaction.py +++ b/core/src/apps/monero/signing/step_01_init_transaction.py @@ -11,13 +11,13 @@ from apps.monero.xmr import crypto, monero if False: from apps.monero.xmr.types import Sc25519, Ge25519 - from trezor.messages.MoneroTransactionData import MoneroTransactionData - from trezor.messages.MoneroTransactionRsigData import MoneroTransactionRsigData - from trezor.messages.MoneroAccountPublicAddress import MoneroAccountPublicAddress - from trezor.messages.MoneroTransactionDestinationEntry import ( + from trezor.messages import ( + MoneroAccountPublicAddress, + MoneroTransactionData, MoneroTransactionDestinationEntry, + MoneroTransactionInitAck, + MoneroTransactionRsigData, ) - from trezor.messages.MoneroTransactionInitAck import MoneroTransactionInitAck async def init_transaction( @@ -113,8 +113,10 @@ async def init_transaction( state.mem_trace(6) - from trezor.messages.MoneroTransactionInitAck import MoneroTransactionInitAck - from trezor.messages.MoneroTransactionRsigData import MoneroTransactionRsigData + from trezor.messages import ( + MoneroTransactionInitAck, + MoneroTransactionRsigData, + ) rsig_data = MoneroTransactionRsigData(offload_type=int(state.rsig_offload)) @@ -170,7 +172,7 @@ def _get_primary_change_address(state: State) -> MoneroAccountPublicAddress: """ Computes primary change address for the current account index """ - from trezor.messages.MoneroAccountPublicAddress import MoneroAccountPublicAddress + from trezor.messages import MoneroAccountPublicAddress D, C = monero.generate_sub_address_keys( state.creds.view_key_private, state.creds.spend_key_public, state.account_idx, 0 @@ -363,7 +365,7 @@ def _get_key_for_payment_id_encryption( dummy payment ID is set for better transaction uniformity if possible. """ from apps.monero.xmr.addresses import addr_eq - from trezor.messages.MoneroAccountPublicAddress import MoneroAccountPublicAddress + from trezor.messages import MoneroAccountPublicAddress addr = MoneroAccountPublicAddress( spend_public_key=crypto.NULL_KEY_ENC, view_public_key=crypto.NULL_KEY_ENC diff --git a/core/src/apps/monero/signing/step_02_set_input.py b/core/src/apps/monero/signing/step_02_set_input.py index 7b9c80c7d..a7bb84cd7 100644 --- a/core/src/apps/monero/signing/step_02_set_input.py +++ b/core/src/apps/monero/signing/step_02_set_input.py @@ -18,20 +18,14 @@ from .state import State if False: from apps.monero.xmr.types import Sc25519, Ge25519 - from trezor.messages.MoneroTransactionSourceEntry import ( - MoneroTransactionSourceEntry, - ) - from trezor.messages.MoneroTransactionSetInputAck import ( - MoneroTransactionSetInputAck, - ) + from trezor.messages import MoneroTransactionSourceEntry + from trezor.messages import MoneroTransactionSetInputAck async def set_input( state: State, src_entr: MoneroTransactionSourceEntry ) -> MoneroTransactionSetInputAck: - from trezor.messages.MoneroTransactionSetInputAck import ( - MoneroTransactionSetInputAck, - ) + from trezor.messages import MoneroTransactionSetInputAck from apps.monero.xmr.crypto import chacha_poly from apps.monero.xmr.serialize_messages.tx_prefix import TxinToKey from apps.monero.signing import offloading_keys diff --git a/core/src/apps/monero/signing/step_03_inputs_permutation.py b/core/src/apps/monero/signing/step_03_inputs_permutation.py index 9f2ff7481..9974f95c4 100644 --- a/core/src/apps/monero/signing/step_03_inputs_permutation.py +++ b/core/src/apps/monero/signing/step_03_inputs_permutation.py @@ -21,17 +21,13 @@ from apps.monero.layout.confirms import transaction_step from .state import State if False: - from trezor.messages.MoneroTransactionInputsPermutationAck import ( - MoneroTransactionInputsPermutationAck, - ) + from trezor.messages import MoneroTransactionInputsPermutationAck async def tsx_inputs_permutation( state: State, permutation: list[int] ) -> MoneroTransactionInputsPermutationAck: - from trezor.messages.MoneroTransactionInputsPermutationAck import ( - MoneroTransactionInputsPermutationAck, - ) + from trezor.messages import MoneroTransactionInputsPermutationAck await transaction_step(state, state.STEP_PERM) diff --git a/core/src/apps/monero/signing/step_04_input_vini.py b/core/src/apps/monero/signing/step_04_input_vini.py index c775e8fbe..b049aa038 100644 --- a/core/src/apps/monero/signing/step_04_input_vini.py +++ b/core/src/apps/monero/signing/step_04_input_vini.py @@ -10,11 +10,9 @@ from apps.monero.xmr import crypto from .state import State if False: - from trezor.messages.MoneroTransactionSourceEntry import ( - MoneroTransactionSourceEntry, - ) - from trezor.messages.MoneroTransactionInputViniAck import ( + from trezor.messages import ( MoneroTransactionInputViniAck, + MoneroTransactionSourceEntry, ) @@ -25,9 +23,7 @@ async def input_vini( vini_hmac: bytes, orig_idx: int, ) -> MoneroTransactionInputViniAck: - from trezor.messages.MoneroTransactionInputViniAck import ( - MoneroTransactionInputViniAck, - ) + from trezor.messages import MoneroTransactionInputViniAck await confirms.transaction_step( state, state.STEP_VINI, state.current_input_index + 1 diff --git a/core/src/apps/monero/signing/step_05_all_inputs_set.py b/core/src/apps/monero/signing/step_05_all_inputs_set.py index 27dd1edaa..71448c5bd 100644 --- a/core/src/apps/monero/signing/step_05_all_inputs_set.py +++ b/core/src/apps/monero/signing/step_05_all_inputs_set.py @@ -9,9 +9,7 @@ from apps.monero.xmr import crypto from .state import State if False: - from trezor.messages.MoneroTransactionAllInputsSetAck import ( - MoneroTransactionAllInputsSetAck, - ) + from trezor.messages import MoneroTransactionAllInputsSetAck async def all_inputs_set(state: State) -> MoneroTransactionAllInputsSetAck: @@ -19,9 +17,7 @@ async def all_inputs_set(state: State) -> MoneroTransactionAllInputsSetAck: await confirms.transaction_step(state, state.STEP_ALL_IN) - from trezor.messages.MoneroTransactionAllInputsSetAck import ( - MoneroTransactionAllInputsSetAck, - ) + from trezor.messages import MoneroTransactionAllInputsSetAck if state.last_step != state.STEP_VINI: raise ValueError("Invalid state transition") diff --git a/core/src/apps/monero/signing/step_06_set_output.py b/core/src/apps/monero/signing/step_06_set_output.py index c260c6962..f4165c543 100644 --- a/core/src/apps/monero/signing/step_06_set_output.py +++ b/core/src/apps/monero/signing/step_06_set_output.py @@ -17,13 +17,11 @@ if False: from apps.monero.xmr.types import Sc25519, Ge25519 from apps.monero.xmr.serialize_messages.tx_ecdh import EcdhTuple from apps.monero.xmr.serialize_messages.tx_rsig_bulletproof import Bulletproof - from trezor.messages.MoneroTransactionDestinationEntry import ( + from trezor.messages import ( MoneroTransactionDestinationEntry, - ) - from trezor.messages.MoneroTransactionSetOutputAck import ( MoneroTransactionSetOutputAck, + MoneroTransactionRsigData, ) - from trezor.messages.MoneroTransactionRsigData import MoneroTransactionRsigData async def set_output( @@ -71,9 +69,7 @@ async def set_output( # If det masks & offloading, return as we are handling offloaded BP. if state.is_processing_offloaded: - from trezor.messages.MoneroTransactionSetOutputAck import ( - MoneroTransactionSetOutputAck, - ) + from trezor.messages import MoneroTransactionSetOutputAck return MoneroTransactionSetOutputAck() @@ -103,9 +99,7 @@ async def set_output( state.last_step = state.STEP_OUT state.mem_trace(14, True) - from trezor.messages.MoneroTransactionSetOutputAck import ( - MoneroTransactionSetOutputAck, - ) + from trezor.messages import MoneroTransactionSetOutputAck out_pk_bin = bytearray(64) utils.memcpy(out_pk_bin, 0, out_pk_dest, 0, 32) @@ -397,7 +391,7 @@ def _return_rsig_data( if rsig is None and mask is None: return None - from trezor.messages.MoneroTransactionRsigData import MoneroTransactionRsigData + from trezor.messages import MoneroTransactionRsigData rsig_data = MoneroTransactionRsigData() diff --git a/core/src/apps/monero/signing/step_07_all_outputs_set.py b/core/src/apps/monero/signing/step_07_all_outputs_set.py index a2b77feb2..e739f2f57 100644 --- a/core/src/apps/monero/signing/step_07_all_outputs_set.py +++ b/core/src/apps/monero/signing/step_07_all_outputs_set.py @@ -14,9 +14,7 @@ from apps.monero.xmr import crypto from .state import State if False: - from trezor.messages.MoneroTransactionAllOutSetAck import ( - MoneroTransactionAllOutSetAck, - ) + from trezor.messages import MoneroTransactionAllOutSetAck async def all_outputs_set(state: State) -> MoneroTransactionAllOutSetAck: @@ -48,10 +46,8 @@ async def all_outputs_set(state: State) -> MoneroTransactionAllOutSetAck: # transaction prefix matches expected transaction prefix sent in the # init step. - from trezor.messages.MoneroRingCtSig import MoneroRingCtSig - from trezor.messages.MoneroTransactionAllOutSetAck import ( - MoneroTransactionAllOutSetAck, - ) + from trezor.messages import MoneroRingCtSig + from trezor.messages import MoneroTransactionAllOutSetAck # Initializes RCTsig structure (fee, tx prefix hash, type) rv_pb = MoneroRingCtSig( diff --git a/core/src/apps/monero/signing/step_09_sign_input.py b/core/src/apps/monero/signing/step_09_sign_input.py index 4435550f4..01141e5a8 100644 --- a/core/src/apps/monero/signing/step_09_sign_input.py +++ b/core/src/apps/monero/signing/step_09_sign_input.py @@ -20,12 +20,8 @@ from apps.monero.xmr import crypto from .state import State if False: - from trezor.messages.MoneroTransactionSourceEntry import ( - MoneroTransactionSourceEntry, - ) - from trezor.messages.MoneroTransactionSignInputAck import ( - MoneroTransactionSignInputAck, - ) + from trezor.messages import MoneroTransactionSourceEntry + from trezor.messages import MoneroTransactionSignInputAck async def sign_input( @@ -207,9 +203,7 @@ async def sign_input( del (CtKey, input_secret_key, pseudo_out_alpha, mlsag, ring_pubkeys) state.mem_trace(6, True) - from trezor.messages.MoneroTransactionSignInputAck import ( - MoneroTransactionSignInputAck, - ) + from trezor.messages import MoneroTransactionSignInputAck # Encrypt signature, reveal once protocol finishes OK if state.client_version >= 3: diff --git a/core/src/apps/monero/signing/step_10_sign_final.py b/core/src/apps/monero/signing/step_10_sign_final.py index 2c373e0c9..cdcb9dcec 100644 --- a/core/src/apps/monero/signing/step_10_sign_final.py +++ b/core/src/apps/monero/signing/step_10_sign_final.py @@ -8,7 +8,7 @@ so we can recover it just from the transaction and the spend key. The private tx keys are used in other numerous Monero features. """ -from trezor.messages.MoneroTransactionFinalAck import MoneroTransactionFinalAck +from trezor.messages import MoneroTransactionFinalAck from apps.monero import misc from apps.monero.xmr import crypto diff --git a/core/src/apps/monero/xmr/addresses.py b/core/src/apps/monero/xmr/addresses.py index 936a8a631..a6c5a9579 100644 --- a/core/src/apps/monero/xmr/addresses.py +++ b/core/src/apps/monero/xmr/addresses.py @@ -4,10 +4,8 @@ from apps.monero.xmr.networks import NetworkTypes, net_version if False: from apps.monero.xmr.types import Ge25519 - from trezor.messages.MoneroAccountPublicAddress import MoneroAccountPublicAddress - from trezor.messages.MoneroTransactionDestinationEntry import ( - MoneroTransactionDestinationEntry, - ) + from trezor.messages import MoneroAccountPublicAddress + from trezor.messages import MoneroTransactionDestinationEntry def addr_to_hash(addr: MoneroAccountPublicAddress) -> bytes: diff --git a/core/src/apps/monero/xmr/key_image.py b/core/src/apps/monero/xmr/key_image.py index 78e58bf19..3ad3967cc 100644 --- a/core/src/apps/monero/xmr/key_image.py +++ b/core/src/apps/monero/xmr/key_image.py @@ -4,7 +4,7 @@ from apps.monero.xmr.serialize.int_serialize import dump_uvarint_b if False: from apps.monero.xmr.types import Ge25519, Sc25519 from apps.monero.xmr.credentials import AccountCreds - from trezor.messages.MoneroTransferDetails import MoneroTransferDetails + from trezor.messages import MoneroTransferDetails Subaddresses = dict[bytes, tuple[int, int]] Sig = list[list[Sc25519]] diff --git a/core/src/apps/monero/xmr/mlsag.py b/core/src/apps/monero/xmr/mlsag.py index e286e0339..f81203775 100644 --- a/core/src/apps/monero/xmr/mlsag.py +++ b/core/src/apps/monero/xmr/mlsag.py @@ -50,7 +50,7 @@ from apps.monero.xmr.serialize import int_serialize if False: from apps.monero.xmr.types import Ge25519, Sc25519 from apps.monero.xmr.serialize_messages.tx_ct_key import CtKey - from trezor.messages.MoneroRctKeyPublic import MoneroRctKeyPublic + from trezor.messages import MoneroRctKeyPublic KeyM = list[list[bytes]] diff --git a/core/src/apps/nem/get_address.py b/core/src/apps/nem/get_address.py index 16391e3ce..b1a08c31b 100644 --- a/core/src/apps/nem/get_address.py +++ b/core/src/apps/nem/get_address.py @@ -1,4 +1,4 @@ -from trezor.messages.NEMAddress import NEMAddress +from trezor.messages import NEMAddress from trezor.ui.layouts import show_address from apps.common.keychain import with_slip44_keychain diff --git a/core/src/apps/nem/layout.py b/core/src/apps/nem/layout.py index 564600db2..6dad04c88 100644 --- a/core/src/apps/nem/layout.py +++ b/core/src/apps/nem/layout.py @@ -1,5 +1,5 @@ from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.strings import format_amount from trezor.ui.components.tt.text import Text diff --git a/core/src/apps/nem/mosaic/__init__.py b/core/src/apps/nem/mosaic/__init__.py index 0a152a22c..4190e3a79 100644 --- a/core/src/apps/nem/mosaic/__init__.py +++ b/core/src/apps/nem/mosaic/__init__.py @@ -1,6 +1,8 @@ -from trezor.messages.NEMMosaicCreation import NEMMosaicCreation -from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import ( + NEMMosaicCreation, + NEMMosaicSupplyChange, + NEMTransactionCommon, +) from . import layout, serialize diff --git a/core/src/apps/nem/mosaic/layout.py b/core/src/apps/nem/mosaic/layout.py index 8f2c41fda..9d207ee8d 100644 --- a/core/src/apps/nem/mosaic/layout.py +++ b/core/src/apps/nem/mosaic/layout.py @@ -1,11 +1,9 @@ from trezor import ui +from trezor.enums import ButtonRequestType, NEMMosaicLevy, NEMSupplyChangeType from trezor.messages import ( - ButtonRequestType, NEMMosaicCreation, NEMMosaicDefinition, - NEMMosaicLevy, NEMMosaicSupplyChange, - NEMSupplyChangeType, NEMTransactionCommon, ) from trezor.ui.components.tt.scroll import Paginated diff --git a/core/src/apps/nem/mosaic/serialize.py b/core/src/apps/nem/mosaic/serialize.py index 29e84f30d..1c86e0912 100644 --- a/core/src/apps/nem/mosaic/serialize.py +++ b/core/src/apps/nem/mosaic/serialize.py @@ -1,6 +1,8 @@ -from trezor.messages.NEMMosaicCreation import NEMMosaicCreation -from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import ( + NEMMosaicCreation, + NEMMosaicSupplyChange, + NEMTransactionCommon, +) from ..helpers import ( NEM_TRANSACTION_TYPE_MOSAIC_CREATION, diff --git a/core/src/apps/nem/multisig/__init__.py b/core/src/apps/nem/multisig/__init__.py index 673642751..f9859fb92 100644 --- a/core/src/apps/nem/multisig/__init__.py +++ b/core/src/apps/nem/multisig/__init__.py @@ -1,6 +1,4 @@ -from trezor.messages.NEMAggregateModification import NEMAggregateModification -from trezor.messages.NEMSignTx import NEMSignTx -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import NEMAggregateModification, NEMSignTx, NEMTransactionCommon from . import layout, serialize diff --git a/core/src/apps/nem/multisig/layout.py b/core/src/apps/nem/multisig/layout.py index 4757dece1..108b011d3 100644 --- a/core/src/apps/nem/multisig/layout.py +++ b/core/src/apps/nem/multisig/layout.py @@ -1,12 +1,7 @@ from trezor import ui from trezor.crypto import nem -from trezor.messages import ( - ButtonRequestType, - NEMAggregateModification, - NEMModificationType, - NEMSignTx, - NEMTransactionCommon, -) +from trezor.enums import ButtonRequestType, NEMModificationType +from trezor.messages import NEMAggregateModification, NEMSignTx, NEMTransactionCommon from trezor.ui.components.tt.text import Text from apps.common.layout import split_address diff --git a/core/src/apps/nem/multisig/serialize.py b/core/src/apps/nem/multisig/serialize.py index d00d37bcc..6f7cb09eb 100644 --- a/core/src/apps/nem/multisig/serialize.py +++ b/core/src/apps/nem/multisig/serialize.py @@ -1,6 +1,5 @@ from trezor.crypto import hashlib, nem -from trezor.messages.NEMAggregateModification import NEMAggregateModification -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import NEMAggregateModification, NEMTransactionCommon from ..helpers import ( NEM_TRANSACTION_TYPE_AGGREGATE_MODIFICATION, diff --git a/core/src/apps/nem/namespace/__init__.py b/core/src/apps/nem/namespace/__init__.py index d61bcd315..1cc3e3f5e 100644 --- a/core/src/apps/nem/namespace/__init__.py +++ b/core/src/apps/nem/namespace/__init__.py @@ -1,5 +1,4 @@ -from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon from . import layout, serialize diff --git a/core/src/apps/nem/namespace/serialize.py b/core/src/apps/nem/namespace/serialize.py index 49c26bc4b..3ee850822 100644 --- a/core/src/apps/nem/namespace/serialize.py +++ b/core/src/apps/nem/namespace/serialize.py @@ -1,5 +1,4 @@ -from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon from ..helpers import NEM_TRANSACTION_TYPE_PROVISION_NAMESPACE from ..writers import ( diff --git a/core/src/apps/nem/sign_tx.py b/core/src/apps/nem/sign_tx.py index bb211dde8..ac9684e0e 100644 --- a/core/src/apps/nem/sign_tx.py +++ b/core/src/apps/nem/sign_tx.py @@ -1,7 +1,6 @@ from trezor import wire from trezor.crypto.curve import ed25519 -from trezor.messages.NEMSignedTx import NEMSignedTx -from trezor.messages.NEMSignTx import NEMSignTx +from trezor.messages import NEMSignedTx, NEMSignTx from apps.common import seed from apps.common.keychain import with_slip44_keychain diff --git a/core/src/apps/nem/transfer/__init__.py b/core/src/apps/nem/transfer/__init__.py index 5a0a61a3a..ab111df8e 100644 --- a/core/src/apps/nem/transfer/__init__.py +++ b/core/src/apps/nem/transfer/__init__.py @@ -1,6 +1,4 @@ -from trezor.messages.NEMImportanceTransfer import NEMImportanceTransfer -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon -from trezor.messages.NEMTransfer import NEMTransfer +from trezor.messages import NEMImportanceTransfer, NEMTransactionCommon, NEMTransfer from . import layout, serialize diff --git a/core/src/apps/nem/transfer/layout.py b/core/src/apps/nem/transfer/layout.py index cdc2dc568..7ffa9d344 100644 --- a/core/src/apps/nem/transfer/layout.py +++ b/core/src/apps/nem/transfer/layout.py @@ -1,10 +1,8 @@ from trezor import ui +from trezor.enums import ButtonRequestType, NEMImportanceTransferMode, NEMMosaicLevy from trezor.messages import ( - ButtonRequestType, NEMImportanceTransfer, - NEMImportanceTransferMode, NEMMosaic, - NEMMosaicLevy, NEMTransactionCommon, NEMTransfer, ) diff --git a/core/src/apps/nem/transfer/serialize.py b/core/src/apps/nem/transfer/serialize.py index 0f68b6c65..7ab7985ed 100644 --- a/core/src/apps/nem/transfer/serialize.py +++ b/core/src/apps/nem/transfer/serialize.py @@ -1,8 +1,10 @@ from trezor.crypto import random -from trezor.messages.NEMImportanceTransfer import NEMImportanceTransfer -from trezor.messages.NEMMosaic import NEMMosaic -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon -from trezor.messages.NEMTransfer import NEMTransfer +from trezor.messages import ( + NEMImportanceTransfer, + NEMMosaic, + NEMTransactionCommon, + NEMTransfer, +) from ..helpers import ( AES_BLOCK_SIZE, diff --git a/core/src/apps/nem/validators.py b/core/src/apps/nem/validators.py index 50d4bce6e..419b95de1 100644 --- a/core/src/apps/nem/validators.py +++ b/core/src/apps/nem/validators.py @@ -1,6 +1,6 @@ from trezor.crypto import nem -from trezor.messages import NEMModificationType, NEMSupplyChangeType -from trezor.messages.NEMSignTx import ( +from trezor.enums import NEMModificationType, NEMSupplyChangeType +from trezor.messages import ( NEMAggregateModification, NEMImportanceTransfer, NEMMosaicCreation, diff --git a/core/src/apps/nem/writers.py b/core/src/apps/nem/writers.py index f049a8512..3e6a57d85 100644 --- a/core/src/apps/nem/writers.py +++ b/core/src/apps/nem/writers.py @@ -1,4 +1,4 @@ -from trezor.messages.NEMTransactionCommon import NEMTransactionCommon +from trezor.messages import NEMTransactionCommon from apps.common.writers import write_bytes_unchecked, write_uint32_le, write_uint64_le diff --git a/core/src/apps/ripple/get_address.py b/core/src/apps/ripple/get_address.py index 9df6a1c49..405afae24 100644 --- a/core/src/apps/ripple/get_address.py +++ b/core/src/apps/ripple/get_address.py @@ -1,5 +1,4 @@ -from trezor.messages.RippleAddress import RippleAddress -from trezor.messages.RippleGetAddress import RippleGetAddress +from trezor.messages import RippleAddress, RippleGetAddress from trezor.ui.layouts import show_address from apps.common import paths diff --git a/core/src/apps/ripple/layout.py b/core/src/apps/ripple/layout.py index 46ba7a1fc..b5270dbcd 100644 --- a/core/src/apps/ripple/layout.py +++ b/core/src/apps/ripple/layout.py @@ -1,5 +1,5 @@ from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.strings import format_amount from trezor.ui.components.tt.text import Text diff --git a/core/src/apps/ripple/serialize.py b/core/src/apps/ripple/serialize.py index 56b82b28c..0ae6afa9e 100644 --- a/core/src/apps/ripple/serialize.py +++ b/core/src/apps/ripple/serialize.py @@ -8,7 +8,7 @@ # the actual data follow. This currently only supports the Payment # transaction type and the fields that are required for it. -from trezor.messages.RippleSignTx import RippleSignTx +from trezor.messages import RippleSignTx from . import helpers diff --git a/core/src/apps/ripple/sign_tx.py b/core/src/apps/ripple/sign_tx.py index ab108fc5b..93ba7541c 100644 --- a/core/src/apps/ripple/sign_tx.py +++ b/core/src/apps/ripple/sign_tx.py @@ -1,8 +1,7 @@ from trezor.crypto import der from trezor.crypto.curve import secp256k1 from trezor.crypto.hashlib import sha512 -from trezor.messages.RippleSignedTx import RippleSignedTx -from trezor.messages.RippleSignTx import RippleSignTx +from trezor.messages import RippleSignedTx, RippleSignTx from trezor.wire import ProcessError from apps.common import paths diff --git a/core/src/apps/stellar/consts.py b/core/src/apps/stellar/consts.py index 8055c97e3..0faf1f8b3 100644 --- a/core/src/apps/stellar/consts.py +++ b/core/src/apps/stellar/consts.py @@ -1,23 +1,23 @@ from micropython import const -from trezor.messages import MessageType +from trezor.enums import MessageType TX_TYPE = bytearray("\x00\x00\x00\x02") # source: https://github.com/stellar/go/blob/3d2c1defe73dbfed00146ebe0e8d7e07ce4bb1b6/xdr/Stellar-transaction.x#L16 # Inflation not supported see https://github.com/trezor/trezor-core/issues/202#issuecomment-393342089 op_codes = { - "StellarAccountMergeOp": const(8), - "StellarAllowTrustOp": const(7), - "StellarBumpSequenceOp": const(11), - "StellarChangeTrustOp": const(6), - "StellarCreateAccountOp": const(0), - "StellarCreatePassiveOfferOp": const(4), - "StellarManageDataOp": const(10), - "StellarManageOfferOp": const(3), - "StellarPathPaymentOp": const(2), - "StellarPaymentOp": const(1), - "StellarSetOptionsOp": const(5), + MessageType.StellarAccountMergeOp: 8, + MessageType.StellarAllowTrustOp: 7, + MessageType.StellarBumpSequenceOp: 11, + MessageType.StellarChangeTrustOp: 6, + MessageType.StellarCreateAccountOp: 0, + MessageType.StellarCreatePassiveOfferOp: 4, + MessageType.StellarManageDataOp: 10, + MessageType.StellarManageOfferOp: 3, + MessageType.StellarPathPaymentOp: 2, + MessageType.StellarPaymentOp: 1, + MessageType.StellarSetOptionsOp: 5, } op_wire_types = [ @@ -69,6 +69,7 @@ SIGN_TYPES = (SIGN_TYPE_ACCOUNT, SIGN_TYPE_HASH, SIGN_TYPE_PRE_AUTH) def get_op_code(msg) -> int: - if msg.__qualname__ not in op_codes: + wire = msg.MESSAGE_WIRE_TYPE + if wire not in op_codes: raise ValueError("Stellar: op code unknown") - return op_codes[msg.__qualname__] + return op_codes[wire] diff --git a/core/src/apps/stellar/get_address.py b/core/src/apps/stellar/get_address.py index 5b0468ea1..5a988fd3b 100644 --- a/core/src/apps/stellar/get_address.py +++ b/core/src/apps/stellar/get_address.py @@ -1,5 +1,4 @@ -from trezor.messages.StellarAddress import StellarAddress -from trezor.messages.StellarGetAddress import StellarGetAddress +from trezor.messages import StellarAddress, StellarGetAddress from trezor.ui.layouts import show_address from apps.common import paths, seed diff --git a/core/src/apps/stellar/layout.py b/core/src/apps/stellar/layout.py index bd4f12834..5b1052fa7 100644 --- a/core/src/apps/stellar/layout.py +++ b/core/src/apps/stellar/layout.py @@ -1,5 +1,5 @@ from trezor import strings, ui, utils -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.components.tt.text import Text from apps.common.confirm import require_confirm, require_hold_to_confirm diff --git a/core/src/apps/stellar/operations/__init__.py b/core/src/apps/stellar/operations/__init__.py index d8438baa4..5325da06d 100644 --- a/core/src/apps/stellar/operations/__init__.py +++ b/core/src/apps/stellar/operations/__init__.py @@ -7,37 +7,37 @@ async def process_operation(ctx, w, op): await layout.confirm_source_account(ctx, op.source_account) serialize.write_account(w, op.source_account) writers.write_uint32(w, consts.get_op_code(op)) - if isinstance(op, serialize.StellarAccountMergeOp): + if serialize.StellarAccountMergeOp.is_type_of(op): await layout.confirm_account_merge_op(ctx, op) serialize.write_account_merge_op(w, op) - elif isinstance(op, serialize.StellarAllowTrustOp): + elif serialize.StellarAllowTrustOp.is_type_of(op): await layout.confirm_allow_trust_op(ctx, op) serialize.write_allow_trust_op(w, op) - elif isinstance(op, serialize.StellarBumpSequenceOp): + elif serialize.StellarBumpSequenceOp.is_type_of(op): await layout.confirm_bump_sequence_op(ctx, op) serialize.write_bump_sequence_op(w, op) - elif isinstance(op, serialize.StellarChangeTrustOp): + elif serialize.StellarChangeTrustOp.is_type_of(op): await layout.confirm_change_trust_op(ctx, op) serialize.write_change_trust_op(w, op) - elif isinstance(op, serialize.StellarCreateAccountOp): + elif serialize.StellarCreateAccountOp.is_type_of(op): await layout.confirm_create_account_op(ctx, op) serialize.write_create_account_op(w, op) - elif isinstance(op, serialize.StellarCreatePassiveOfferOp): + elif serialize.StellarCreatePassiveOfferOp.is_type_of(op): await layout.confirm_create_passive_offer_op(ctx, op) serialize.write_create_passive_offer_op(w, op) - elif isinstance(op, serialize.StellarManageDataOp): + elif serialize.StellarManageDataOp.is_type_of(op): await layout.confirm_manage_data_op(ctx, op) serialize.write_manage_data_op(w, op) - elif isinstance(op, serialize.StellarManageOfferOp): + elif serialize.StellarManageOfferOp.is_type_of(op): await layout.confirm_manage_offer_op(ctx, op) serialize.write_manage_offer_op(w, op) - elif isinstance(op, serialize.StellarPathPaymentOp): + elif serialize.StellarPathPaymentOp.is_type_of(op): await layout.confirm_path_payment_op(ctx, op) serialize.write_path_payment_op(w, op) - elif isinstance(op, serialize.StellarPaymentOp): + elif serialize.StellarPaymentOp.is_type_of(op): await layout.confirm_payment_op(ctx, op) serialize.write_payment_op(w, op) - elif isinstance(op, serialize.StellarSetOptionsOp): + elif serialize.StellarSetOptionsOp.is_type_of(op): await layout.confirm_set_options_op(ctx, op) serialize.write_set_options_op(w, op) else: diff --git a/core/src/apps/stellar/operations/layout.py b/core/src/apps/stellar/operations/layout.py index 13c36b9ea..79acbbcea 100644 --- a/core/src/apps/stellar/operations/layout.py +++ b/core/src/apps/stellar/operations/layout.py @@ -1,18 +1,20 @@ from ubinascii import hexlify -from trezor.messages import ButtonRequestType -from trezor.messages.StellarAccountMergeOp import StellarAccountMergeOp -from trezor.messages.StellarAllowTrustOp import StellarAllowTrustOp -from trezor.messages.StellarAssetType import StellarAssetType -from trezor.messages.StellarBumpSequenceOp import StellarBumpSequenceOp -from trezor.messages.StellarChangeTrustOp import StellarChangeTrustOp -from trezor.messages.StellarCreateAccountOp import StellarCreateAccountOp -from trezor.messages.StellarCreatePassiveOfferOp import StellarCreatePassiveOfferOp -from trezor.messages.StellarManageDataOp import StellarManageDataOp -from trezor.messages.StellarManageOfferOp import StellarManageOfferOp -from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp -from trezor.messages.StellarPaymentOp import StellarPaymentOp -from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp +from trezor.enums import ButtonRequestType +from trezor.messages import ( + StellarAccountMergeOp, + StellarAllowTrustOp, + StellarAssetType, + StellarBumpSequenceOp, + StellarChangeTrustOp, + StellarCreateAccountOp, + StellarCreatePassiveOfferOp, + StellarManageDataOp, + StellarManageOfferOp, + StellarPathPaymentOp, + StellarPaymentOp, + StellarSetOptionsOp, +) from trezor.ui.components.tt.text import Text from trezor.wire import ProcessError diff --git a/core/src/apps/stellar/operations/serialize.py b/core/src/apps/stellar/operations/serialize.py index fc88ac750..fbd7f74e1 100644 --- a/core/src/apps/stellar/operations/serialize.py +++ b/core/src/apps/stellar/operations/serialize.py @@ -1,15 +1,17 @@ -from trezor.messages.StellarAccountMergeOp import StellarAccountMergeOp -from trezor.messages.StellarAllowTrustOp import StellarAllowTrustOp -from trezor.messages.StellarAssetType import StellarAssetType -from trezor.messages.StellarBumpSequenceOp import StellarBumpSequenceOp -from trezor.messages.StellarChangeTrustOp import StellarChangeTrustOp -from trezor.messages.StellarCreateAccountOp import StellarCreateAccountOp -from trezor.messages.StellarCreatePassiveOfferOp import StellarCreatePassiveOfferOp -from trezor.messages.StellarManageDataOp import StellarManageDataOp -from trezor.messages.StellarManageOfferOp import StellarManageOfferOp -from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp -from trezor.messages.StellarPaymentOp import StellarPaymentOp -from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp +from trezor.messages import ( + StellarAccountMergeOp, + StellarAllowTrustOp, + StellarAssetType, + StellarBumpSequenceOp, + StellarChangeTrustOp, + StellarCreateAccountOp, + StellarCreatePassiveOfferOp, + StellarManageDataOp, + StellarManageOfferOp, + StellarPathPaymentOp, + StellarPaymentOp, + StellarSetOptionsOp, +) from trezor.wire import ProcessError from .. import consts, writers diff --git a/core/src/apps/stellar/sign_tx.py b/core/src/apps/stellar/sign_tx.py index bf72d3531..418727cc3 100644 --- a/core/src/apps/stellar/sign_tx.py +++ b/core/src/apps/stellar/sign_tx.py @@ -2,9 +2,7 @@ from ubinascii import hexlify from trezor.crypto.curve import ed25519 from trezor.crypto.hashlib import sha256 -from trezor.messages.StellarSignedTx import StellarSignedTx -from trezor.messages.StellarSignTx import StellarSignTx -from trezor.messages.StellarTxOpRequest import StellarTxOpRequest +from trezor.messages import StellarSignedTx, StellarSignTx, StellarTxOpRequest from trezor.wire import ProcessError from apps.common import paths, seed diff --git a/core/src/apps/tezos/get_address.py b/core/src/apps/tezos/get_address.py index 3d31315d6..08a221dfc 100644 --- a/core/src/apps/tezos/get_address.py +++ b/core/src/apps/tezos/get_address.py @@ -1,5 +1,5 @@ from trezor.crypto import hashlib -from trezor.messages.TezosAddress import TezosAddress +from trezor.messages import TezosAddress from trezor.ui.layouts import show_address from apps.common import paths, seed diff --git a/core/src/apps/tezos/get_public_key.py b/core/src/apps/tezos/get_public_key.py index fbd043d97..87288ef06 100644 --- a/core/src/apps/tezos/get_public_key.py +++ b/core/src/apps/tezos/get_public_key.py @@ -1,4 +1,4 @@ -from trezor.messages.TezosPublicKey import TezosPublicKey +from trezor.messages import TezosPublicKey from trezor.ui.layouts import show_pubkey from apps.common import paths, seed diff --git a/core/src/apps/tezos/layout.py b/core/src/apps/tezos/layout.py index 41f1be629..181c6c68d 100644 --- a/core/src/apps/tezos/layout.py +++ b/core/src/apps/tezos/layout.py @@ -1,5 +1,5 @@ from trezor import ui -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.strings import format_amount from trezor.ui.components.tt.scroll import Paginated from trezor.ui.components.tt.text import Text diff --git a/core/src/apps/tezos/sign_tx.py b/core/src/apps/tezos/sign_tx.py index 011491c5e..16bdf2606 100644 --- a/core/src/apps/tezos/sign_tx.py +++ b/core/src/apps/tezos/sign_tx.py @@ -1,8 +1,8 @@ from trezor import wire from trezor.crypto import hashlib from trezor.crypto.curve import ed25519 -from trezor.messages import TezosBallotType, TezosContractType -from trezor.messages.TezosSignedTx import TezosSignedTx +from trezor.enums import TezosBallotType, TezosContractType +from trezor.messages import TezosSignedTx from apps.common import paths from apps.common.keychain import with_slip44_keychain diff --git a/core/src/apps/webauthn/add_resident_credential.py b/core/src/apps/webauthn/add_resident_credential.py index 3972b6a15..a9a2642fd 100644 --- a/core/src/apps/webauthn/add_resident_credential.py +++ b/core/src/apps/webauthn/add_resident_credential.py @@ -1,7 +1,6 @@ import storage.device from trezor import wire -from trezor.messages.Success import Success -from trezor.messages.WebAuthnAddResidentCredential import WebAuthnAddResidentCredential +from trezor.messages import Success, WebAuthnAddResidentCredential from trezor.ui.layouts import show_error_and_raise from apps.common.confirm import require_confirm diff --git a/core/src/apps/webauthn/list_resident_credentials.py b/core/src/apps/webauthn/list_resident_credentials.py index 9cee7fea1..9140d6a1b 100644 --- a/core/src/apps/webauthn/list_resident_credentials.py +++ b/core/src/apps/webauthn/list_resident_credentials.py @@ -1,7 +1,7 @@ from trezor import wire -from trezor.messages.WebAuthnCredential import WebAuthnCredential -from trezor.messages.WebAuthnCredentials import WebAuthnCredentials -from trezor.messages.WebAuthnListResidentCredentials import ( +from trezor.messages import ( + WebAuthnCredential, + WebAuthnCredentials, WebAuthnListResidentCredentials, ) from trezor.ui.layouts import confirm_action diff --git a/core/src/apps/webauthn/remove_resident_credential.py b/core/src/apps/webauthn/remove_resident_credential.py index c3c75bda3..5e102f138 100644 --- a/core/src/apps/webauthn/remove_resident_credential.py +++ b/core/src/apps/webauthn/remove_resident_credential.py @@ -1,10 +1,7 @@ import storage.device import storage.resident_credentials from trezor import wire -from trezor.messages.Success import Success -from trezor.messages.WebAuthnRemoveResidentCredential import ( - WebAuthnRemoveResidentCredential, -) +from trezor.messages import Success, WebAuthnRemoveResidentCredential from apps.common.confirm import require_confirm diff --git a/core/src/apps/workflow_handlers.py b/core/src/apps/workflow_handlers.py index f7b9e4b17..26d685573 100644 --- a/core/src/apps/workflow_handlers.py +++ b/core/src/apps/workflow_handlers.py @@ -1,5 +1,5 @@ from trezor import utils -from trezor.messages import MessageType +from trezor.enums import MessageType if False: from trezor.wire import Handler diff --git a/core/src/storage/device.py b/core/src/storage/device.py index 4e689f048..627786f4f 100644 --- a/core/src/storage/device.py +++ b/core/src/storage/device.py @@ -5,7 +5,7 @@ import storage.cache from storage import common if False: - from trezor.messages.ResetDevice import EnumTypeBackupType + from trezor.enums import BackupType from typing_extensions import Literal # Namespace: @@ -119,8 +119,8 @@ def get_mnemonic_secret() -> bytes | None: return common.get(_NAMESPACE, _MNEMONIC_SECRET) -def get_backup_type() -> EnumTypeBackupType: - from trezor.messages import BackupType +def get_backup_type() -> BackupType: + from trezor.enums import BackupType backup_type = common.get_uint8(_NAMESPACE, _BACKUP_TYPE) if backup_type is None: @@ -158,7 +158,7 @@ def set_homescreen(homescreen: bytes) -> None: def store_mnemonic_secret( secret: bytes, - backup_type: EnumTypeBackupType, + backup_type: BackupType, needs_backup: bool = False, no_backup: bool = False, ) -> None: diff --git a/core/src/trezor/ui/layouts/common.py b/core/src/trezor/ui/layouts/common.py index 74c0d0ca9..586f2ece7 100644 --- a/core/src/trezor/ui/layouts/common.py +++ b/core/src/trezor/ui/layouts/common.py @@ -1,13 +1,10 @@ from trezor import log, wire, workflow -from trezor.messages import ButtonRequestType -from trezor.messages.ButtonAck import ButtonAck -from trezor.messages.ButtonRequest import ButtonRequest +from trezor.enums import ButtonRequestType +from trezor.messages import ButtonAck, ButtonRequest if False: from typing import Any, Awaitable - from trezor.messages.ButtonRequest import EnumTypeButtonRequestType - LayoutType = Awaitable[Any] @@ -15,7 +12,7 @@ async def interact( ctx: wire.GenericContext, layout: LayoutType, brtype: str, - brcode: EnumTypeButtonRequestType = ButtonRequestType.Other, + brcode: ButtonRequestType = ButtonRequestType.Other, ) -> Any: log.debug(__name__, "ButtonRequest.type={}".format(brtype)) workflow.close_others() diff --git a/core/src/trezor/ui/layouts/t1.py b/core/src/trezor/ui/layouts/t1.py index 3c82e555f..d18224f6c 100644 --- a/core/src/trezor/ui/layouts/t1.py +++ b/core/src/trezor/ui/layouts/t1.py @@ -1,11 +1,9 @@ from trezor import ui, wire -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType if False: from typing import NoReturn, Type, Union - from trezor.messages.ButtonRequest import EnumTypeButtonRequestType - ExceptionType = Union[BaseException, Type[BaseException]] @@ -26,7 +24,7 @@ async def confirm_action( reverse: bool = False, larger_vspace: bool = False, exc: ExceptionType = wire.ActionCancelled, - br_code: EnumTypeButtonRequestType = ButtonRequestType.Other, + br_code: ButtonRequestType = ButtonRequestType.Other, ) -> None: raise NotImplementedError diff --git a/core/src/trezor/ui/layouts/tt.py b/core/src/trezor/ui/layouts/tt.py index 4ff7131a7..616737682 100644 --- a/core/src/trezor/ui/layouts/tt.py +++ b/core/src/trezor/ui/layouts/tt.py @@ -1,7 +1,7 @@ from micropython import const from trezor import ui, wire -from trezor.messages import ButtonRequestType +from trezor.enums import ButtonRequestType from trezor.ui.container import Container from trezor.ui.loader import LoaderDanger from trezor.ui.qr import Qr @@ -33,8 +33,6 @@ if False: NoReturn, ) - from trezor.messages.ButtonRequest import EnumTypeButtonRequestType - from ..components.common.text import TextContent ExceptionType = Union[BaseException, Type[BaseException]] @@ -82,7 +80,7 @@ async def confirm_action( reverse: bool = False, # TODO cleanup @ redesign larger_vspace: bool = False, # TODO cleanup @ redesign exc: ExceptionType = wire.ActionCancelled, - br_code: EnumTypeButtonRequestType = ButtonRequestType.Other, + br_code: ButtonRequestType = ButtonRequestType.Other, ) -> None: text = Text( title, @@ -340,7 +338,7 @@ def show_pubkey( async def _show_modal( ctx: wire.GenericContext, br_type: str, - br_code: EnumTypeButtonRequestType, + br_code: ButtonRequestType, header: str, subheader: str | None, content: str, @@ -400,7 +398,7 @@ def show_warning( header: str = "Warning", subheader: str | None = None, button: str = "Try again", - br_code: EnumTypeButtonRequestType = ButtonRequestType.Warning, + br_code: ButtonRequestType = ButtonRequestType.Warning, ) -> Awaitable[None]: return _show_modal( ctx, @@ -475,7 +473,7 @@ async def confirm_hex( title: str, data: str, description: str | None = None, - br_code: EnumTypeButtonRequestType = ButtonRequestType.Other, + br_code: ButtonRequestType = ButtonRequestType.Other, icon: str = ui.ICON_SEND, # TODO cleanup @ redesign icon_color: int = ui.GREEN, # TODO cleanup @ redesign width: int = MONO_HEX_PER_LINE, @@ -533,7 +531,7 @@ async def confirm_metadata( title: str, content: str, param: str | None = None, - br_code: EnumTypeButtonRequestType = ButtonRequestType.SignTx, + br_code: ButtonRequestType = ButtonRequestType.SignTx, ) -> None: text = Text(title, ui.ICON_SEND, ui.GREEN, new_lines=False) text.format_parametrized(content, param if param is not None else "") diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py index ca67810cd..8376ac61d 100644 --- a/core/src/trezor/wire/__init__.py +++ b/core/src/trezor/wire/__init__.py @@ -36,9 +36,9 @@ reads the message's header. When the message type is known the first handler is """ from storage.cache import InvalidSessionError +from trezor import log, loop, protobuf, utils, workflow from trezor.enums import FailureType from trezor.messages import Failure -from trezor import log, loop, protobuf, utils, workflow from trezor.wire import codec_v1 from trezor.wire.errors import ActionCancelled, DataError, Error diff --git a/core/src/trezor/wire/errors.py b/core/src/trezor/wire/errors.py index aeed58cb9..32cc81437 100644 --- a/core/src/trezor/wire/errors.py +++ b/core/src/trezor/wire/errors.py @@ -1,11 +1,12 @@ -from trezor.messages import FailureType +from trezor.enums import FailureType as F -if False: - from trezor.messages.Failure import EnumTypeFailureType +# XXX this rename is also required so that `import errors.*` work in wire/__init__.py +# Otherwise, although the revealed type of FailureType is the same in here and there, +# mypy will complain that one is a module and other is Type[FailureType] class Error(Exception): - def __init__(self, code: EnumTypeFailureType, message: str) -> None: + def __init__(self, code: F, message: str) -> None: super().__init__() self.code = code self.message = message @@ -13,74 +14,74 @@ class Error(Exception): class UnexpectedMessage(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.UnexpectedMessage, message) + super().__init__(F.UnexpectedMessage, message) class ButtonExpected(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.ButtonExpected, message) + super().__init__(F.ButtonExpected, message) class DataError(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.DataError, message) + super().__init__(F.DataError, message) class ActionCancelled(Error): def __init__(self, message: str = "Cancelled") -> None: - super().__init__(FailureType.ActionCancelled, message) + super().__init__(F.ActionCancelled, message) class PinExpected(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.PinExpected, message) + super().__init__(F.PinExpected, message) class PinCancelled(Error): def __init__(self, message: str = "PIN entry cancelled") -> None: - super().__init__(FailureType.PinCancelled, message) + super().__init__(F.PinCancelled, message) class PinInvalid(Error): def __init__(self, message: str = "PIN invalid") -> None: - super().__init__(FailureType.PinInvalid, message) + super().__init__(F.PinInvalid, message) class InvalidSignature(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.InvalidSignature, message) + super().__init__(F.InvalidSignature, message) class ProcessError(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.ProcessError, message) + super().__init__(F.ProcessError, message) class NotEnoughFunds(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.NotEnoughFunds, message) + super().__init__(F.NotEnoughFunds, message) class NotInitialized(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.NotInitialized, message) + super().__init__(F.NotInitialized, message) class PinMismatch(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.PinMismatch, message) + super().__init__(F.PinMismatch, message) class WipeCodeMismatch(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.WipeCodeMismatch, message) + super().__init__(F.WipeCodeMismatch, message) class InvalidSession(Error): def __init__(self, message: str = "Invalid session") -> None: - super().__init__(FailureType.InvalidSession, message) + super().__init__(F.InvalidSession, message) class FirmwareError(Error): def __init__(self, message: str) -> None: - super().__init__(FailureType.FirmwareError, message) + super().__init__(F.FirmwareError, message) diff --git a/core/tests/test_apps.binance.sign_tx.py b/core/tests/test_apps.binance.sign_tx.py index a85fe1726..0d7f70deb 100644 --- a/core/tests/test_apps.binance.sign_tx.py +++ b/core/tests/test_apps.binance.sign_tx.py @@ -6,12 +6,12 @@ from trezor.crypto.hashlib import sha256 if not utils.BITCOIN_ONLY: from apps.binance.helpers import produce_json_for_signing from apps.binance.sign_tx import generate_content_signature, sign_tx - from trezor.messages.BinanceCancelMsg import BinanceCancelMsg - from trezor.messages.BinanceCoin import BinanceCoin - from trezor.messages.BinanceInputOutput import BinanceInputOutput - from trezor.messages.BinanceOrderMsg import BinanceOrderMsg - from trezor.messages.BinanceSignTx import BinanceSignTx - from trezor.messages.BinanceTransferMsg import BinanceTransferMsg + from trezor.messages import BinanceCancelMsg + from trezor.messages import BinanceCoin + from trezor.messages import BinanceInputOutput + from trezor.messages import BinanceOrderMsg + from trezor.messages import BinanceSignTx + from trezor.messages import BinanceTransferMsg @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.bitcoin.address.py b/core/tests/test_apps.bitcoin.address.py index 7d80112e6..643866c93 100644 --- a/core/tests/test_apps.bitcoin.address.py +++ b/core/tests/test_apps.bitcoin.address.py @@ -1,6 +1,6 @@ from common import * from trezor.crypto import bip32, bip39 -from trezor.messages.GetAddress import GetAddress +from trezor.messages import GetAddress from trezor.utils import HashWriter from apps.common import coins diff --git a/core/tests/test_apps.bitcoin.approver.py b/core/tests/test_apps.bitcoin.approver.py index 5af36a9c9..d37a23669 100644 --- a/core/tests/test_apps.bitcoin.approver.py +++ b/core/tests/test_apps.bitcoin.approver.py @@ -2,11 +2,11 @@ from common import unittest, await_result, H_ import storage.cache from trezor import wire -from trezor.messages.AuthorizeCoinJoin import AuthorizeCoinJoin -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput -from trezor.messages.SignTx import SignTx -from trezor.messages import InputScriptType, OutputScriptType +from trezor.messages import AuthorizeCoinJoin +from trezor.messages import TxInput +from trezor.messages import TxOutput +from trezor.messages import SignTx +from trezor.enums import InputScriptType, OutputScriptType from apps.common import coins from apps.bitcoin.authorization import CoinJoinAuthorization diff --git a/core/tests/test_apps.bitcoin.authorization.py b/core/tests/test_apps.bitcoin.authorization.py index bdfa8aef4..a276178b8 100644 --- a/core/tests/test_apps.bitcoin.authorization.py +++ b/core/tests/test_apps.bitcoin.authorization.py @@ -1,10 +1,10 @@ from common import unittest, H_ import storage.cache -from trezor.messages.AuthorizeCoinJoin import AuthorizeCoinJoin -from trezor.messages.GetOwnershipProof import GetOwnershipProof -from trezor.messages.SignTx import SignTx -from trezor.messages import InputScriptType +from trezor.messages import AuthorizeCoinJoin +from trezor.messages import GetOwnershipProof +from trezor.messages import SignTx +from trezor.enums import InputScriptType from apps.common import coins from apps.bitcoin.authorization import CoinJoinAuthorization diff --git a/core/tests/test_apps.bitcoin.ownership_proof.py b/core/tests/test_apps.bitcoin.ownership_proof.py index 8598084f8..811c83bea 100644 --- a/core/tests/test_apps.bitcoin.ownership_proof.py +++ b/core/tests/test_apps.bitcoin.ownership_proof.py @@ -1,8 +1,8 @@ from common import unhexlify, unittest from trezor.crypto import bip39 -from trezor.messages import InputScriptType -from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType -from trezor.messages.HDNodeType import HDNodeType +from trezor.enums import InputScriptType +from trezor.messages import MultisigRedeemScriptType +from trezor.messages import HDNodeType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py b/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py index dd88a2b0e..8c7761c65 100644 --- a/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py +++ b/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py @@ -7,12 +7,12 @@ from apps.bitcoin.writers import get_tx_hash from apps.common import coins from apps.common.keychain import Keychain from apps.common.paths import AlwaysMatchingSchema -from trezor.messages.SignTx import SignTx -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages import InputScriptType -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxInput +from trezor.messages import TxOutput +from trezor.messages import PrevOutput +from trezor.enums import InputScriptType +from trezor.enums import OutputScriptType from trezor.crypto import bip39 diff --git a/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py b/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py index 0275306c1..ea801d314 100644 --- a/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py +++ b/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py @@ -7,12 +7,12 @@ from apps.bitcoin.writers import get_tx_hash from apps.common import coins from apps.common.keychain import Keychain from apps.common.paths import AlwaysMatchingSchema -from trezor.messages.SignTx import SignTx -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages import InputScriptType -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxInput +from trezor.messages import TxOutput +from trezor.messages import PrevOutput +from trezor.enums import InputScriptType +from trezor.enums import OutputScriptType from trezor.crypto import bip39 diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py index afea4d414..7133e21f9 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py @@ -2,28 +2,28 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import InputScriptType -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import InputScriptType +from trezor.enums import OutputScriptType from trezor import wire from apps.common import coins diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py index 1366eadab..6b44fbfeb 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py @@ -2,28 +2,28 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import InputScriptType -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import InputScriptType +from trezor.enums import OutputScriptType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py index 8fc6fd41c..797a33495 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py @@ -2,28 +2,28 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import InputScriptType -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import InputScriptType +from trezor.enums import OutputScriptType from trezor import wire from apps.common import coins diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py index e857955a5..dcb77b817 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py @@ -2,28 +2,28 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import InputScriptType -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import InputScriptType +from trezor.enums import OutputScriptType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.sign_tx.writers.py b/core/tests/test_apps.bitcoin.sign_tx.writers.py index e8bbf92e3..efe4cb4fb 100644 --- a/core/tests/test_apps.bitcoin.sign_tx.writers.py +++ b/core/tests/test_apps.bitcoin.sign_tx.writers.py @@ -1,7 +1,7 @@ from common import * -from trezor.messages.TxInput import TxInput -from trezor.messages import InputScriptType +from trezor.messages import TxInput +from trezor.enums import InputScriptType from apps.bitcoin import writers diff --git a/core/tests/test_apps.bitcoin.signtx.fee_threshold.py b/core/tests/test_apps.bitcoin.signtx.fee_threshold.py index e8916c501..d5183901a 100644 --- a/core/tests/test_apps.bitcoin.signtx.fee_threshold.py +++ b/core/tests/test_apps.bitcoin.signtx.fee_threshold.py @@ -2,27 +2,27 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip32, bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXOUTPUT, TXMETA +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import OutputScriptType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.signtx.py b/core/tests/test_apps.bitcoin.signtx.py index d2b384bfe..7e93f67c7 100644 --- a/core/tests/test_apps.bitcoin.signtx.py +++ b/core/tests/test_apps.bitcoin.signtx.py @@ -2,27 +2,27 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip32, bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import OutputScriptType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.signtx_decred.py b/core/tests/test_apps.bitcoin.signtx_decred.py index ab2258edd..2d0e6b76a 100644 --- a/core/tests/test_apps.bitcoin.signtx_decred.py +++ b/core/tests/test_apps.bitcoin.signtx_decred.py @@ -2,27 +2,27 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import OutputScriptType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.signtx_grs.py b/core/tests/test_apps.bitcoin.signtx_grs.py index 53d519997..e985906a1 100644 --- a/core/tests/test_apps.bitcoin.signtx_grs.py +++ b/core/tests/test_apps.bitcoin.signtx_grs.py @@ -2,27 +2,27 @@ from common import * from trezor.utils import chunks from trezor.crypto import bip39 -from trezor.messages.SignTx import SignTx -from trezor.messages.TxAckInput import TxAckInput -from trezor.messages.TxAckInputWrapper import TxAckInputWrapper -from trezor.messages.TxInput import TxInput -from trezor.messages.TxAckOutput import TxAckOutput -from trezor.messages.TxAckOutputWrapper import TxAckOutputWrapper -from trezor.messages.TxOutput import TxOutput -from trezor.messages.TxAckPrevMeta import TxAckPrevMeta -from trezor.messages.PrevTx import PrevTx -from trezor.messages.TxAckPrevInput import TxAckPrevInput -from trezor.messages.TxAckPrevInputWrapper import TxAckPrevInputWrapper -from trezor.messages.PrevInput import PrevInput -from trezor.messages.TxAckPrevOutput import TxAckPrevOutput -from trezor.messages.TxAckPrevOutputWrapper import TxAckPrevOutputWrapper -from trezor.messages.PrevOutput import PrevOutput -from trezor.messages.TxRequest import TxRequest -from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED -from trezor.messages.TxRequestDetailsType import TxRequestDetailsType -from trezor.messages.TxRequestSerializedType import TxRequestSerializedType -from trezor.messages import AmountUnit -from trezor.messages import OutputScriptType +from trezor.messages import SignTx +from trezor.messages import TxAckInput +from trezor.messages import TxAckInputWrapper +from trezor.messages import TxInput +from trezor.messages import TxAckOutput +from trezor.messages import TxAckOutputWrapper +from trezor.messages import TxOutput +from trezor.messages import TxAckPrevMeta +from trezor.messages import PrevTx +from trezor.messages import TxAckPrevInput +from trezor.messages import TxAckPrevInputWrapper +from trezor.messages import PrevInput +from trezor.messages import TxAckPrevOutput +from trezor.messages import TxAckPrevOutputWrapper +from trezor.messages import PrevOutput +from trezor.messages import TxRequest +from trezor.enums.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED +from trezor.messages import TxRequestDetailsType +from trezor.messages import TxRequestSerializedType +from trezor.enums import AmountUnit +from trezor.enums import OutputScriptType from apps.common import coins from apps.common.keychain import Keychain diff --git a/core/tests/test_apps.bitcoin.txweight.py b/core/tests/test_apps.bitcoin.txweight.py index d9156b642..ad46b0b79 100644 --- a/core/tests/test_apps.bitcoin.txweight.py +++ b/core/tests/test_apps.bitcoin.txweight.py @@ -1,8 +1,8 @@ from common import * -from trezor.messages.TxInput import TxInput -from trezor.messages.TxOutput import TxOutput -from trezor.messages import OutputScriptType +from trezor.messages import TxInput +from trezor.messages import TxOutput +from trezor.enums import OutputScriptType from trezor.crypto import bip32, bip39 from apps.common import coins diff --git a/core/tests/test_apps.bitcoin.zcash.zip243.py b/core/tests/test_apps.bitcoin.zcash.zip243.py index fcf5379cb..769814c9e 100644 --- a/core/tests/test_apps.bitcoin.zcash.zip243.py +++ b/core/tests/test_apps.bitcoin.zcash.zip243.py @@ -1,8 +1,8 @@ from common import * -from trezor.messages import InputScriptType -from trezor.messages.SignTx import SignTx -from trezor.messages.TxInput import TxInput -from trezor.messages.PrevOutput import PrevOutput +from trezor.enums import InputScriptType +from trezor.messages import SignTx +from trezor.messages import TxInput +from trezor.messages import PrevOutput from apps.common import coins from apps.bitcoin.common import SIGHASH_ALL diff --git a/core/tests/test_apps.cardano.address.py b/core/tests/test_apps.cardano.address.py index a3dc13118..863cffb0e 100644 --- a/core/tests/test_apps.cardano.address.py +++ b/core/tests/test_apps.cardano.address.py @@ -1,9 +1,9 @@ from common import * from trezor import wire from trezor.crypto import bip32, slip39 -from trezor.messages import CardanoAddressType -from trezor.messages.CardanoAddressParametersType import CardanoAddressParametersType -from trezor.messages.CardanoBlockchainPointerType import CardanoBlockchainPointerType +from trezor.enums import CardanoAddressType +from trezor.messages import CardanoAddressParametersType +from trezor.messages import CardanoBlockchainPointerType from apps.common import HARDENED, seed diff --git a/core/tests/test_apps.cardano.sign_tx.py b/core/tests/test_apps.cardano.sign_tx.py index 0e4e22b8f..756745992 100644 --- a/core/tests/test_apps.cardano.sign_tx.py +++ b/core/tests/test_apps.cardano.sign_tx.py @@ -1,6 +1,6 @@ from common import * from apps.common import HARDENED -from trezor.messages.CardanoTxInputType import CardanoTxInputType +from trezor.messages import CardanoTxInputType if not utils.BITCOIN_ONLY: from apps.cardano.sign_tx import _should_hide_output diff --git a/core/tests/test_apps.cardano.staking_use_cases.py b/core/tests/test_apps.cardano.staking_use_cases.py index a93e0db2a..ac3304324 100644 --- a/core/tests/test_apps.cardano.staking_use_cases.py +++ b/core/tests/test_apps.cardano.staking_use_cases.py @@ -4,9 +4,9 @@ from common import * from apps.common import HARDENED from trezor.crypto import bip32 -from trezor.messages import CardanoAddressType -from trezor.messages.CardanoAddressParametersType import CardanoAddressParametersType -from trezor.messages.CardanoBlockchainPointerType import CardanoBlockchainPointerType +from trezor.enums import CardanoAddressType +from trezor.messages import CardanoAddressParametersType +from trezor.messages import CardanoBlockchainPointerType if not utils.BITCOIN_ONLY: diff --git a/core/tests/test_apps.common.keychain.py b/core/tests/test_apps.common.keychain.py index 0ccfafa49..d7c7e4742 100644 --- a/core/tests/test_apps.common.keychain.py +++ b/core/tests/test_apps.common.keychain.py @@ -8,7 +8,7 @@ from apps.common.paths import PATTERN_SEP5, PathSchema from apps.common.keychain import LRUCache, Keychain, with_slip44_keychain, get_keychain from trezor import wire from trezor.crypto import bip39 -from trezor.messages import SafetyCheckLevel +from trezor.enums import SafetyCheckLevel class TestKeychain(unittest.TestCase): diff --git a/core/tests/test_apps.eos.check_action.py b/core/tests/test_apps.eos.check_action.py index fb8098c8b..8ddcab1c0 100644 --- a/core/tests/test_apps.eos.check_action.py +++ b/core/tests/test_apps.eos.check_action.py @@ -2,20 +2,20 @@ from common import * if not utils.BITCOIN_ONLY: from apps.eos.actions import check_action - from trezor.messages.EosTxActionAck import EosTxActionAck - from trezor.messages.EosActionBuyRam import EosActionBuyRam - from trezor.messages.EosActionBuyRamBytes import EosActionBuyRamBytes - from trezor.messages.EosActionDelegate import EosActionDelegate - from trezor.messages.EosActionDeleteAuth import EosActionDeleteAuth - from trezor.messages.EosActionLinkAuth import EosActionLinkAuth - from trezor.messages.EosActionNewAccount import EosActionNewAccount - from trezor.messages.EosActionRefund import EosActionRefund - from trezor.messages.EosActionSellRam import EosActionSellRam - from trezor.messages.EosActionTransfer import EosActionTransfer - from trezor.messages.EosActionUndelegate import EosActionUndelegate - from trezor.messages.EosActionUnlinkAuth import EosActionUnlinkAuth - from trezor.messages.EosActionUpdateAuth import EosActionUpdateAuth - from trezor.messages.EosActionVoteProducer import EosActionVoteProducer + from trezor.messages import EosTxActionAck + from trezor.messages import EosActionBuyRam + from trezor.messages import EosActionBuyRamBytes + from trezor.messages import EosActionDelegate + from trezor.messages import EosActionDeleteAuth + from trezor.messages import EosActionLinkAuth + from trezor.messages import EosActionNewAccount + from trezor.messages import EosActionRefund + from trezor.messages import EosActionSellRam + from trezor.messages import EosActionTransfer + from trezor.messages import EosActionUndelegate + from trezor.messages import EosActionUnlinkAuth + from trezor.messages import EosActionUpdateAuth + from trezor.messages import EosActionVoteProducer @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.eos.conversions.py b/core/tests/test_apps.eos.conversions.py index 381f896a3..83779099e 100644 --- a/core/tests/test_apps.eos.conversions.py +++ b/core/tests/test_apps.eos.conversions.py @@ -2,7 +2,7 @@ from common import * if not utils.BITCOIN_ONLY: from apps.eos import helpers - from trezor.messages.EosAsset import EosAsset + from trezor.messages import EosAsset @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.ethereum.keychain.py b/core/tests/test_apps.ethereum.keychain.py index 4491c7ee5..532703c13 100644 --- a/core/tests/test_apps.ethereum.keychain.py +++ b/core/tests/test_apps.ethereum.keychain.py @@ -15,8 +15,8 @@ if not utils.BITCOIN_ONLY: ) from apps.ethereum.networks import by_chain_id, by_slip44 - from trezor.messages.EthereumGetAddress import EthereumGetAddress - from trezor.messages.EthereumSignTx import EthereumSignTx + from trezor.messages import EthereumGetAddress + from trezor.messages import EthereumSignTx @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.management.recovery_device.py b/core/tests/test_apps.management.recovery_device.py index 678fc906a..67124b3d3 100644 --- a/core/tests/test_apps.management.recovery_device.py +++ b/core/tests/test_apps.management.recovery_device.py @@ -4,7 +4,7 @@ from mock_storage import mock_storage import storage import storage.recovery from apps.management.recovery_device.recover import process_slip39 -from trezor.messages import BackupType +from trezor.enums import BackupType from apps.management.recovery_device.word_validity import check, IdentifierMismatch, AlreadyAdded, ThresholdReached MNEMONIC_SLIP39_BASIC_20_3of6 = [ diff --git a/core/tests/test_apps.nem.mosaic.py b/core/tests/test_apps.nem.mosaic.py index d41ea3089..5f7f9f8dc 100644 --- a/core/tests/test_apps.nem.mosaic.py +++ b/core/tests/test_apps.nem.mosaic.py @@ -1,7 +1,7 @@ from common import * if not utils.BITCOIN_ONLY: - from trezor.messages.NEMMosaic import NEMMosaic + from trezor.messages import NEMMosaic from apps.nem.mosaic.helpers import get_mosaic_definition from apps.nem.transfer import * from apps.nem.transfer.serialize import * diff --git a/core/tests/test_apps.nem.mosaic_creation.py b/core/tests/test_apps.nem.mosaic_creation.py index 1c07d2fa3..ab63b6bb7 100644 --- a/core/tests/test_apps.nem.mosaic_creation.py +++ b/core/tests/test_apps.nem.mosaic_creation.py @@ -3,9 +3,9 @@ from common import * from trezor.crypto import hashlib if not utils.BITCOIN_ONLY: - from trezor.messages.NEMSignTx import NEMSignTx - from trezor.messages.NEMMosaicCreation import NEMMosaicCreation - from trezor.messages.NEMMosaicDefinition import NEMMosaicDefinition + from trezor.messages import NEMSignTx + from trezor.messages import NEMMosaicCreation + from trezor.messages import NEMMosaicDefinition from apps.nem.helpers import * from apps.nem.mosaic import * from apps.nem.mosaic.serialize import * diff --git a/core/tests/test_apps.nem.mosaic_supply_change.py b/core/tests/test_apps.nem.mosaic_supply_change.py index 0d9804094..465871d38 100644 --- a/core/tests/test_apps.nem.mosaic_supply_change.py +++ b/core/tests/test_apps.nem.mosaic_supply_change.py @@ -6,8 +6,8 @@ if not utils.BITCOIN_ONLY: from apps.nem.helpers import * from apps.nem.mosaic import * from apps.nem.mosaic.serialize import * - from trezor.messages.NEMSignTx import NEMSignTx - from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange + from trezor.messages import NEMSignTx + from trezor.messages import NEMMosaicSupplyChange @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.nem.multisig.aggregate_modification.py b/core/tests/test_apps.nem.multisig.aggregate_modification.py index 5d0105f3f..1058f7e1b 100644 --- a/core/tests/test_apps.nem.multisig.aggregate_modification.py +++ b/core/tests/test_apps.nem.multisig.aggregate_modification.py @@ -2,10 +2,10 @@ from common import * from trezor.crypto import hashlib if not utils.BITCOIN_ONLY: - from trezor.messages.NEMAggregateModification import NEMAggregateModification - from trezor.messages.NEMCosignatoryModification import NEMCosignatoryModification - from trezor.messages.NEMSignTx import NEMSignTx - from trezor.messages.NEMTransactionCommon import NEMTransactionCommon + from trezor.messages import NEMAggregateModification + from trezor.messages import NEMCosignatoryModification + from trezor.messages import NEMSignTx + from trezor.messages import NEMTransactionCommon from apps.nem.helpers import * from apps.nem.multisig import * from apps.nem.multisig.serialize import * diff --git a/core/tests/test_apps.nem.multisig.py b/core/tests/test_apps.nem.multisig.py index 37edc1181..34982e855 100644 --- a/core/tests/test_apps.nem.multisig.py +++ b/core/tests/test_apps.nem.multisig.py @@ -6,10 +6,10 @@ if not utils.BITCOIN_ONLY: from apps.nem.multisig.serialize import * from apps.nem.namespace import * from apps.nem.namespace.serialize import * - from trezor.messages.NEMSignTx import NEMSignTx - from trezor.messages.NEMAggregateModification import NEMAggregateModification - from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace - from trezor.messages.NEMCosignatoryModification import NEMCosignatoryModification + from trezor.messages import NEMSignTx + from trezor.messages import NEMAggregateModification + from trezor.messages import NEMProvisionNamespace + from trezor.messages import NEMCosignatoryModification @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.nem.namespace.py b/core/tests/test_apps.nem.namespace.py index a1ba82c2a..722d6c494 100644 --- a/core/tests/test_apps.nem.namespace.py +++ b/core/tests/test_apps.nem.namespace.py @@ -6,8 +6,8 @@ if not utils.BITCOIN_ONLY: from apps.nem.helpers import * from apps.nem.namespace import * from apps.nem.namespace.serialize import * - from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace - from trezor.messages.NEMSignTx import NEMSignTx + from trezor.messages import NEMProvisionNamespace + from trezor.messages import NEMSignTx @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.nem.transfer.py b/core/tests/test_apps.nem.transfer.py index 6c8f159af..8300a9fe1 100644 --- a/core/tests/test_apps.nem.transfer.py +++ b/core/tests/test_apps.nem.transfer.py @@ -7,8 +7,8 @@ if not utils.BITCOIN_ONLY: from apps.nem.mosaic import * from apps.nem.transfer import * from apps.nem.transfer.serialize import * - from trezor.messages.NEMTransfer import NEMTransfer - from trezor.messages.NEMSignTx import NEMSignTx + from trezor.messages import NEMTransfer + from trezor.messages import NEMSignTx @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.ripple.serializer.py b/core/tests/test_apps.ripple.serializer.py index 99e308796..85852f2a2 100644 --- a/core/tests/test_apps.ripple.serializer.py +++ b/core/tests/test_apps.ripple.serializer.py @@ -1,8 +1,8 @@ from common import * if not utils.BITCOIN_ONLY: - from trezor.messages.RipplePayment import RipplePayment - from trezor.messages.RippleSignTx import RippleSignTx + from trezor.messages import RipplePayment + from trezor.messages import RippleSignTx from apps.ripple.serialize import serialize, serialize_amount from apps.ripple.sign_tx import get_network_prefix diff --git a/core/tests/test_apps.tezos.address.py b/core/tests/test_apps.tezos.address.py index ac353c074..b5298c8b8 100644 --- a/core/tests/test_apps.tezos.address.py +++ b/core/tests/test_apps.tezos.address.py @@ -4,8 +4,8 @@ from apps.common.paths import HARDENED if not utils.BITCOIN_ONLY: from apps.tezos.sign_tx import _get_address_from_contract - from trezor.messages import TezosContractType - from trezor.messages.TezosContractID import TezosContractID + from trezor.enums import TezosContractType + from trezor.messages import TezosContractID @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin") diff --git a/core/tests/test_apps.tezos.encode.py b/core/tests/test_apps.tezos.encode.py index 00fa9a557..504126be1 100644 --- a/core/tests/test_apps.tezos.encode.py +++ b/core/tests/test_apps.tezos.encode.py @@ -1,8 +1,8 @@ from common import * if not utils.BITCOIN_ONLY: - from trezor.messages import TezosContractType - from trezor.messages.TezosContractID import TezosContractID + from trezor.enums import TezosContractType + from trezor.messages import TezosContractID from apps.tezos.helpers import base58_decode_check, base58_encode_check, write_bool from apps.tezos.sign_tx import ( _encode_contract_id, diff --git a/core/tests/test_storage.cache.py b/core/tests/test_storage.cache.py index 220db6b6e..cc2bfcf3e 100644 --- a/core/tests/test_storage.cache.py +++ b/core/tests/test_storage.cache.py @@ -2,8 +2,8 @@ from common import * from mock_storage import mock_storage from storage import cache -from trezor.messages.Initialize import Initialize -from trezor.messages.EndSession import EndSession +from trezor.messages import Initialize +from trezor.messages import EndSession from trezor.wire import DUMMY_CONTEXT from apps.base import handle_Initialize, handle_EndSession