mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
travis: add make style (using flake8)
This commit is contained in:
parent
2c3221810e
commit
73b2ea6c85
@ -38,6 +38,7 @@ script:
|
|||||||
- test "$GOAL" != "unix" || make build_unix TREZOR_NOUI=1
|
- test "$GOAL" != "unix" || make build_unix TREZOR_NOUI=1
|
||||||
- test "$GOAL" != "unix" || make test
|
- test "$GOAL" != "unix" || make test
|
||||||
- test "$GOAL" != "unix" || make testpy
|
- test "$GOAL" != "unix" || make testpy
|
||||||
|
- test "$GOAL" != "unix" || make style
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks:
|
webhooks:
|
||||||
|
3
Makefile
3
Makefile
@ -50,6 +50,9 @@ testpy: ## run selected unit tests from python-trezor
|
|||||||
pylint: ## run pylint on application sources
|
pylint: ## run pylint on application sources
|
||||||
pylint --rcfile=pylint.rc -E $(shell find src -name *.py)
|
pylint --rcfile=pylint.rc -E $(shell find src -name *.py)
|
||||||
|
|
||||||
|
style: ## run code style check on application sources
|
||||||
|
flake8 --ignore=E221,E241,E402,E501,F401 $(shell find src -name *.py)
|
||||||
|
|
||||||
## build commands:
|
## build commands:
|
||||||
|
|
||||||
build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all
|
build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all
|
||||||
|
@ -26,6 +26,7 @@ def strip(address_type, raw_address):
|
|||||||
l = length(address_type)
|
l = length(address_type)
|
||||||
return raw_address[l:]
|
return raw_address[l:]
|
||||||
|
|
||||||
|
|
||||||
def split(coin, raw_address):
|
def split(coin, raw_address):
|
||||||
l = None
|
l = None
|
||||||
for f in ['', '_p2sh', '_p2wpkh', '_p2wsh']:
|
for f in ['', '_p2sh', '_p2wpkh', '_p2wsh']:
|
||||||
|
@ -2,6 +2,7 @@ from trezor.crypto.hashlib import sha256
|
|||||||
|
|
||||||
from apps.wallet.sign_tx.signing import HashWriter, write_varint
|
from apps.wallet.sign_tx.signing import HashWriter, write_varint
|
||||||
|
|
||||||
|
|
||||||
def message_digest(coin, message):
|
def message_digest(coin, message):
|
||||||
|
|
||||||
h = HashWriter(sha256)
|
h = HashWriter(sha256)
|
||||||
|
@ -9,5 +9,6 @@ def dispatch_EthereumGetAddress(*args, **kwargs):
|
|||||||
from .ethereum_get_address import layout_ethereum_get_address
|
from .ethereum_get_address import layout_ethereum_get_address
|
||||||
return layout_ethereum_get_address(*args, **kwargs)
|
return layout_ethereum_get_address(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def boot():
|
def boot():
|
||||||
register(EthereumGetAddress, protobuf_workflow, dispatch_EthereumGetAddress)
|
register(EthereumGetAddress, protobuf_workflow, dispatch_EthereumGetAddress)
|
||||||
|
@ -415,8 +415,7 @@ class ConfirmContent(ui.Widget):
|
|||||||
name = knownapps.knownapps[app_id]
|
name = knownapps.knownapps[app_id]
|
||||||
icon = res.load('apps/fido_u2f/res/u2f_%s.toif' % name.lower().replace(' ', '_'))
|
icon = res.load('apps/fido_u2f/res/u2f_%s.toif' % name.lower().replace(' ', '_'))
|
||||||
else:
|
else:
|
||||||
name = ubinascii.hexlify(app_id[:4]) + '...' + \
|
name = '%s...%s' % (ubinascii.hexlify(app_id[:4]), ubinascii.hexlify(app_id[-4:]))
|
||||||
ubinascii.hexlify(app_id[-4:])
|
|
||||||
icon = res.load('apps/fido_u2f/res/u2f_unknown.toif')
|
icon = res.load('apps/fido_u2f/res/u2f_unknown.toif')
|
||||||
self.app_name = name
|
self.app_name = name
|
||||||
self.app_icon = icon
|
self.app_icon = icon
|
||||||
|
@ -7,7 +7,6 @@ async def layout_get_entropy(session_id, msg):
|
|||||||
from trezor.messages.Entropy import Entropy
|
from trezor.messages.Entropy import Entropy
|
||||||
from trezor.crypto import random
|
from trezor.crypto import random
|
||||||
|
|
||||||
|
|
||||||
l = min(msg.size, 1024)
|
l = min(msg.size, 1024)
|
||||||
|
|
||||||
await _show_entropy(session_id)
|
await _show_entropy(session_id)
|
||||||
|
@ -53,7 +53,6 @@ def sign_challenge(seckey: bytes,
|
|||||||
from trezor.crypto.curve import ed25519
|
from trezor.crypto.curve import ed25519
|
||||||
from ..common.signverify import message_digest
|
from ..common.signverify import message_digest
|
||||||
|
|
||||||
|
|
||||||
if sigtype == 'gpg':
|
if sigtype == 'gpg':
|
||||||
data = challenge_hidden
|
data = challenge_hidden
|
||||||
elif sigtype == 'ssh':
|
elif sigtype == 'ssh':
|
||||||
@ -63,8 +62,7 @@ def sign_challenge(seckey: bytes,
|
|||||||
data = challenge_hidden
|
data = challenge_hidden
|
||||||
else:
|
else:
|
||||||
# sigtype is coin
|
# sigtype is coin
|
||||||
challenge = sha256(challenge_hidden).digest() + \
|
challenge = sha256(challenge_hidden).digest() + sha256(challenge_visual).digest()
|
||||||
sha256(challenge_visual).digest()
|
|
||||||
data = message_digest(sigtype, challenge)
|
data = message_digest(sigtype, challenge)
|
||||||
|
|
||||||
if curve == 'secp256k1':
|
if curve == 'secp256k1':
|
||||||
|
@ -162,7 +162,7 @@ class MessageType(Type):
|
|||||||
@classmethod
|
@classmethod
|
||||||
async def load(cls, source=None, target=None):
|
async def load(cls, source=None, target=None):
|
||||||
if target is None:
|
if target is None:
|
||||||
target = build_protobuf_message(cls)
|
target = build_message(cls)
|
||||||
if source is None:
|
if source is None:
|
||||||
source = StreamReader()
|
source = StreamReader()
|
||||||
try:
|
try:
|
||||||
|
@ -48,6 +48,7 @@ class __dummy:
|
|||||||
def __getitem__(self, *args):
|
def __getitem__(self, *args):
|
||||||
return object
|
return object
|
||||||
|
|
||||||
|
|
||||||
__t = __dummy()
|
__t = __dummy()
|
||||||
|
|
||||||
for __n in __names_get:
|
for __n in __names_get:
|
||||||
@ -64,4 +65,5 @@ def TypeVar(*args):
|
|||||||
def NewType(*args):
|
def NewType(*args):
|
||||||
return lambda x: x
|
return lambda x: x
|
||||||
|
|
||||||
|
|
||||||
TYPE_CHECKING = False
|
TYPE_CHECKING = False
|
||||||
|
@ -59,25 +59,23 @@ def decode(string: str) -> bytes:
|
|||||||
return bytes((b for b in reversed(result + [0] * (origlen - newlen))))
|
return bytes((b for b in reversed(result + [0] * (origlen - newlen))))
|
||||||
|
|
||||||
|
|
||||||
def encode_check(data: bytes, digestfunc=None) -> str:
|
def _dsha256_32(data: bytes) -> bytes:
|
||||||
|
from .hashlib import sha256
|
||||||
|
return sha256(sha256(data).digest()).digest()[:4]
|
||||||
|
|
||||||
|
|
||||||
|
def encode_check(data: bytes, digestfunc=_dsha256_32) -> str:
|
||||||
'''
|
'''
|
||||||
Convert bytes to base58 encoded string, append checksum.
|
Convert bytes to base58 encoded string, append checksum.
|
||||||
'''
|
'''
|
||||||
if digestfunc is None:
|
|
||||||
from .hashlib import sha256
|
|
||||||
digestfunc = lambda x: sha256(sha256(x).digest()).digest()[:4]
|
|
||||||
return encode(data + digestfunc(data))
|
return encode(data + digestfunc(data))
|
||||||
|
|
||||||
|
|
||||||
def decode_check(string: str, digestfunc=None) -> bytes:
|
def decode_check(string: str, digestfunc=_dsha256_32) -> bytes:
|
||||||
'''
|
'''
|
||||||
Convert base58 encoded string to bytes and verify checksum.
|
Convert base58 encoded string to bytes and verify checksum.
|
||||||
'''
|
'''
|
||||||
result = decode(string)
|
result = decode(string)
|
||||||
|
|
||||||
if digestfunc is None:
|
|
||||||
from .hashlib import sha256
|
|
||||||
digestfunc = lambda x: sha256(sha256(x).digest()).digest()[:4]
|
|
||||||
digestlen = len(digestfunc(b''))
|
digestlen = len(digestfunc(b''))
|
||||||
result, check = result[:-digestlen], result[-digestlen:]
|
result, check = result[:-digestlen], result[-digestlen:]
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Address(p.MessageType):
|
class Address(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UnicodeType, 0), # required
|
1: ('address', p.UnicodeType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ApplySettings(p.MessageType):
|
class ApplySettings(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('language', p.UnicodeType, 0),
|
1: ('language', p.UnicodeType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ButtonAck(p.MessageType):
|
class ButtonAck(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 27
|
MESSAGE_WIRE_TYPE = 27
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ButtonRequest(p.MessageType):
|
class ButtonRequest(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('code', p.UVarintType, 0),
|
1: ('code', p.UVarintType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Cancel(p.MessageType):
|
class Cancel(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 20
|
MESSAGE_WIRE_TYPE = 20
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ChangePin(p.MessageType):
|
class ChangePin(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('remove', p.BoolType, 0),
|
1: ('remove', p.BoolType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class CipherKeyValue(p.MessageType):
|
class CipherKeyValue(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class CipheredKeyValue(p.MessageType):
|
class CipheredKeyValue(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('value', p.BytesType, 0),
|
1: ('value', p.BytesType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ClearSession(p.MessageType):
|
class ClearSession(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 24
|
MESSAGE_WIRE_TYPE = 24
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class CoinType(p.MessageType):
|
class CoinType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('coin_name', p.UnicodeType, 0),
|
1: ('coin_name', p.UnicodeType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkDecision(p.MessageType):
|
class DebugLinkDecision(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('yes_no', p.BoolType, 0), # required
|
1: ('yes_no', p.BoolType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkFlashErase(p.MessageType):
|
class DebugLinkFlashErase(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('sector', p.UVarintType, 0),
|
1: ('sector', p.UVarintType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkGetState(p.MessageType):
|
class DebugLinkGetState(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 101
|
MESSAGE_WIRE_TYPE = 101
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkLog(p.MessageType):
|
class DebugLinkLog(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('level', p.UVarintType, 0),
|
1: ('level', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkMemory(p.MessageType):
|
class DebugLinkMemory(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('memory', p.BytesType, 0),
|
1: ('memory', p.BytesType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkMemoryRead(p.MessageType):
|
class DebugLinkMemoryRead(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UVarintType, 0),
|
1: ('address', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkMemoryWrite(p.MessageType):
|
class DebugLinkMemoryWrite(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UVarintType, 0),
|
1: ('address', p.UVarintType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .HDNodeType import HDNodeType
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkState(p.MessageType):
|
class DebugLinkState(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('layout', p.BytesType, 0),
|
1: ('layout', p.BytesType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DebugLinkStop(p.MessageType):
|
class DebugLinkStop(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 103
|
MESSAGE_WIRE_TYPE = 103
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DecryptMessage(p.MessageType):
|
class DecryptMessage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class DecryptedMessage(p.MessageType):
|
class DecryptedMessage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('message', p.BytesType, 0),
|
1: ('message', p.BytesType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ECDHSessionKey(p.MessageType):
|
class ECDHSessionKey(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('session_key', p.BytesType, 0),
|
1: ('session_key', p.BytesType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EncryptMessage(p.MessageType):
|
class EncryptMessage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('pubkey', p.BytesType, 0),
|
1: ('pubkey', p.BytesType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EncryptedMessage(p.MessageType):
|
class EncryptedMessage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('nonce', p.BytesType, 0),
|
1: ('nonce', p.BytesType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Entropy(p.MessageType):
|
class Entropy(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('entropy', p.BytesType, 0), # required
|
1: ('entropy', p.BytesType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EntropyAck(p.MessageType):
|
class EntropyAck(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('entropy', p.BytesType, 0),
|
1: ('entropy', p.BytesType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EntropyRequest(p.MessageType):
|
class EntropyRequest(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 35
|
MESSAGE_WIRE_TYPE = 35
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EstimateTxSize(p.MessageType):
|
class EstimateTxSize(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('outputs_count', p.UVarintType, 0), # required
|
1: ('outputs_count', p.UVarintType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EthereumAddress(p.MessageType):
|
class EthereumAddress(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.BytesType, 0), # required
|
1: ('address', p.BytesType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EthereumGetAddress(p.MessageType):
|
class EthereumGetAddress(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EthereumSignTx(p.MessageType):
|
class EthereumSignTx(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EthereumTxAck(p.MessageType):
|
class EthereumTxAck(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('data_chunk', p.BytesType, 0),
|
1: ('data_chunk', p.BytesType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class EthereumTxRequest(p.MessageType):
|
class EthereumTxRequest(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('data_length', p.UVarintType, 0),
|
1: ('data_length', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Failure(p.MessageType):
|
class Failure(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('code', p.UVarintType, 0),
|
1: ('code', p.UVarintType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .CoinType import CoinType
|
from .CoinType import CoinType
|
||||||
|
|
||||||
|
|
||||||
class Features(p.MessageType):
|
class Features(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('vendor', p.UnicodeType, 0),
|
1: ('vendor', p.UnicodeType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class FirmwareErase(p.MessageType):
|
class FirmwareErase(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 6
|
MESSAGE_WIRE_TYPE = 6
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class FirmwareRequest(p.MessageType):
|
class FirmwareRequest(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('offset', p.UVarintType, 0),
|
1: ('offset', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class FirmwareUpload(p.MessageType):
|
class FirmwareUpload(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('payload', p.BytesType, 0), # required
|
1: ('payload', p.BytesType, 0), # required
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
||||||
|
|
||||||
|
|
||||||
class GetAddress(p.MessageType):
|
class GetAddress(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .IdentityType import IdentityType
|
from .IdentityType import IdentityType
|
||||||
|
|
||||||
|
|
||||||
class GetECDHSessionKey(p.MessageType):
|
class GetECDHSessionKey(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('identity', IdentityType, 0),
|
1: ('identity', IdentityType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class GetEntropy(p.MessageType):
|
class GetEntropy(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('size', p.UVarintType, 0), # required
|
1: ('size', p.UVarintType, 0), # required
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class GetFeatures(p.MessageType):
|
class GetFeatures(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 55
|
MESSAGE_WIRE_TYPE = 55
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class GetPublicKey(p.MessageType):
|
class GetPublicKey(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .HDNodeType import HDNodeType
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
class HDNodePathType(p.MessageType):
|
class HDNodePathType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('node', HDNodeType, 0), # required
|
1: ('node', HDNodeType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class HDNodeType(p.MessageType):
|
class HDNodeType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('depth', p.UVarintType, 0), # required
|
1: ('depth', p.UVarintType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class IdentityType(p.MessageType):
|
class IdentityType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('proto', p.UnicodeType, 0),
|
1: ('proto', p.UnicodeType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Initialize(p.MessageType):
|
class Initialize(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 0
|
MESSAGE_WIRE_TYPE = 0
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .HDNodeType import HDNodeType
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
class LoadDevice(p.MessageType):
|
class LoadDevice(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('mnemonic', p.UnicodeType, 0),
|
1: ('mnemonic', p.UnicodeType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class MessageSignature(p.MessageType):
|
class MessageSignature(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UnicodeType, 0),
|
1: ('address', p.UnicodeType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .HDNodePathType import HDNodePathType
|
from .HDNodePathType import HDNodePathType
|
||||||
|
|
||||||
|
|
||||||
class MultisigRedeemScriptType(p.MessageType):
|
class MultisigRedeemScriptType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('pubkeys', HDNodePathType, p.FLAG_REPEATED),
|
1: ('pubkeys', HDNodePathType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class PassphraseAck(p.MessageType):
|
class PassphraseAck(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('passphrase', p.UnicodeType, 0), # required
|
1: ('passphrase', p.UnicodeType, 0), # required
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class PassphraseRequest(p.MessageType):
|
class PassphraseRequest(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 41
|
MESSAGE_WIRE_TYPE = 41
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class PinMatrixAck(p.MessageType):
|
class PinMatrixAck(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('pin', p.UnicodeType, 0), # required
|
1: ('pin', p.UnicodeType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class PinMatrixRequest(p.MessageType):
|
class PinMatrixRequest(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('type', p.UVarintType, 0),
|
1: ('type', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Ping(p.MessageType):
|
class Ping(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('message', p.UnicodeType, 0),
|
1: ('message', p.UnicodeType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .HDNodeType import HDNodeType
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
class PublicKey(p.MessageType):
|
class PublicKey(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('node', HDNodeType, 0), # required
|
1: ('node', HDNodeType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class RecoveryDevice(p.MessageType):
|
class RecoveryDevice(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('word_count', p.UVarintType, 0),
|
1: ('word_count', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class ResetDevice(p.MessageType):
|
class ResetDevice(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('display_random', p.BoolType, 0),
|
1: ('display_random', p.BoolType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class SetU2FCounter(p.MessageType):
|
class SetU2FCounter(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('u2f_counter', p.UVarintType, 0),
|
1: ('u2f_counter', p.UVarintType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .IdentityType import IdentityType
|
from .IdentityType import IdentityType
|
||||||
|
|
||||||
|
|
||||||
class SignIdentity(p.MessageType):
|
class SignIdentity(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('identity', IdentityType, 0),
|
1: ('identity', IdentityType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class SignMessage(p.MessageType):
|
class SignMessage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class SignTx(p.MessageType):
|
class SignTx(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('outputs_count', p.UVarintType, 0), # required
|
1: ('outputs_count', p.UVarintType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class SignedIdentity(p.MessageType):
|
class SignedIdentity(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UnicodeType, 0),
|
1: ('address', p.UnicodeType, 0),
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .TxInputType import TxInputType
|
from .TxInputType import TxInputType
|
||||||
from .TxOutputType import TxOutputType
|
from .TxOutputType import TxOutputType
|
||||||
from .TransactionType import TransactionType
|
from .TransactionType import TransactionType
|
||||||
|
|
||||||
|
|
||||||
class SimpleSignTx(p.MessageType):
|
class SimpleSignTx(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('inputs', TxInputType, p.FLAG_REPEATED),
|
1: ('inputs', TxInputType, p.FLAG_REPEATED),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .HDNodeType import HDNodeType
|
from .HDNodeType import HDNodeType
|
||||||
|
|
||||||
|
|
||||||
class Storage(p.MessageType):
|
class Storage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('version', p.UVarintType, 0), # required
|
1: ('version', p.UVarintType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class Success(p.MessageType):
|
class Success(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('message', p.UnicodeType, 0),
|
1: ('message', p.UnicodeType, 0),
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .TxInputType import TxInputType
|
from .TxInputType import TxInputType
|
||||||
from .TxOutputBinType import TxOutputBinType
|
from .TxOutputBinType import TxOutputBinType
|
||||||
from .TxOutputType import TxOutputType
|
from .TxOutputType import TxOutputType
|
||||||
|
|
||||||
|
|
||||||
class TransactionType(p.MessageType):
|
class TransactionType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('version', p.UVarintType, 0),
|
1: ('version', p.UVarintType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .TransactionType import TransactionType
|
from .TransactionType import TransactionType
|
||||||
|
|
||||||
|
|
||||||
class TxAck(p.MessageType):
|
class TxAck(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('tx', TransactionType, 0),
|
1: ('tx', TransactionType, 0),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
||||||
|
|
||||||
|
|
||||||
class TxInputType(p.MessageType):
|
class TxInputType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class TxOutputBinType(p.MessageType):
|
class TxOutputBinType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('amount', p.UVarintType, 0), # required
|
1: ('amount', p.UVarintType, 0), # required
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
from .MultisigRedeemScriptType import MultisigRedeemScriptType
|
||||||
|
|
||||||
|
|
||||||
class TxOutputType(p.MessageType):
|
class TxOutputType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UnicodeType, 0),
|
1: ('address', p.UnicodeType, 0),
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
from .TxRequestDetailsType import TxRequestDetailsType
|
from .TxRequestDetailsType import TxRequestDetailsType
|
||||||
from .TxRequestSerializedType import TxRequestSerializedType
|
from .TxRequestSerializedType import TxRequestSerializedType
|
||||||
|
|
||||||
|
|
||||||
class TxRequest(p.MessageType):
|
class TxRequest(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('request_type', p.UVarintType, 0),
|
1: ('request_type', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class TxRequestDetailsType(p.MessageType):
|
class TxRequestDetailsType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('request_index', p.UVarintType, 0),
|
1: ('request_index', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class TxRequestSerializedType(p.MessageType):
|
class TxRequestSerializedType(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('signature_index', p.UVarintType, 0),
|
1: ('signature_index', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class TxSize(p.MessageType):
|
class TxSize(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('tx_size', p.UVarintType, 0),
|
1: ('tx_size', p.UVarintType, 0),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class VerifyMessage(p.MessageType):
|
class VerifyMessage(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('address', p.UnicodeType, 0),
|
1: ('address', p.UnicodeType, 0),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class WipeDevice(p.MessageType):
|
class WipeDevice(p.MessageType):
|
||||||
MESSAGE_WIRE_TYPE = 5
|
MESSAGE_WIRE_TYPE = 5
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class WordAck(p.MessageType):
|
class WordAck(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('word', p.UnicodeType, 0), # required
|
1: ('word', p.UnicodeType, 0), # required
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Automatically generated by pb2py
|
# Automatically generated by pb2py
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
import protobuf as p
|
import protobuf as p
|
||||||
|
|
||||||
|
|
||||||
class WordRequest(p.MessageType):
|
class WordRequest(p.MessageType):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
1: ('type', p.UVarintType, 0),
|
1: ('type', p.UVarintType, 0),
|
||||||
|
@ -20,4 +20,5 @@ def gettext(message):
|
|||||||
'''
|
'''
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
_ = gettext
|
_ = gettext
|
||||||
|
@ -42,9 +42,9 @@ class Swipe(ui.Widget):
|
|||||||
# check if its vertical scroll up
|
# check if its vertical scroll up
|
||||||
velya = abs(pdy / td) if td > 0 else 1
|
velya = abs(pdy / td) if td > 0 else 1
|
||||||
ratio = int(pdxa / pdya * 100) if pdya > 0 else 100
|
ratio = int(pdxa / pdya * 100) if pdya > 0 else 100
|
||||||
if (velya >= _SWIPE_VELOCITY_THRESHOLD
|
if (velya >= _SWIPE_VELOCITY_THRESHOLD and
|
||||||
and pdya >= _SWIPE_DISTANCE_THRESHOLD
|
pdya >= _SWIPE_DISTANCE_THRESHOLD and
|
||||||
and ratio <= _SWIPE_RATIO_THRESHOLD):
|
ratio <= _SWIPE_RATIO_THRESHOLD):
|
||||||
light = ui.display.backlight()
|
light = ui.display.backlight()
|
||||||
if light > self.light_target:
|
if light > self.light_target:
|
||||||
light -= 5
|
light -= 5
|
||||||
@ -68,17 +68,17 @@ class Swipe(ui.Widget):
|
|||||||
# Horizontal direction
|
# Horizontal direction
|
||||||
velxa = abs(pdx / td)
|
velxa = abs(pdx / td)
|
||||||
ratio = int(pdya / pdxa * 100) if pdxa > 0 else 100
|
ratio = int(pdya / pdxa * 100) if pdxa > 0 else 100
|
||||||
if (velxa >= _SWIPE_VELOCITY_THRESHOLD
|
if (velxa >= _SWIPE_VELOCITY_THRESHOLD and
|
||||||
and pdxa >= _SWIPE_DISTANCE_THRESHOLD
|
pdxa >= _SWIPE_DISTANCE_THRESHOLD and
|
||||||
and ratio <= _SWIPE_RATIO_THRESHOLD):
|
ratio <= _SWIPE_RATIO_THRESHOLD):
|
||||||
return SWIPE_RIGHT if pdx > 0 else SWIPE_LEFT
|
return SWIPE_RIGHT if pdx > 0 else SWIPE_LEFT
|
||||||
else:
|
else:
|
||||||
# Vertical direction
|
# Vertical direction
|
||||||
velya = abs(pdy / td)
|
velya = abs(pdy / td)
|
||||||
ratio = int(pdxa / pdya * 100) if pdya > 0 else 100
|
ratio = int(pdxa / pdya * 100) if pdya > 0 else 100
|
||||||
if (velya >= _SWIPE_VELOCITY_THRESHOLD
|
if (velya >= _SWIPE_VELOCITY_THRESHOLD and
|
||||||
and pdya >= _SWIPE_DISTANCE_THRESHOLD
|
pdya >= _SWIPE_DISTANCE_THRESHOLD and
|
||||||
and ratio <= _SWIPE_RATIO_THRESHOLD):
|
ratio <= _SWIPE_RATIO_THRESHOLD):
|
||||||
if pdy < 0:
|
if pdy < 0:
|
||||||
ui.display.backlight(self.light_origin)
|
ui.display.backlight(self.light_origin)
|
||||||
return SWIPE_DOWN if pdy > 0 else SWIPE_UP
|
return SWIPE_DOWN if pdy > 0 else SWIPE_UP
|
||||||
|
@ -3,6 +3,8 @@ CURDIR=$(pwd)
|
|||||||
mkdir -p $CURDIR/pb2/
|
mkdir -p $CURDIR/pb2/
|
||||||
echo > $CURDIR/pb2/__init__.py
|
echo > $CURDIR/pb2/__init__.py
|
||||||
|
|
||||||
|
mkdir -p ../src/trezor/messages
|
||||||
|
|
||||||
INDEX=../src/trezor/messages/wire_types.py
|
INDEX=../src/trezor/messages/wire_types.py
|
||||||
rm -f $INDEX
|
rm -f $INDEX
|
||||||
echo '# Automatically generated by pb2py' >> $INDEX
|
echo '# Automatically generated by pb2py' >> $INDEX
|
||||||
@ -18,7 +20,7 @@ done
|
|||||||
for i in types messages storage ; do
|
for i in types messages storage ; do
|
||||||
# Convert google protobuf library to trezor's internal format
|
# Convert google protobuf library to trezor's internal format
|
||||||
cd $CURDIR
|
cd $CURDIR
|
||||||
../../trezor-common/tools/pb2py -m -p $CURDIR -i $INDEX $i ../src/trezor/messages/
|
./pb2py -m -p $CURDIR -i $INDEX $i ../src/trezor/messages/
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -rf $CURDIR/pb2/
|
rm -rf $CURDIR/pb2/
|
||||||
|
189
tools/pb2py
Executable file
189
tools/pb2py
Executable file
@ -0,0 +1,189 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Converts Google's protobuf python definitions of TREZOR wire messages
|
||||||
|
# to plain-python objects as used in TREZOR Core and python-trezor
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
|
||||||
|
|
||||||
|
|
||||||
|
def process_type(t, cls, msg_id, indexfile, is_upy):
|
||||||
|
print(" * type %s" % t)
|
||||||
|
|
||||||
|
imports = ['import protobuf as p']
|
||||||
|
|
||||||
|
out = ["", "", "class %s(p.MessageType):" % t, ]
|
||||||
|
|
||||||
|
if cls.DESCRIPTOR.fields_by_name:
|
||||||
|
out.append(" FIELDS = {")
|
||||||
|
elif msg_id is None:
|
||||||
|
out.append(" pass")
|
||||||
|
|
||||||
|
for v in sorted(cls.DESCRIPTOR.fields_by_name.values(), key=lambda x: x.number):
|
||||||
|
number = v.number
|
||||||
|
fieldname = v.name
|
||||||
|
type = None
|
||||||
|
repeated = v.label == 3
|
||||||
|
required = v.label == 2
|
||||||
|
|
||||||
|
# print v.has_default_value, v.default_value
|
||||||
|
|
||||||
|
if v.type in (4, 13, 14):
|
||||||
|
# TYPE_UINT64 = 4
|
||||||
|
# TYPE_UINT32 = 13
|
||||||
|
# TYPE_ENUM = 14
|
||||||
|
type = 'p.UVarintType'
|
||||||
|
|
||||||
|
elif v.type == 9:
|
||||||
|
# TYPE_STRING = 9
|
||||||
|
type = 'p.UnicodeType'
|
||||||
|
|
||||||
|
elif v.type == 8:
|
||||||
|
# TYPE_BOOL = 8
|
||||||
|
type = 'p.BoolType'
|
||||||
|
|
||||||
|
elif v.type == 12:
|
||||||
|
# TYPE_BYTES = 12
|
||||||
|
type = 'p.BytesType'
|
||||||
|
|
||||||
|
elif v.type == 11:
|
||||||
|
# TYPE_MESSAGE = 1
|
||||||
|
type = v.message_type.name
|
||||||
|
imports.append("from .%s import %s" %
|
||||||
|
(v.message_type.name, v.message_type.name))
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown field type %s for field %s" %
|
||||||
|
(v.type, fieldname))
|
||||||
|
|
||||||
|
if required:
|
||||||
|
comment = ' # required'
|
||||||
|
elif v.has_default_value:
|
||||||
|
comment = ' # default=%s' % repr(v.default_value)
|
||||||
|
else:
|
||||||
|
comment = ''
|
||||||
|
|
||||||
|
if repeated:
|
||||||
|
flags = 'p.FLAG_REPEATED'
|
||||||
|
else:
|
||||||
|
flags = '0'
|
||||||
|
|
||||||
|
out.append(" %d: ('%s', %s, %s),%s" %
|
||||||
|
(number, fieldname, type, flags, comment))
|
||||||
|
|
||||||
|
# print fieldname, number, type, repeated, comment
|
||||||
|
# print v.__dict__
|
||||||
|
# print v.CPPTYPE_STRING
|
||||||
|
# print v.LABEL_REPEATED
|
||||||
|
# print v.enum_type
|
||||||
|
# v.has_default_value, v.default_value
|
||||||
|
# v.label == 3 # repeated
|
||||||
|
# print v.number
|
||||||
|
|
||||||
|
if cls.DESCRIPTOR.fields_by_name:
|
||||||
|
out.append(" }")
|
||||||
|
|
||||||
|
if msg_id is not None:
|
||||||
|
out.append(" MESSAGE_WIRE_TYPE = %d" % msg_id)
|
||||||
|
if indexfile is not None:
|
||||||
|
if is_upy:
|
||||||
|
indexfile.write("%s = const(%d)\n" % (t, msg_id))
|
||||||
|
else:
|
||||||
|
indexfile.write("%s = %d\n" % (t, msg_id))
|
||||||
|
|
||||||
|
return imports + out
|
||||||
|
|
||||||
|
|
||||||
|
def process_enum(t, cls, is_upy):
|
||||||
|
out = []
|
||||||
|
|
||||||
|
if is_upy:
|
||||||
|
out += ("from micropython import const", "")
|
||||||
|
|
||||||
|
print(" * enum %s" % t)
|
||||||
|
|
||||||
|
for k, v in cls.items():
|
||||||
|
# Remove type name from the beginning of the constant
|
||||||
|
# For example "PinMatrixRequestType_Current" -> "Current"
|
||||||
|
if k.startswith("%s_" % t):
|
||||||
|
k = k.replace("%s_" % t, '')
|
||||||
|
|
||||||
|
# If type ends with *Type, but constant use type name without *Type, remove it too :)
|
||||||
|
# For example "ButtonRequestType & ButtonRequest_Other" => "Other"
|
||||||
|
if t.endswith("Type") and k.startswith("%s_" % t.replace("Type", '')):
|
||||||
|
k = k.replace("%s_" % t.replace("Type", ''), '')
|
||||||
|
|
||||||
|
if is_upy:
|
||||||
|
out.append("%s = const(%s)" % (k, v))
|
||||||
|
else:
|
||||||
|
out.append("%s = %s" % (k, v))
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def find_msg_type(msg_types, t):
|
||||||
|
for k, v in msg_types:
|
||||||
|
msg_name = k.replace('MessageType_', '')
|
||||||
|
if msg_name == t:
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
def process_module(mod, genpath, indexfile, is_upy):
|
||||||
|
|
||||||
|
print("Processing module %s" % mod.__name__)
|
||||||
|
types = dict([(name, cls)
|
||||||
|
for name, cls in mod.__dict__.items() if isinstance(cls, type)])
|
||||||
|
|
||||||
|
msg_types = __import__('pb2', globals(), locals(), [
|
||||||
|
'messages_pb2', ]).messages_pb2.MessageType.items()
|
||||||
|
|
||||||
|
for t, cls in types.items():
|
||||||
|
# Find message type for given class
|
||||||
|
msg_id = find_msg_type(msg_types, t)
|
||||||
|
|
||||||
|
out = process_type(t, cls, msg_id, indexfile, is_upy)
|
||||||
|
|
||||||
|
write_to_file(genpath, t, out)
|
||||||
|
|
||||||
|
enums = dict([(name, cls) for name, cls in mod.__dict__.items()
|
||||||
|
if isinstance(cls, EnumTypeWrapper)])
|
||||||
|
|
||||||
|
for t, cls in enums.items():
|
||||||
|
out = process_enum(t, cls, is_upy)
|
||||||
|
write_to_file(genpath, t, out)
|
||||||
|
|
||||||
|
|
||||||
|
def write_to_file(genpath, t, out):
|
||||||
|
# Write generated sourcecode to given file
|
||||||
|
f = open(os.path.join(genpath, "%s.py" % t), 'w')
|
||||||
|
out = ["# Automatically generated by pb2py"] + out
|
||||||
|
|
||||||
|
data = "\n".join(out) + "\n"
|
||||||
|
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('modulename', type=str, help="Name of module to generate")
|
||||||
|
parser.add_argument('genpath', type=str, help="Directory for generated source code")
|
||||||
|
parser.add_argument('-i', '--indexfile', type=str, help="[optional] Generate index file of wire types")
|
||||||
|
parser.add_argument('-p', '--protopath', type=str, help="[optional] Path to search for pregenerated Google's python sources")
|
||||||
|
parser.add_argument('-m', '--micropython', action='store_true', help="Use micropython-favoured source code")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.indexfile:
|
||||||
|
indexfile = open(args.indexfile, 'a')
|
||||||
|
else:
|
||||||
|
indexfile = None
|
||||||
|
|
||||||
|
if args.protopath:
|
||||||
|
sys.path.append(args.protopath)
|
||||||
|
|
||||||
|
# Dynamically load module from argv[1]
|
||||||
|
tmp = __import__('pb2', globals(), locals(), ['%s_pb2' % args.modulename])
|
||||||
|
mod = getattr(tmp, "%s_pb2" % args.modulename)
|
||||||
|
|
||||||
|
process_module(mod, args.genpath, indexfile, args.micropython)
|
Loading…
Reference in New Issue
Block a user