1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

src: run isort

This commit is contained in:
Jan Pochyla 2018-07-03 16:20:26 +02:00
parent e8af00d21d
commit ead154b907
85 changed files with 384 additions and 212 deletions

View File

@ -1,4 +1,5 @@
from trezor.crypto import hashlib, hmac, random
from apps.common import storage
_cached_seed = None

View File

@ -1,5 +1,5 @@
from micropython import const
from apps.common.confirm import confirm
from trezor import ui
from trezor.messages import ButtonRequestType
from trezor.ui.container import Container
@ -7,6 +7,8 @@ from trezor.ui.qr import Qr
from trezor.ui.text import Text
from trezor.utils import chunks
from apps.common.confirm import confirm
async def show_address(ctx, address: str):
lines = split_address(address)

View File

@ -1,12 +1,12 @@
from trezor import ui, wire
from trezor.messages import ButtonRequestType, MessageType
from trezor.messages import ButtonRequestType, MessageType, PassphraseSourceType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages import PassphraseSourceType
from trezor.messages.PassphraseRequest import PassphraseRequest
from trezor.messages.PassphraseStateRequest import PassphraseStateRequest
from trezor.ui.entry_select import DEVICE, EntrySelector
from trezor.ui.passphrase import CANCELLED, PassphraseKeyboard
from trezor.ui.text import Text
from apps.common import storage
from apps.common.cache import get_state

View File

@ -1,5 +1,6 @@
from trezor import wire
from trezor.crypto import bip32, bip39
from apps.common import cache, storage
from apps.common.request_passphrase import protect_by_passphrase

View File

@ -1,8 +1,10 @@
from ubinascii import hexlify
from trezor import ui
from trezor.crypto.hashlib import sha256
from trezor.ui.text import TEXT_MARGIN_LEFT
from trezor.utils import HashWriter, chunks, split_words
from ubinascii import hexlify
from apps.wallet.sign_tx.signing import write_varint

View File

@ -1,7 +1,9 @@
from micropython import const
from ubinascii import hexlify
from trezor import config
from trezor.crypto import random
from apps.common import cache
HOMESCREEN_MAXSIZE = 16384

View File

@ -1,6 +1,10 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.MessageType import EthereumGetAddress, EthereumSignTx
from trezor.messages.MessageType import EthereumSignMessage, EthereumVerifyMessage
from trezor.messages.MessageType import (
EthereumGetAddress,
EthereumSignMessage,
EthereumSignTx,
EthereumVerifyMessage,
)
from trezor.wire import protobuf_workflow, register
def dispatch_EthereumGetAddress(*args, **kwargs):

View File

@ -1,9 +1,9 @@
from ubinascii import hexlify
from trezor import ui
from trezor.utils import chunks, format_amount
from trezor.messages import ButtonRequestType
from trezor.ui.text import Text
from trezor.utils import chunks, format_amount
from apps.common.confirm import require_confirm, require_hold_to_confirm
from apps.ethereum import networks, tokens

View File

@ -1,8 +1,9 @@
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha3_256
from trezor.utils import HashWriter
from trezor.messages.EthereumMessageSignature import EthereumMessageSignature
from trezor.ui.text import Text
from trezor.crypto.curve import secp256k1
from trezor.utils import HashWriter
from apps.common import seed
from apps.common.confirm import require_confirm
from apps.common.signverify import split_message

View File

@ -1,10 +1,15 @@
from trezor import wire
from trezor.crypto import rlp
from trezor.messages.EthereumSignTx import EthereumSignTx
from trezor.messages.EthereumTxRequest import EthereumTxRequest
from trezor.utils import HashWriter
from trezor.crypto import rlp
from apps.ethereum import tokens
from apps.ethereum.layout import require_confirm_tx, require_confirm_data, require_confirm_fee
from apps.ethereum.layout import (
require_confirm_data,
require_confirm_fee,
require_confirm_tx,
)
# maximum supported chain id
MAX_CHAIN_ID = 2147483630

View File

@ -1,8 +1,10 @@
from ubinascii import hexlify
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha3_256
from trezor.ui.text import Text
from trezor.messages.Success import Success
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
from apps.common.display_address import split_address
from apps.common.signverify import split_message

View File

@ -1,22 +1,13 @@
from micropython import const
import uctypes
import ustruct
import utime
from micropython import const
from trezor import log
from trezor import loop
from trezor import io
from trezor import ui
from trezor import utils
from trezor import workflow
from trezor.crypto import der
from trezor.crypto import hashlib
from trezor.crypto import hmac
from trezor.crypto import random
from trezor import io, log, loop, ui, utils, workflow
from trezor.crypto import der, hashlib, hmac, random
from trezor.crypto.curve import nist256p1
from apps.common import storage, HARDENED
from apps.common import HARDENED, storage
_HID_RPT_SIZE = const(64)
_CID_BROADCAST = const(0xffffffff) # broadcast channel id

View File

@ -1,10 +1,10 @@
from trezor import config, utils, wire
from trezor.wire import register, protobuf_workflow
from trezor.messages import MessageType
from trezor.messages.Features import Features
from trezor.messages.Success import Success
from trezor.wire import protobuf_workflow, register
from apps.common import storage, cache
from apps.common import cache, storage
def get_features():

View File

@ -1,5 +1,6 @@
from trezor import ui, res, config
from trezor import config, res, ui
from trezor.ui.swipe import Swipe, degrees
from apps.common import storage

View File

@ -1,6 +1,11 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.MessageType import \
LiskGetAddress, LiskSignTx, LiskGetPublicKey, LiskSignMessage, LiskVerifyMessage
from trezor.messages.MessageType import (
LiskGetAddress,
LiskGetPublicKey,
LiskSignMessage,
LiskSignTx,
LiskVerifyMessage,
)
from trezor.wire import protobuf_workflow, register
def dispatch_LiskGetAddress(*args, **kwargs):

View File

@ -1,9 +1,10 @@
from apps.common import seed
from apps.common.display_address import show_address, show_qr
from trezor.messages.LiskAddress import LiskAddress
from .helpers import LISK_CURVE, get_address_from_public_key
from apps.common import seed
from apps.common.display_address import show_address, show_qr
async def layout_lisk_get_address(ctx, msg):
address_n = msg.address_n or ()

View File

@ -1,9 +1,10 @@
from apps.common import seed
from apps.wallet.get_public_key import _show_pubkey
from trezor.messages.LiskPublicKey import LiskPublicKey
from .helpers import LISK_CURVE
from apps.common import seed
from apps.wallet.get_public_key import _show_pubkey
async def lisk_get_public_key(ctx, msg):
address_n = msg.address_n or ()

View File

@ -1,5 +1,3 @@
from apps.common.confirm import require_confirm, require_hold_to_confirm
from apps.wallet.get_public_key import _show_pubkey
from trezor import ui
from trezor.messages import ButtonRequestType
from trezor.ui.text import Text
@ -7,6 +5,9 @@ from trezor.utils import chunks
from .helpers import get_vote_tx_text
from apps.common.confirm import require_confirm, require_hold_to_confirm
from apps.wallet.get_public_key import _show_pubkey
async def require_confirm_tx(ctx, to, value):
text = Text('Confirm sending', ui.ICON_SEND, icon_color=ui.GREEN)

View File

@ -1,7 +1,3 @@
from apps.common import seed
from apps.common.confirm import require_confirm
from apps.common.signverify import split_message
from apps.wallet.sign_tx.signing import write_varint
from trezor.crypto.curve import ed25519
from trezor.crypto.hashlib import sha256
from trezor.messages.LiskMessageSignature import LiskMessageSignature
@ -10,6 +6,11 @@ from trezor.utils import HashWriter
from .helpers import LISK_CURVE
from apps.common import seed
from apps.common.confirm import require_confirm
from apps.common.signverify import split_message
from apps.wallet.sign_tx.signing import write_varint
def message_digest(message):
h = HashWriter(sha256)

View File

@ -1,5 +1,5 @@
import ustruct
from apps.common import seed
from trezor import wire
from trezor.crypto.curve import ed25519
from trezor.crypto.hashlib import sha256
@ -10,6 +10,8 @@ from trezor.utils import HashWriter
from . import layout
from .helpers import LISK_CURVE, get_address_from_public_key
from apps.common import seed
async def lisk_sign_tx(ctx, msg):
pubkey, seckey = await _get_keys(ctx, msg)

View File

@ -1,4 +1,3 @@
from apps.wallet.verify_message import require_confirm_verify_message
from trezor import wire
from trezor.crypto.curve import ed25519
from trezor.messages.Success import Success
@ -6,6 +5,8 @@ from trezor.messages.Success import Success
from .helpers import get_address_from_public_key
from .sign_message import message_digest
from apps.wallet.verify_message import require_confirm_verify_message
async def lisk_verify_message(ctx, msg):
digest = message_digest(msg.message)

View File

@ -1,6 +1,15 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.MessageType import \
LoadDevice, ResetDevice, BackupDevice, WipeDevice, RecoveryDevice, ApplySettings, ApplyFlags, ChangePin, SetU2FCounter
from trezor.messages.MessageType import (
ApplyFlags,
ApplySettings,
BackupDevice,
ChangePin,
LoadDevice,
RecoveryDevice,
ResetDevice,
SetU2FCounter,
WipeDevice,
)
from trezor.wire import protobuf_workflow, register
def dispatch_LoadDevice(*args, **kwargs):

View File

@ -1,4 +1,5 @@
from trezor.messages.Success import Success
from apps.common import storage

View File

@ -2,6 +2,7 @@ from trezor import ui, wire
from trezor.messages import ButtonRequestType, PassphraseSourceType
from trezor.messages.Success import Success
from trezor.ui.text import Text
from apps.common import storage
from apps.common.confirm import require_confirm

View File

@ -1,5 +1,6 @@
from trezor import wire
from trezor.messages.Success import Success
from apps.common import storage
from apps.management.reset_device import (
check_mnemonic,

View File

@ -1,10 +1,10 @@
from trezor import config, loop, ui, wire
from trezor.messages import MessageType
from trezor.messages import ButtonRequestType
from trezor.messages import ButtonRequestType, MessageType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages.Success import Success
from trezor.pin import pin_to_int, show_pin_timeout
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
from apps.common.request_pin import PinCancelled, request_pin

View File

@ -3,6 +3,7 @@ from trezor.crypto import bip39
from trezor.messages.Success import Success
from trezor.pin import pin_to_int
from trezor.ui.text import Text
from apps.common import storage
from apps.common.confirm import require_confirm

View File

@ -1,14 +1,15 @@
from trezor import config, ui, wire
from trezor.crypto import bip39
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages.ButtonRequestType import MnemonicWordCount, MnemonicInput
from trezor.messages.Success import Success
from trezor.messages.ButtonRequestType import MnemonicInput, MnemonicWordCount
from trezor.messages.MessageType import ButtonAck
from trezor.messages.Success import Success
from trezor.pin import pin_to_int
from trezor.ui.mnemonic import MnemonicKeyboard
from trezor.ui.text import Text
from trezor.ui.word_select import WordSelector
from trezor.utils import format_ordinal
from apps.common import storage
from apps.management.change_pin import request_pin_confirm

View File

@ -1,18 +1,19 @@
from micropython import const
from trezor import config, ui, wire
from ubinascii import hexlify
from trezor import config, ui, wire, workflow
from trezor.crypto import bip39, hashlib, random
from trezor.messages import ButtonRequestType, MessageType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages.EntropyRequest import EntropyRequest
from trezor.messages.Success import Success
from trezor import workflow
from trezor.pin import pin_to_int
from trezor.ui.confirm import HoldToConfirmDialog
from trezor.ui.mnemonic import MnemonicKeyboard
from trezor.ui.scroll import Scrollpage, animate_swipe, paginate
from trezor.ui.text import Text
from trezor.utils import chunks, format_ordinal
from ubinascii import hexlify
from apps.common import storage
from apps.common.confirm import require_confirm
from apps.management.change_pin import request_pin_confirm

View File

@ -2,6 +2,7 @@ from trezor import ui, wire
from trezor.messages import ButtonRequestType
from trezor.messages.Success import Success
from trezor.ui.text import Text
from apps.common import storage
from apps.common.confirm import require_confirm

View File

@ -2,6 +2,7 @@ from trezor import ui
from trezor.messages import ButtonRequestType
from trezor.messages.Success import Success
from trezor.ui.text import Text
from apps.common import storage
from apps.common.confirm import require_hold_to_confirm

View File

@ -1,5 +1,5 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.MessageType import NEMGetAddress, NEMSignTx
from trezor.wire import protobuf_workflow, register
def dispatch_NemGetAddress(*args, **kwargs):

View File

@ -3,14 +3,14 @@ from trezor.messages import ButtonRequestType
from trezor.messages.NEMAddress import NEMAddress
from trezor.ui.text import Text
from .helpers import NEM_CURVE, get_network_str
from .layout import split_address
from .validators import validate_network
from apps.common import seed
from apps.common.confirm import confirm
from apps.common.display_address import show_qr
from .layout import split_address
from .helpers import get_network_str, NEM_CURVE
from .validators import validate_network
async def get_address(ctx, msg):
network = validate_network(msg.network)

View File

@ -3,10 +3,10 @@ from trezor.messages import ButtonRequestType
from trezor.ui.text import Text
from trezor.utils import chunks, format_amount, split_words
from apps.common.confirm import require_confirm, require_hold_to_confirm
from .helpers import NEM_MAX_DIVISIBILITY
from apps.common.confirm import require_confirm, require_hold_to_confirm
async def require_confirm_text(ctx, action: str):
words = split_words(action, 18)

View File

@ -1,6 +1,6 @@
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from trezor.messages.NEMMosaicCreation import NEMMosaicCreation
from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from . import layout, serialize

View File

@ -1,16 +1,27 @@
from micropython import const
from trezor import ui
from trezor.messages import (NEMMosaicCreation, NEMMosaicDefinition,
NEMMosaicLevy, NEMMosaicSupplyChange,
NEMSupplyChangeType, NEMTransactionCommon)
from trezor.messages import (
NEMMosaicCreation,
NEMMosaicDefinition,
NEMMosaicLevy,
NEMMosaicSupplyChange,
NEMSupplyChangeType,
NEMTransactionCommon,
)
from trezor.ui.confirm import ConfirmDialog
from trezor.ui.scroll import Scrollpage, animate_swipe, paginate
from trezor.ui.text import Text
from trezor.utils import split_words
from ..layout import (require_confirm_content, require_confirm_fee,
require_confirm_final, require_confirm_text,
split_address, trim)
from ..layout import (
require_confirm_content,
require_confirm_fee,
require_confirm_final,
require_confirm_text,
split_address,
trim,
)
async def ask_mosaic_creation(ctx, common: NEMTransactionCommon, creation: NEMMosaicCreation):

View File

@ -2,10 +2,11 @@ from trezor.messages.NEMMosaicCreation import NEMMosaicCreation
from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from ..helpers import (NEM_TRANSACTION_TYPE_MOSAIC_CREATION,
NEM_TRANSACTION_TYPE_MOSAIC_SUPPLY_CHANGE)
from ..writers import (write_bytes_with_length, write_common, write_uint32,
write_uint64)
from ..helpers import (
NEM_TRANSACTION_TYPE_MOSAIC_CREATION,
NEM_TRANSACTION_TYPE_MOSAIC_SUPPLY_CHANGE,
)
from ..writers import write_bytes_with_length, write_common, write_uint32, write_uint64
def serialize_mosaic_creation(common: NEMTransactionCommon, creation: NEMMosaicCreation, public_key: bytes):

View File

@ -1,13 +1,21 @@
from trezor import ui
from trezor.crypto import nem
from trezor.messages import (ButtonRequestType, NEMAggregateModification,
NEMModificationType, NEMSignTx,
NEMTransactionCommon)
from trezor.messages import (
ButtonRequestType,
NEMAggregateModification,
NEMModificationType,
NEMSignTx,
NEMTransactionCommon,
)
from trezor.ui.text import Text
from ..layout import (require_confirm, require_confirm_fee,
require_confirm_final, require_confirm_text,
split_address)
from ..layout import (
require_confirm,
require_confirm_fee,
require_confirm_final,
require_confirm_text,
split_address,
)
async def ask_multisig(ctx, msg: NEMSignTx):

View File

@ -2,9 +2,11 @@ from trezor.crypto import hashlib, nem
from trezor.messages.NEMAggregateModification import NEMAggregateModification
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from ..helpers import (NEM_TRANSACTION_TYPE_AGGREGATE_MODIFICATION,
NEM_TRANSACTION_TYPE_MULTISIG,
NEM_TRANSACTION_TYPE_MULTISIG_SIGNATURE)
from ..helpers import (
NEM_TRANSACTION_TYPE_AGGREGATE_MODIFICATION,
NEM_TRANSACTION_TYPE_MULTISIG,
NEM_TRANSACTION_TYPE_MULTISIG_SIGNATURE,
)
from ..writers import write_bytes_with_length, write_common, write_uint32

View File

@ -1,5 +1,5 @@
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from . import layout, serialize

View File

@ -1,8 +1,7 @@
from trezor import ui
from trezor.messages import NEMProvisionNamespace, NEMTransactionCommon
from ..layout import (require_confirm_content, require_confirm_fee,
require_confirm_final)
from ..layout import require_confirm_content, require_confirm_fee, require_confirm_final
async def ask_provision_namespace(ctx, common: NEMTransactionCommon, namespace: NEMProvisionNamespace):

View File

@ -1,12 +1,13 @@
from trezor.crypto.curve import ed25519
from trezor.messages.NEMSignedTx import NEMSignedTx
from trezor.messages.NEMSignTx import NEMSignTx
from apps.common import seed
from . import mosaic, multisig, namespace, transfer
from .helpers import NEM_CURVE, NEM_HASH_ALG
from .validators import validate
from apps.common import seed
async def sign_tx(ctx, msg: NEMSignTx):
validate(msg)

View File

@ -1,6 +1,6 @@
from trezor.messages.NEMTransfer import NEMTransfer
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from trezor.messages.NEMImportanceTransfer import NEMImportanceTransfer
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from trezor.messages.NEMTransfer import NEMTransfer
from . import layout, serialize

View File

@ -1,17 +1,26 @@
from trezor import ui
from trezor.messages import (ButtonRequestType, NEMImportanceTransfer,
NEMImportanceTransferMode, NEMMosaic,
NEMMosaicLevy, NEMTransactionCommon, NEMTransfer)
from trezor.messages import (
ButtonRequestType,
NEMImportanceTransfer,
NEMImportanceTransferMode,
NEMMosaic,
NEMMosaicLevy,
NEMTransactionCommon,
NEMTransfer,
)
from trezor.ui.text import Text
from trezor.utils import format_amount, split_words
from apps.common.confirm import require_confirm
from ..helpers import (NEM_LEVY_PERCENTILE_DIVISOR_ABSOLUTE,
NEM_MAX_DIVISIBILITY, NEM_MOSAIC_AMOUNT_DIVISOR)
from ..helpers import (
NEM_LEVY_PERCENTILE_DIVISOR_ABSOLUTE,
NEM_MAX_DIVISIBILITY,
NEM_MOSAIC_AMOUNT_DIVISOR,
)
from ..layout import require_confirm_final, require_confirm_text, split_address
from ..mosaic.helpers import get_mosaic_definition, is_nem_xem_mosaic
from apps.common.confirm import require_confirm
async def ask_transfer(ctx, common: NEMTransactionCommon, transfer: NEMTransfer, payload: bytes, encrypted: bool):
if payload:

View File

@ -4,9 +4,12 @@ from trezor.messages.NEMMosaic import NEMMosaic
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from trezor.messages.NEMTransfer import NEMTransfer
from ..helpers import (AES_BLOCK_SIZE, NEM_SALT_SIZE,
NEM_TRANSACTION_TYPE_IMPORTANCE_TRANSFER,
NEM_TRANSACTION_TYPE_TRANSFER)
from ..helpers import (
AES_BLOCK_SIZE,
NEM_SALT_SIZE,
NEM_TRANSACTION_TYPE_IMPORTANCE_TRANSFER,
NEM_TRANSACTION_TYPE_TRANSFER,
)
from ..writers import write_bytes_with_length, write_common, write_uint32, write_uint64

View File

@ -1,18 +1,27 @@
from trezor.crypto import nem
from trezor.messages import NEMModificationType, NEMSupplyChangeType
from trezor.messages.NEMSignTx import (
NEMAggregateModification,
NEMImportanceTransfer,
NEMMosaicCreation,
NEMMosaicSupplyChange,
NEMProvisionNamespace,
NEMSignTx,
NEMTransactionCommon,
NEMTransfer,
)
from trezor.wire import ProcessError
from trezor.messages import NEMModificationType
from trezor.messages import NEMSupplyChangeType
from trezor.messages.NEMSignTx import (NEMAggregateModification,
NEMImportanceTransfer,
NEMMosaicCreation,
NEMMosaicSupplyChange,
NEMProvisionNamespace, NEMSignTx,
NEMTransactionCommon, NEMTransfer)
from .helpers import (NEM_MAX_DIVISIBILITY, NEM_MAX_ENCRYPTED_PAYLOAD_SIZE,
NEM_MAX_PLAIN_PAYLOAD_SIZE, NEM_MAX_SUPPLY,
NEM_NETWORK_MAINNET, NEM_NETWORK_MIJIN,
NEM_NETWORK_TESTNET, NEM_PUBLIC_KEY_SIZE)
from .helpers import (
NEM_MAX_DIVISIBILITY,
NEM_MAX_ENCRYPTED_PAYLOAD_SIZE,
NEM_MAX_PLAIN_PAYLOAD_SIZE,
NEM_MAX_SUPPLY,
NEM_NETWORK_MAINNET,
NEM_NETWORK_MIJIN,
NEM_NETWORK_TESTNET,
NEM_PUBLIC_KEY_SIZE,
)
def validate(msg: NEMSignTx):

View File

@ -1,12 +1,15 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.MessageType import \
GetPublicKey, GetAddress, \
GetEntropy, \
SignTx, \
SignMessage, VerifyMessage, \
SignIdentity, \
GetECDHSessionKey, \
CipherKeyValue
from trezor.messages.MessageType import (
CipherKeyValue,
GetAddress,
GetECDHSessionKey,
GetEntropy,
GetPublicKey,
SignIdentity,
SignMessage,
SignTx,
VerifyMessage,
)
from trezor.wire import protobuf_workflow, register
def dispatch_GetPublicKey(*args, **kwargs):

View File

@ -4,6 +4,7 @@ from trezor.crypto.aes import AES_CBC_Decrypt, AES_CBC_Encrypt
from trezor.crypto.hashlib import sha512
from trezor.messages.CipheredKeyValue import CipheredKeyValue
from trezor.ui.text import Text
from apps.common import seed
from apps.common.confirm import require_confirm

View File

@ -1,12 +1,16 @@
from ustruct import pack, unpack
from trezor.crypto.hashlib import sha256
from trezor.messages.ECDHSessionKey import ECDHSessionKey
from ustruct import pack, unpack
from trezor.utils import chunks
from apps.common.confirm import require_confirm
from apps.wallet.sign_identity import serialize_identity, serialize_identity_without_proto
from trezor.ui.text import Text
from trezor.utils import chunks
from apps.common import seed, HARDENED
from apps.common import HARDENED, seed
from apps.common.confirm import require_confirm
from apps.wallet.sign_identity import (
serialize_identity,
serialize_identity_without_proto,
)
async def get_ecdh_session_key(ctx, msg):

View File

@ -1,7 +1,8 @@
from trezor.messages import InputScriptType
from trezor.messages.Address import Address
from apps.common import coins, seed
from apps.common.display_address import show_qr, show_address
from apps.common.display_address import show_address, show_qr
from apps.wallet.sign_tx import addresses

View File

@ -2,6 +2,7 @@ from trezor.crypto import random
from trezor.messages import ButtonRequestType
from trezor.messages.Entropy import Entropy
from trezor.ui.text import Text
from apps.common.confirm import require_confirm

View File

@ -1,12 +1,14 @@
from trezor.messages.HDNodeType import HDNodeType
from trezor.messages.PublicKey import PublicKey
from ubinascii import hexlify
from trezor import ui
from trezor.messages import ButtonRequestType
from trezor.messages.HDNodeType import HDNodeType
from trezor.messages.PublicKey import PublicKey
from trezor.ui.text import Text
from trezor.utils import chunks
from apps.common import coins, seed
from apps.common.confirm import require_confirm
from ubinascii import hexlify
async def get_public_key(ctx, msg):

View File

@ -3,10 +3,10 @@ from ustruct import pack, unpack
from trezor import ui
from trezor.crypto.hashlib import sha256
from trezor.messages.SignedIdentity import SignedIdentity
from trezor.utils import chunks
from trezor.ui.text import Text
from trezor.utils import chunks
from apps.common import coins, seed, HARDENED
from apps.common import HARDENED, coins, seed
from apps.common.confirm import require_confirm

View File

@ -3,6 +3,7 @@ from trezor.crypto.curve import secp256k1
from trezor.messages.InputScriptType import SPENDADDRESS, SPENDP2SHWITNESS, SPENDWITNESS
from trezor.messages.MessageSignature import MessageSignature
from trezor.ui.text import Text
from apps.common import coins, seed
from apps.common.confirm import require_confirm
from apps.common.signverify import message_digest, split_message

View File

@ -1,16 +1,22 @@
from trezor import ui, wire
from trezor.messages.MessageType import TxAck
from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXFINISHED
from apps.common import seed, coins
from apps.wallet.sign_tx.helpers import UiConfirmOutput, UiConfirmTotal, UiConfirmFeeOverThreshold, UiConfirmForeignAddress
from trezor.messages.TxRequest import TxRequest
from apps.common import coins, seed
from apps.wallet.sign_tx.helpers import (
UiConfirmFeeOverThreshold,
UiConfirmForeignAddress,
UiConfirmOutput,
UiConfirmTotal,
)
@ui.layout
async def sign_tx(ctx, msg):
from apps.wallet.sign_tx import layout, progress, signing
coin_name = msg.coin_name or 'Bitcoin'
coin_name = msg.coin_name or "Bitcoin"
coin = coins.by_name(coin_name)
# TODO: rework this so we don't have to pass root to signing.sign_tx
root = await seed.derive_node(ctx, [], curve_name=coin.curve_name)
@ -46,5 +52,5 @@ async def sign_tx(ctx, msg):
elif isinstance(req, UiConfirmForeignAddress):
res = await layout.confirm_foreign_address(ctx, req.address_n, req.coin)
else:
raise TypeError('Invalid signing instruction')
raise TypeError("Invalid signing instruction")
return req

View File

@ -1,16 +1,18 @@
from micropython import const
from trezor.crypto.hashlib import sha256, ripemd160
from trezor.crypto import base58, bech32, cashaddr
from trezor.crypto.hashlib import ripemd160, sha256
from trezor.messages import FailureType, InputScriptType
from trezor.utils import ensure
from trezor.messages import FailureType
from trezor.messages import InputScriptType
from apps.common.coininfo import CoinInfo
from apps.common.address_type import addrtype_bytes
from apps.wallet.sign_tx.scripts import output_script_multisig, sha256_ripemd160_digest, output_script_native_p2wpkh_or_p2wsh
from apps.wallet.sign_tx.multisig import multisig_pubkey_index, multisig_get_pubkeys
from apps.common.coininfo import CoinInfo
from apps.wallet.sign_tx.multisig import multisig_get_pubkeys, multisig_pubkey_index
from apps.wallet.sign_tx.scripts import (
output_script_multisig,
output_script_native_p2wpkh_or_p2wsh,
sha256_ripemd160_digest,
)
# supported witness version for bech32 addresses
_BECH32_WITVER = const(0x00)

View File

@ -1,11 +1,17 @@
from trezor.messages.TxOutputType import TxOutputType
from trezor.messages.TxOutputBinType import TxOutputBinType
from trezor.messages.TxInputType import TxInputType
from trezor.messages.SignTx import SignTx
from trezor.messages.TxRequest import TxRequest
from trezor.messages.TransactionType import TransactionType
from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXEXTRADATA, TXFINISHED
from trezor.messages import InputScriptType
from trezor.messages.RequestType import (
TXEXTRADATA,
TXFINISHED,
TXINPUT,
TXMETA,
TXOUTPUT,
)
from trezor.messages.SignTx import SignTx
from trezor.messages.TransactionType import TransactionType
from trezor.messages.TxInputType import TxInputType
from trezor.messages.TxOutputBinType import TxOutputBinType
from trezor.messages.TxOutputType import TxOutputType
from trezor.messages.TxRequest import TxRequest
from apps.common.coininfo import CoinInfo

View File

@ -1,11 +1,11 @@
from ubinascii import hexlify
from trezor import ui
from trezor.utils import chunks, format_amount
from trezor.messages import ButtonRequestType, OutputScriptType
from trezor.ui.text import Text
from trezor.messages import ButtonRequestType
from trezor.messages import OutputScriptType
from apps.common.confirm import confirm
from apps.common.confirm import hold_to_confirm
from trezor.utils import chunks, format_amount
from apps.common.confirm import confirm, hold_to_confirm
from apps.wallet.sign_tx import addresses

View File

@ -1,10 +1,9 @@
from trezor.crypto.hashlib import sha256
from trezor.crypto import bip32
from trezor.utils import HashWriter
from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType
from trezor.messages.HDNodePathType import HDNodePathType
from trezor.crypto.hashlib import sha256
from trezor.messages import FailureType
from trezor.messages.HDNodePathType import HDNodePathType
from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType
from trezor.utils import HashWriter
from apps.wallet.sign_tx.writers import write_bytes, write_uint32

View File

@ -1,17 +1,24 @@
from micropython import const
from trezor.crypto.hashlib import blake2b
from trezor.messages import FailureType, InputScriptType
from trezor.messages.SignTx import SignTx
from trezor.messages.TxInputType import TxInputType
from trezor.messages.TxOutputBinType import TxOutputBinType
from trezor.messages import InputScriptType, FailureType
from trezor.utils import HashWriter
from apps.common.coininfo import CoinInfo
from apps.wallet.sign_tx.writers import write_bytes, write_bytes_rev, write_uint32, write_uint64, write_varint, write_tx_output, get_tx_hash
from apps.wallet.sign_tx.scripts import output_script_p2pkh, output_script_multisig
from apps.wallet.sign_tx.multisig import multisig_get_pubkeys
from apps.wallet.sign_tx.scripts import output_script_multisig, output_script_p2pkh
from apps.wallet.sign_tx.writers import (
get_tx_hash,
write_bytes,
write_bytes_rev,
write_tx_output,
write_uint32,
write_uint64,
write_varint,
)
OVERWINTERED = const(0x80000000)

View File

@ -1,7 +1,14 @@
from trezor.crypto.hashlib import ripemd160, sha256
from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType
from apps.wallet.sign_tx.multisig import multisig_get_pubkeys
from apps.wallet.sign_tx.writers import bytearray_with_cap, write_bytes, write_varint, write_op_push, write_scriptnum
from apps.wallet.sign_tx.writers import (
bytearray_with_cap,
write_bytes,
write_op_push,
write_scriptnum,
write_varint,
)
class ScriptsError(ValueError):
@ -13,7 +20,9 @@ class ScriptsError(ValueError):
# https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
def input_script_p2pkh_or_p2sh(pubkey: bytes, signature: bytes, sighash: int) -> bytearray:
def input_script_p2pkh_or_p2sh(
pubkey: bytes, signature: bytes, sighash: int
) -> bytearray:
w = bytearray_with_cap(5 + len(signature) + 1 + 5 + len(pubkey))
append_signature(w, signature, sighash)
append_pubkey(w, pubkey)
@ -116,7 +125,7 @@ def input_script_p2wsh_in_p2sh(script_hash: bytes) -> bytearray:
# Signature is moved to the witness.
if len(script_hash) != 32:
raise ScriptsError('Redeem script hash should be 32 bytes long')
raise ScriptsError("Redeem script hash should be 32 bytes long")
w = bytearray_with_cap(3 + len(script_hash))
w.append(0x22) # length of the data
@ -138,10 +147,15 @@ def witness_p2wpkh(signature: bytes, pubkey: bytes, sighash: int):
return w
def witness_p2wsh(multisig: MultisigRedeemScriptType, signature: bytes, signature_index: int, sighash: int):
def witness_p2wsh(
multisig: MultisigRedeemScriptType,
signature: bytes,
signature_index: int,
sighash: int,
):
signatures = multisig.signatures # other signatures
if len(signatures[signature_index]) > 0:
raise ScriptsError('Invalid multisig parameters')
raise ScriptsError("Invalid multisig parameters")
signatures[signature_index] = signature # our signature
# filter empty
@ -171,10 +185,15 @@ def witness_p2wsh(multisig: MultisigRedeemScriptType, signature: bytes, signatur
# Used either as P2SH, P2WSH, or P2WSH nested in P2SH.
def input_script_multisig(multisig: MultisigRedeemScriptType, signature: bytes, signature_index: int, sighash: int):
def input_script_multisig(
multisig: MultisigRedeemScriptType,
signature: bytes,
signature_index: int,
sighash: int,
):
signatures = multisig.signatures # other signatures
if len(signatures[signature_index]) > 0:
raise ScriptsError('Invalid multisig parameters')
raise ScriptsError("Invalid multisig parameters")
signatures[signature_index] = signature # our signature
w = bytearray()
@ -199,10 +218,10 @@ def input_script_multisig(multisig: MultisigRedeemScriptType, signature: bytes,
def output_script_multisig(pubkeys, m: int) -> bytearray:
n = len(pubkeys)
if n < 1 or n > 15 or m < 1 or m > 15:
raise ScriptsError('Invalid multisig parameters')
raise ScriptsError("Invalid multisig parameters")
for pubkey in pubkeys:
if len(pubkey) != 33:
raise ScriptsError('Invalid multisig parameters')
raise ScriptsError("Invalid multisig parameters")
w = bytearray()
w.append(0x50 + m) # numbers 1 to 16 are pushed as 0x50 + value

View File

@ -1,14 +1,22 @@
from trezor.crypto.hashlib import sha256
from trezor.messages import FailureType, InputScriptType
from trezor.messages.SignTx import SignTx
from trezor.messages.TxInputType import TxInputType
from trezor.messages.TxOutputBinType import TxOutputBinType
from trezor.messages import InputScriptType, FailureType
from trezor.utils import HashWriter
from apps.common.coininfo import CoinInfo
from apps.wallet.sign_tx.writers import write_bytes, write_bytes_rev, write_uint32, write_uint64, write_varint, write_tx_output, get_tx_hash
from apps.wallet.sign_tx.scripts import output_script_p2pkh, output_script_multisig
from apps.wallet.sign_tx.multisig import multisig_get_pubkeys
from apps.wallet.sign_tx.scripts import output_script_multisig, output_script_p2pkh
from apps.wallet.sign_tx.writers import (
get_tx_hash,
write_bytes,
write_bytes_rev,
write_tx_output,
write_uint32,
write_uint64,
write_varint,
)
class Bip143Error(ValueError):

View File

@ -1,26 +1,28 @@
from micropython import const
from trezor.crypto import base58, bip32, der, cashaddr
from trezor.crypto import base58, bip32, cashaddr, der
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha256
from trezor.utils import HashWriter
from trezor.messages import OutputScriptType
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.utils import HashWriter
from apps.common import address_type, coins
from apps.common.coininfo import CoinInfo
from apps.wallet.sign_tx import progress
from apps.wallet.sign_tx.addresses import *
from apps.wallet.sign_tx.helpers import *
from apps.wallet.sign_tx.multisig import *
from apps.wallet.sign_tx.overwinter_zip143 import ( # noqa:F401
OVERWINTERED,
Zip143,
Zip143Error,
)
from apps.wallet.sign_tx.scripts import *
from apps.wallet.sign_tx.segwit_bip143 import Bip143, Bip143Error # noqa:F401
from apps.wallet.sign_tx.overwinter_zip143 import Zip143, Zip143Error, OVERWINTERED # noqa:F401
from apps.wallet.sign_tx.tx_weight_calculator import *
from apps.wallet.sign_tx.writers import *
from apps.wallet.sign_tx import progress
# the number of bip32 levels used in a wallet (chain and address)
_BIP32_WALLET_DEPTH = const(2)

View File

@ -2,7 +2,6 @@ from trezor.crypto.hashlib import sha256
from trezor.messages.TxInputType import TxInputType
from trezor.messages.TxOutputBinType import TxOutputBinType
# TX Serialization
# ===

View File

@ -3,11 +3,18 @@ from trezor.crypto.curve import secp256k1
from trezor.messages.InputScriptType import SPENDADDRESS, SPENDP2SHWITNESS, SPENDWITNESS
from trezor.messages.Success import Success
from trezor.ui.text import Text
from apps.common import coins
from apps.common.confirm import require_confirm
from apps.common.display_address import split_address
from apps.common.signverify import message_digest, split_message
from apps.wallet.sign_tx.addresses import address_pkh, address_p2wpkh_in_p2sh, address_p2wpkh, address_to_cashaddr, address_short
from apps.wallet.sign_tx.addresses import (
address_p2wpkh,
address_p2wpkh_in_p2sh,
address_pkh,
address_short,
address_to_cashaddr,
)
async def verify_message(ctx, msg):

View File

@ -1,5 +1,6 @@
from trezor import config, loop, res, ui
from trezor.pin import pin_to_int, show_pin_timeout
from apps.common.request_pin import request_pin

View File

@ -1,2 +1,2 @@
import trezorconfig as config # noqa: F401
import trezorio as io # noqa: F401
import trezorio as io # noqa: F401

View File

@ -1 +1,10 @@
from trezorcrypto import bip32, bip39, chacha20poly1305, crc, pbkdf2, random, rfc6979, nem # noqa: F401
from trezorcrypto import ( # noqa: F401
bip32,
bip39,
chacha20poly1305,
crc,
nem,
pbkdf2,
random,
rfc6979,
)

View File

@ -5,7 +5,6 @@
from ubinascii import unhexlify
from ustruct import unpack
_b32alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
_b32tab = [ord(c) for c in _b32alphabet]

View File

@ -1 +1,12 @@
from trezorcrypto import blake256, blake2b, blake2s, groestl512, ripemd160, sha1, sha256, sha512, sha3_256, sha3_512 # noqa: F401
from trezorcrypto import ( # noqa: F401
blake2b,
blake2s,
blake256,
groestl512,
ripemd160,
sha1,
sha3_256,
sha3_512,
sha256,
sha512,
)

View File

@ -1,6 +1,6 @@
from micropython import const
import sys
import utime
from micropython import const
NOTSET = const(0)
DEBUG = const(10)

View File

@ -10,8 +10,8 @@ See `schedule`, `run`, and syscalls `sleep`, `wait`, `signal` and `spawn`.
import utime
import utimeq
from micropython import const
from trezor import log
from trezor import io
from trezor import io, log
after_step_hook = None # function, called after each task step

View File

@ -1,12 +1,7 @@
from micropython import const
from trezor import io
from trezor import ui
from trezor.ui import contains
from trezor.ui import display
from trezor.ui import rotate
from trezor.ui import LazyWidget
from trezor import io, ui
from trezor.ui import LazyWidget, contains, display, rotate
# button events
BTN_CLICKED = const(1)

View File

@ -1,4 +1,5 @@
from micropython import const
from trezor import loop, res, ui
from trezor.ui import Widget
from trezor.ui.button import BTN_ACTIVE, BTN_CLICKED, Button

View File

@ -1,8 +1,8 @@
from micropython import const
from trezor import loop
from trezor import ui
from trezor import loop, ui
from trezor.ui import Widget
from trezor.ui.button import Button, BTN_CLICKED
from trezor.ui.button import BTN_CLICKED, Button
DEVICE = const(0)
HOST = const(1)

View File

@ -1,5 +1,6 @@
import utime
from micropython import const
from trezor import loop, res, ui
_TARGET_MS = const(1000)

View File

@ -1,5 +1,6 @@
from micropython import const
from trezor import io, loop, ui, res
from trezor import io, loop, res, ui
from trezor.ui import display
from trezor.ui.button import BTN_CLICKED, Button
from trezor.ui.swipe import SWIPE_HORIZONTAL, SWIPE_LEFT, Swipe

View File

@ -1,8 +1,9 @@
from micropython import const
from trezor import ui
from trezor.crypto import random
from trezor.ui import display
from trezor.ui.button import Button, BTN_CLICKED
from trezor.ui.button import BTN_CLICKED, Button
def digit_area(i):

View File

@ -1,6 +1,7 @@
from micropython import const
from trezor import loop, ui, res
from trezor.ui.swipe import Swipe, SWIPE_UP, SWIPE_DOWN, SWIPE_VERTICAL
from trezor import loop, res, ui
from trezor.ui.swipe import SWIPE_DOWN, SWIPE_UP, SWIPE_VERTICAL, Swipe
if __debug__:
from apps.debug import swipe_signal

View File

@ -1,6 +1,6 @@
from micropython import const
from trezor.ui import rgb
from trezor.ui import NORMAL, BOLD, MONO
from trezor.ui import BOLD, MONO, NORMAL, rgb
# radius for buttons and other elements
RADIUS = const(2)

View File

@ -1,4 +1,5 @@
from micropython import const
from trezor import io, ui
from trezor.ui import contains, rotate

View File

@ -1,4 +1,5 @@
from micropython import const
from trezor import ui
TEXT_HEADER_HEIGHT = const(48)

View File

@ -1,4 +1,5 @@
from micropython import const
from trezor import loop, ui
from trezor.ui import Widget
from trezor.ui.button import BTN_CLICKED, Button

View File

@ -1,7 +1,6 @@
import sys
import gc
from trezorutils import halt, memcpy, set_mode_unprivileged, symbol, model # noqa: F401
import sys
from trezorutils import halt, memcpy, model, set_mode_unprivileged, symbol # noqa: F401
def unimport_begin():

View File

@ -1,9 +1,7 @@
from micropython import const
import ustruct
from micropython import const
from trezor import io
from trezor import loop
from trezor import utils
from trezor import io, loop, utils
_REP_LEN = const(64)