diff --git a/tools/build_protobuf b/tools/build_protobuf index fd2eb5b69..6b32317fb 100755 --- a/tools/build_protobuf +++ b/tools/build_protobuf @@ -1,6 +1,17 @@ #!/bin/bash set -e +IS_CORE="" + +if [ "$1" == "--core" ]; then + shift + IS_CORE=yes +elif [ "$1" == "--no-core" ]; then + shift +elif echo $PWD | grep -q "trezor-core"; then + IS_CORE=yes +fi + if [ -n "$1" ]; then OUTDIR=`readlink -f "$1"` fi @@ -29,17 +40,26 @@ for file in $PROTO_FILES; do protoc --python_out="$PB2_OUT" -I/usr/include -I"$PROTO_PATH" "$PROTO_PATH/$file.proto" done -# create index (__init__.py) -cat > "$TMPDIR/$INDEX" << EOF -# Automatically generated by pb2py -EOF +if [ -n "$IS_CORE" ]; then + # generate for micropython + PB2PY_OPTS="-m" +else + # create index (__init__.py) + echo "# Automatically generated by pb2py" > $TMPDIR/$INDEX + echo >> $TMPDIR/$INDEX + PB2PY_OPTS="-l $TMPDIR/$INDEX" +fi # convert google protobuf library to trezor's internal format for file in $PROTO_FILES; do - ./pb2py -P "trezorlib.protobuf" -p "$PB2_OUT" -l "$TMPDIR/$INDEX" "$file" "$TMPDIR" + ./pb2py $PB2PY_OPTS -P "trezorlib.protobuf" -p "$PB2_OUT" "$file" "$TMPDIR" done +if [ -n "$IS_CORE" ]; then + cp "$TMPDIR/MessageType.py" "$TMPDIR/wire_types.py" +fi + # ensure $GENPATH exists and is empty of messages mkdir -p "$GENPATH" # only remove messages - there could possibly be other files not starting with capital letter diff --git a/tools/pb2py b/tools/pb2py index 58a11e5e5..6f1bc2af7 100755 --- a/tools/pb2py +++ b/tools/pb2py @@ -7,6 +7,44 @@ import importlib import logging import os import sys +from collections import namedtuple + +ProtoField = namedtuple('ProtoField', 'name, number, proto_type, py_type, repeated, required, orig') + + +def parse_field(number, field): + FIELD_TYPES = { + field.TYPE_UINT64: ('p.UVarintType', 'int'), + field.TYPE_UINT32: ('p.UVarintType', 'int'), + field.TYPE_ENUM: ('p.UVarintType', 'int'), + field.TYPE_SINT32: ('p.SVarintType', 'int'), + field.TYPE_SINT64: ('p.SVarintType', 'int'), + field.TYPE_STRING: ('p.UnicodeType', 'str'), + field.TYPE_BOOL: ('p.BoolType', 'bool'), + field.TYPE_BYTES: ('p.BytesType', 'bytes'), + } + repeated = (field.label == field.LABEL_REPEATED) + required = (field.label == field.LABEL_REQUIRED) + if field.type == field.TYPE_MESSAGE: + proto_type = py_type = field.message_type.name + else: + try: + proto_type, py_type = FIELD_TYPES[field.type] + except KeyError: + raise ValueError("Unknown field type %d for field %s" % (field.type, field.name)) from None + + if repeated: + py_type = "List[%s]" % py_type + + return ProtoField( + name=field.name, + number=number, + proto_type=proto_type, + py_type=py_type, + repeated=repeated, + required=required, + orig=field, + ) def import_pb2(name): @@ -17,13 +55,6 @@ def create_message_import(name): return "from .%s import %s" % (name, name) -def create_const(name, value, is_upy): - if is_upy: - return "%s = const(%s)" % (name, value) - else: - return "%s = %s" % (name, value) - - def remove_from_start(s, prefix): if s.startswith(prefix): return s[len(prefix):] @@ -42,83 +73,82 @@ def process_message_imports(descriptor): yield create_message_import(name) -def process_message(descriptor, protobuf_module, msg_id, indexfile, is_upy): +def create_init_method(fields): + yield " def __init__(" + yield " self," + for field in fields[:-1]: + yield " %s: %s = None," % (field.name, field.py_type) + # last field must not have a traling comma + yield " %s: %s = None" % (fields[-1].name, fields[-1].py_type) + yield " ) -> None:" + + for field in fields: + if field.repeated: + yield " self.{0} = {0} if {0} is not None else []".format(field.name) + else: + yield " self.{0} = {0}".format(field.name) + + +def process_message(descriptor, protobuf_module, msg_id, is_upy): logging.debug("Processing message %s", descriptor.name) if is_upy: yield "import protobuf as p" else: yield "from .. import protobuf as p" + + fields = list(parse_field(number, field) + for number, field + in descriptor.fields_by_number.items()) + + if any(field.repeated for field in fields): + yield "if __debug__:" + yield " try:" + yield " from typing import List" + yield " except ImportError:" + yield " List = None" + yield from process_message_imports(descriptor) yield "" yield "" yield "class %s(p.MessageType):" % descriptor.name - if descriptor.fields_by_number: - yield " FIELDS = {" - elif msg_id is None: - yield " pass" - - for number, field in descriptor.fields_by_number.items(): - field_name = field.name - field_type = None - repeated = (field.label == field.LABEL_REPEATED) - required = (field.label == field.LABEL_REQUIRED) - - types = { - field.TYPE_UINT64: 'p.UVarintType', - field.TYPE_UINT32: 'p.UVarintType', - field.TYPE_ENUM: 'p.UVarintType', - field.TYPE_SINT32: 'p.SVarintType', - field.TYPE_SINT64: 'p.SVarintType', - field.TYPE_STRING: 'p.UnicodeType', - field.TYPE_BOOL: 'p.BoolType', - field.TYPE_BYTES: 'p.BytesType' - } - - if field.type == field.TYPE_MESSAGE: - field_type = field.message_type.name - else: - try: - field_type = types[field.type] - except KeyError: - raise ValueError("Unknown field type %d for field %s" % (field.type, field_name)) - - comments = [] - if required: - comments.append('required') - if field.has_default_value: - comments.append("default=%s" % repr(field.default_value)) - - if comments: - comment = " # %s" % ' '.join(comments) - else: - comment = '' - - if repeated: - flags = 'p.FLAG_REPEATED' - else: - flags = '0' - - yield " %d: ('%s', %s, %s),%s" % (number, field_name, field_type, flags, comment) - - if descriptor.fields_by_name: - yield " }" - if msg_id is not None: yield " MESSAGE_WIRE_TYPE = %d" % msg_id - if indexfile is not None: - indexfile.write(create_const(t, msg_id, is_upy)) + + if fields: + yield " FIELDS = {" + for field in fields: + comments = [] + if field.required: + comments.append('required') + if field.orig.has_default_value: + comments.append("default=%s" % repr(field.orig.default_value)) + + if comments: + comment = " # %s" % ' '.join(comments) + else: + comment = '' + + if field.repeated: + flags = 'p.FLAG_REPEATED' + else: + flags = '0' + + yield " %d: ('%s', %s, %s),%s" % (field.number, field.name, field.proto_type, flags, comment) + + yield " }" + yield "" + yield from create_init_method(fields) + + if not fields and not msg_id: + yield " pass" def process_enum(descriptor, is_upy): logging.debug("Processing enum %s", descriptor.name) - if is_upy: - yield "from micropython import const" - yield "" - for name, value in descriptor.values_by_name.items(): # Remove type name from the beginning of the constant # For example "PinMatrixRequestType_Current" -> "Current" @@ -131,10 +161,10 @@ def process_enum(descriptor, is_upy): enum_prefix, _ = enum_prefix.rsplit("Type", 1) name = remove_from_start(name, "%s_" % enum_prefix) - yield create_const(name, value.number, is_upy) + yield "%s = %s" % (name, value.number) -def process_file(descriptor, protobuf_module, genpath, indexfile, modlist, is_upy): +def process_file(descriptor, protobuf_module, genpath, modlist, is_upy): logging.info("Processing module %s", descriptor.name) msg_types = import_pb2('messages').MessageType @@ -146,7 +176,7 @@ def process_file(descriptor, protobuf_module, genpath, indexfile, modlist, is_up except ValueError: msg_id = None - out = process_message(message_descriptor, protobuf_module, msg_id, indexfile, is_upy) + out = process_message(message_descriptor, protobuf_module, msg_id, is_upy) write_to_file(genpath, name, out) if modlist: modlist.write(create_message_import(name) + "\n") @@ -173,7 +203,6 @@ if __name__ == '__main__': parser.add_argument('module', help="Name of module to generate") parser.add_argument('genpath', help="Directory for generated source code") parser.add_argument('-P', '--protobuf-module', default="protobuf", help="Name of protobuf module") - parser.add_argument('-i', '--indexfile', type=argparse.FileType('a'), help="Generate index file of wire types") parser.add_argument('-l', '--modlist', type=argparse.FileType('a'), help="Generate list of modules") parser.add_argument('-p', '--protopath', type=str, help="Path to search for pregenerated Google's python sources") parser.add_argument('-m', '--micropython', action='store_true', help="Use micropython-favoured source code") @@ -185,4 +214,4 @@ if __name__ == '__main__': # This must be done after sys.path.append module = import_pb2(args.module) - process_file(module.DESCRIPTOR, args.protobuf_module, args.genpath, args.indexfile, args.modlist, args.micropython) + process_file(module.DESCRIPTOR, args.protobuf_module, args.genpath, args.modlist, args.micropython) diff --git a/trezorlib/messages/Address.py b/trezorlib/messages/Address.py index 506935c11..fd4edab80 100644 --- a/trezorlib/messages/Address.py +++ b/trezorlib/messages/Address.py @@ -3,7 +3,13 @@ from .. import protobuf as p class Address(p.MessageType): + MESSAGE_WIRE_TYPE = 30 FIELDS = { 1: ('address', p.UnicodeType, 0), # required } - MESSAGE_WIRE_TYPE = 30 + + def __init__( + self, + address: str = None + ) -> None: + self.address = address diff --git a/trezorlib/messages/ApplyFlags.py b/trezorlib/messages/ApplyFlags.py index f4163862b..9240dd9bf 100644 --- a/trezorlib/messages/ApplyFlags.py +++ b/trezorlib/messages/ApplyFlags.py @@ -3,7 +3,13 @@ from .. import protobuf as p class ApplyFlags(p.MessageType): + MESSAGE_WIRE_TYPE = 28 FIELDS = { 1: ('flags', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 28 + + def __init__( + self, + flags: int = None + ) -> None: + self.flags = flags diff --git a/trezorlib/messages/ApplySettings.py b/trezorlib/messages/ApplySettings.py index fbb776e6a..f269acd18 100644 --- a/trezorlib/messages/ApplySettings.py +++ b/trezorlib/messages/ApplySettings.py @@ -3,6 +3,7 @@ from .. import protobuf as p class ApplySettings(p.MessageType): + MESSAGE_WIRE_TYPE = 25 FIELDS = { 1: ('language', p.UnicodeType, 0), 2: ('label', p.UnicodeType, 0), @@ -11,4 +12,19 @@ class ApplySettings(p.MessageType): 5: ('passphrase_source', p.UVarintType, 0), 6: ('auto_lock_delay_ms', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 25 + + def __init__( + self, + language: str = None, + label: str = None, + use_passphrase: bool = None, + homescreen: bytes = None, + passphrase_source: int = None, + auto_lock_delay_ms: int = None + ) -> None: + self.language = language + self.label = label + self.use_passphrase = use_passphrase + self.homescreen = homescreen + self.passphrase_source = passphrase_source + self.auto_lock_delay_ms = auto_lock_delay_ms diff --git a/trezorlib/messages/ButtonRequest.py b/trezorlib/messages/ButtonRequest.py index 56cbca251..ea57764cc 100644 --- a/trezorlib/messages/ButtonRequest.py +++ b/trezorlib/messages/ButtonRequest.py @@ -3,8 +3,16 @@ from .. import protobuf as p class ButtonRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 26 FIELDS = { 1: ('code', p.UVarintType, 0), 2: ('data', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 26 + + def __init__( + self, + code: int = None, + data: str = None + ) -> None: + self.code = code + self.data = data diff --git a/trezorlib/messages/ChangePin.py b/trezorlib/messages/ChangePin.py index 217a84a73..9f7b19547 100644 --- a/trezorlib/messages/ChangePin.py +++ b/trezorlib/messages/ChangePin.py @@ -3,7 +3,13 @@ from .. import protobuf as p class ChangePin(p.MessageType): + MESSAGE_WIRE_TYPE = 4 FIELDS = { 1: ('remove', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 4 + + def __init__( + self, + remove: bool = None + ) -> None: + self.remove = remove diff --git a/trezorlib/messages/CipherKeyValue.py b/trezorlib/messages/CipherKeyValue.py index 2673b5be0..f76d81665 100644 --- a/trezorlib/messages/CipherKeyValue.py +++ b/trezorlib/messages/CipherKeyValue.py @@ -1,8 +1,14 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class CipherKeyValue(p.MessageType): + MESSAGE_WIRE_TYPE = 23 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('key', p.UnicodeType, 0), @@ -12,4 +18,21 @@ class CipherKeyValue(p.MessageType): 6: ('ask_on_decrypt', p.BoolType, 0), 7: ('iv', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 23 + + def __init__( + self, + address_n: List[int] = None, + key: str = None, + value: bytes = None, + encrypt: bool = None, + ask_on_encrypt: bool = None, + ask_on_decrypt: bool = None, + iv: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.key = key + self.value = value + self.encrypt = encrypt + self.ask_on_encrypt = ask_on_encrypt + self.ask_on_decrypt = ask_on_decrypt + self.iv = iv diff --git a/trezorlib/messages/CipheredKeyValue.py b/trezorlib/messages/CipheredKeyValue.py index 3db46014e..d1abf63f6 100644 --- a/trezorlib/messages/CipheredKeyValue.py +++ b/trezorlib/messages/CipheredKeyValue.py @@ -3,7 +3,13 @@ from .. import protobuf as p class CipheredKeyValue(p.MessageType): + MESSAGE_WIRE_TYPE = 48 FIELDS = { 1: ('value', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 48 + + def __init__( + self, + value: bytes = None + ) -> None: + self.value = value diff --git a/trezorlib/messages/CoinType.py b/trezorlib/messages/CoinType.py index 7fcd9aaf1..e106d4d4f 100644 --- a/trezorlib/messages/CoinType.py +++ b/trezorlib/messages/CoinType.py @@ -16,3 +16,29 @@ class CoinType(p.MessageType): 12: ('forkid', p.UVarintType, 0), 13: ('force_bip143', p.BoolType, 0), } + + def __init__( + self, + coin_name: str = None, + coin_shortcut: str = None, + address_type: int = None, + maxfee_kb: int = None, + address_type_p2sh: int = None, + signed_message_header: str = None, + xpub_magic: int = None, + xprv_magic: int = None, + segwit: bool = None, + forkid: int = None, + force_bip143: bool = None + ) -> None: + self.coin_name = coin_name + self.coin_shortcut = coin_shortcut + self.address_type = address_type + self.maxfee_kb = maxfee_kb + self.address_type_p2sh = address_type_p2sh + self.signed_message_header = signed_message_header + self.xpub_magic = xpub_magic + self.xprv_magic = xprv_magic + self.segwit = segwit + self.forkid = forkid + self.force_bip143 = force_bip143 diff --git a/trezorlib/messages/CosiCommit.py b/trezorlib/messages/CosiCommit.py index ac8b318aa..96e3839ab 100644 --- a/trezorlib/messages/CosiCommit.py +++ b/trezorlib/messages/CosiCommit.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class CosiCommit(p.MessageType): + MESSAGE_WIRE_TYPE = 71 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('data', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 71 + + def __init__( + self, + address_n: List[int] = None, + data: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.data = data diff --git a/trezorlib/messages/CosiCommitment.py b/trezorlib/messages/CosiCommitment.py index 652319f13..d87fa529e 100644 --- a/trezorlib/messages/CosiCommitment.py +++ b/trezorlib/messages/CosiCommitment.py @@ -3,8 +3,16 @@ from .. import protobuf as p class CosiCommitment(p.MessageType): + MESSAGE_WIRE_TYPE = 72 FIELDS = { 1: ('commitment', p.BytesType, 0), 2: ('pubkey', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 72 + + def __init__( + self, + commitment: bytes = None, + pubkey: bytes = None + ) -> None: + self.commitment = commitment + self.pubkey = pubkey diff --git a/trezorlib/messages/CosiSign.py b/trezorlib/messages/CosiSign.py index 78a6996b5..5db336de3 100644 --- a/trezorlib/messages/CosiSign.py +++ b/trezorlib/messages/CosiSign.py @@ -1,12 +1,29 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class CosiSign(p.MessageType): + MESSAGE_WIRE_TYPE = 73 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('data', p.BytesType, 0), 3: ('global_commitment', p.BytesType, 0), 4: ('global_pubkey', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 73 + + def __init__( + self, + address_n: List[int] = None, + data: bytes = None, + global_commitment: bytes = None, + global_pubkey: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.data = data + self.global_commitment = global_commitment + self.global_pubkey = global_pubkey diff --git a/trezorlib/messages/CosiSignature.py b/trezorlib/messages/CosiSignature.py index 371616522..e2a585a19 100644 --- a/trezorlib/messages/CosiSignature.py +++ b/trezorlib/messages/CosiSignature.py @@ -3,7 +3,13 @@ from .. import protobuf as p class CosiSignature(p.MessageType): + MESSAGE_WIRE_TYPE = 74 FIELDS = { 1: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 74 + + def __init__( + self, + signature: bytes = None + ) -> None: + self.signature = signature diff --git a/trezorlib/messages/DebugLinkDecision.py b/trezorlib/messages/DebugLinkDecision.py index e5016f304..de262c0a6 100644 --- a/trezorlib/messages/DebugLinkDecision.py +++ b/trezorlib/messages/DebugLinkDecision.py @@ -3,9 +3,19 @@ from .. import protobuf as p class DebugLinkDecision(p.MessageType): + MESSAGE_WIRE_TYPE = 100 FIELDS = { 1: ('yes_no', p.BoolType, 0), 2: ('up_down', p.BoolType, 0), 3: ('input', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 100 + + def __init__( + self, + yes_no: bool = None, + up_down: bool = None, + input: str = None + ) -> None: + self.yes_no = yes_no + self.up_down = up_down + self.input = input diff --git a/trezorlib/messages/DebugLinkFlashErase.py b/trezorlib/messages/DebugLinkFlashErase.py index 405443a01..21d48c8c6 100644 --- a/trezorlib/messages/DebugLinkFlashErase.py +++ b/trezorlib/messages/DebugLinkFlashErase.py @@ -3,7 +3,13 @@ from .. import protobuf as p class DebugLinkFlashErase(p.MessageType): + MESSAGE_WIRE_TYPE = 113 FIELDS = { 1: ('sector', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 113 + + def __init__( + self, + sector: int = None + ) -> None: + self.sector = sector diff --git a/trezorlib/messages/DebugLinkLog.py b/trezorlib/messages/DebugLinkLog.py index 5ab46fa19..da6435bfc 100644 --- a/trezorlib/messages/DebugLinkLog.py +++ b/trezorlib/messages/DebugLinkLog.py @@ -3,9 +3,19 @@ from .. import protobuf as p class DebugLinkLog(p.MessageType): + MESSAGE_WIRE_TYPE = 104 FIELDS = { 1: ('level', p.UVarintType, 0), 2: ('bucket', p.UnicodeType, 0), 3: ('text', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 104 + + def __init__( + self, + level: int = None, + bucket: str = None, + text: str = None + ) -> None: + self.level = level + self.bucket = bucket + self.text = text diff --git a/trezorlib/messages/DebugLinkMemory.py b/trezorlib/messages/DebugLinkMemory.py index 5ef79e57f..9f6ae8b9f 100644 --- a/trezorlib/messages/DebugLinkMemory.py +++ b/trezorlib/messages/DebugLinkMemory.py @@ -3,7 +3,13 @@ from .. import protobuf as p class DebugLinkMemory(p.MessageType): + MESSAGE_WIRE_TYPE = 111 FIELDS = { 1: ('memory', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 111 + + def __init__( + self, + memory: bytes = None + ) -> None: + self.memory = memory diff --git a/trezorlib/messages/DebugLinkMemoryRead.py b/trezorlib/messages/DebugLinkMemoryRead.py index b2ebb2574..57fc4a037 100644 --- a/trezorlib/messages/DebugLinkMemoryRead.py +++ b/trezorlib/messages/DebugLinkMemoryRead.py @@ -3,8 +3,16 @@ from .. import protobuf as p class DebugLinkMemoryRead(p.MessageType): + MESSAGE_WIRE_TYPE = 110 FIELDS = { 1: ('address', p.UVarintType, 0), 2: ('length', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 110 + + def __init__( + self, + address: int = None, + length: int = None + ) -> None: + self.address = address + self.length = length diff --git a/trezorlib/messages/DebugLinkMemoryWrite.py b/trezorlib/messages/DebugLinkMemoryWrite.py index 3b7265267..456bac235 100644 --- a/trezorlib/messages/DebugLinkMemoryWrite.py +++ b/trezorlib/messages/DebugLinkMemoryWrite.py @@ -3,9 +3,19 @@ from .. import protobuf as p class DebugLinkMemoryWrite(p.MessageType): + MESSAGE_WIRE_TYPE = 112 FIELDS = { 1: ('address', p.UVarintType, 0), 2: ('memory', p.BytesType, 0), 3: ('flash', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 112 + + def __init__( + self, + address: int = None, + memory: bytes = None, + flash: bool = None + ) -> None: + self.address = address + self.memory = memory + self.flash = flash diff --git a/trezorlib/messages/DebugLinkState.py b/trezorlib/messages/DebugLinkState.py index ef671619e..9b8ce3810 100644 --- a/trezorlib/messages/DebugLinkState.py +++ b/trezorlib/messages/DebugLinkState.py @@ -4,6 +4,7 @@ from .HDNodeType import HDNodeType class DebugLinkState(p.MessageType): + MESSAGE_WIRE_TYPE = 102 FIELDS = { 1: ('layout', p.BytesType, 0), 2: ('pin', p.UnicodeType, 0), @@ -17,4 +18,29 @@ class DebugLinkState(p.MessageType): 10: ('recovery_word_pos', p.UVarintType, 0), 11: ('reset_word_pos', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 102 + + def __init__( + self, + layout: bytes = None, + pin: str = None, + matrix: str = None, + mnemonic: str = None, + node: HDNodeType = None, + passphrase_protection: bool = None, + reset_word: str = None, + reset_entropy: bytes = None, + recovery_fake_word: str = None, + recovery_word_pos: int = None, + reset_word_pos: int = None + ) -> None: + self.layout = layout + self.pin = pin + self.matrix = matrix + self.mnemonic = mnemonic + self.node = node + self.passphrase_protection = passphrase_protection + self.reset_word = reset_word + self.reset_entropy = reset_entropy + self.recovery_fake_word = recovery_fake_word + self.recovery_word_pos = recovery_word_pos + self.reset_word_pos = reset_word_pos diff --git a/trezorlib/messages/DecryptMessage.py b/trezorlib/messages/DecryptMessage.py index f37d679a0..5d72b25d1 100644 --- a/trezorlib/messages/DecryptMessage.py +++ b/trezorlib/messages/DecryptMessage.py @@ -1,12 +1,29 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class DecryptMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 51 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('nonce', p.BytesType, 0), 3: ('message', p.BytesType, 0), 4: ('hmac', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 51 + + def __init__( + self, + address_n: List[int] = None, + nonce: bytes = None, + message: bytes = None, + hmac: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.nonce = nonce + self.message = message + self.hmac = hmac diff --git a/trezorlib/messages/DecryptedMessage.py b/trezorlib/messages/DecryptedMessage.py index d8917295c..f62386da2 100644 --- a/trezorlib/messages/DecryptedMessage.py +++ b/trezorlib/messages/DecryptedMessage.py @@ -3,8 +3,16 @@ from .. import protobuf as p class DecryptedMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 52 FIELDS = { 1: ('message', p.BytesType, 0), 2: ('address', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 52 + + def __init__( + self, + message: bytes = None, + address: str = None + ) -> None: + self.message = message + self.address = address diff --git a/trezorlib/messages/ECDHSessionKey.py b/trezorlib/messages/ECDHSessionKey.py index aa8cc8272..79c41e020 100644 --- a/trezorlib/messages/ECDHSessionKey.py +++ b/trezorlib/messages/ECDHSessionKey.py @@ -3,7 +3,13 @@ from .. import protobuf as p class ECDHSessionKey(p.MessageType): + MESSAGE_WIRE_TYPE = 62 FIELDS = { 1: ('session_key', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 62 + + def __init__( + self, + session_key: bytes = None + ) -> None: + self.session_key = session_key diff --git a/trezorlib/messages/EncryptMessage.py b/trezorlib/messages/EncryptMessage.py index 1be5c963b..e96e54b27 100644 --- a/trezorlib/messages/EncryptMessage.py +++ b/trezorlib/messages/EncryptMessage.py @@ -1,8 +1,14 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class EncryptMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 49 FIELDS = { 1: ('pubkey', p.BytesType, 0), 2: ('message', p.BytesType, 0), @@ -10,4 +16,17 @@ class EncryptMessage(p.MessageType): 4: ('address_n', p.UVarintType, p.FLAG_REPEATED), 5: ('coin_name', p.UnicodeType, 0), # default='Bitcoin' } - MESSAGE_WIRE_TYPE = 49 + + def __init__( + self, + pubkey: bytes = None, + message: bytes = None, + display_only: bool = None, + address_n: List[int] = None, + coin_name: str = None + ) -> None: + self.pubkey = pubkey + self.message = message + self.display_only = display_only + self.address_n = address_n if address_n is not None else [] + self.coin_name = coin_name diff --git a/trezorlib/messages/EncryptedMessage.py b/trezorlib/messages/EncryptedMessage.py index 131a35637..d52d3c953 100644 --- a/trezorlib/messages/EncryptedMessage.py +++ b/trezorlib/messages/EncryptedMessage.py @@ -3,9 +3,19 @@ from .. import protobuf as p class EncryptedMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 50 FIELDS = { 1: ('nonce', p.BytesType, 0), 2: ('message', p.BytesType, 0), 3: ('hmac', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 50 + + def __init__( + self, + nonce: bytes = None, + message: bytes = None, + hmac: bytes = None + ) -> None: + self.nonce = nonce + self.message = message + self.hmac = hmac diff --git a/trezorlib/messages/Entropy.py b/trezorlib/messages/Entropy.py index 0a828f952..bdc314c90 100644 --- a/trezorlib/messages/Entropy.py +++ b/trezorlib/messages/Entropy.py @@ -3,7 +3,13 @@ from .. import protobuf as p class Entropy(p.MessageType): + MESSAGE_WIRE_TYPE = 10 FIELDS = { 1: ('entropy', p.BytesType, 0), # required } - MESSAGE_WIRE_TYPE = 10 + + def __init__( + self, + entropy: bytes = None + ) -> None: + self.entropy = entropy diff --git a/trezorlib/messages/EntropyAck.py b/trezorlib/messages/EntropyAck.py index 2050865c7..19afa8e15 100644 --- a/trezorlib/messages/EntropyAck.py +++ b/trezorlib/messages/EntropyAck.py @@ -3,7 +3,13 @@ from .. import protobuf as p class EntropyAck(p.MessageType): + MESSAGE_WIRE_TYPE = 36 FIELDS = { 1: ('entropy', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 36 + + def __init__( + self, + entropy: bytes = None + ) -> None: + self.entropy = entropy diff --git a/trezorlib/messages/EstimateTxSize.py b/trezorlib/messages/EstimateTxSize.py index 889ca9f23..34e2ec125 100644 --- a/trezorlib/messages/EstimateTxSize.py +++ b/trezorlib/messages/EstimateTxSize.py @@ -3,9 +3,19 @@ from .. import protobuf as p class EstimateTxSize(p.MessageType): + MESSAGE_WIRE_TYPE = 43 FIELDS = { 1: ('outputs_count', p.UVarintType, 0), # required 2: ('inputs_count', p.UVarintType, 0), # required 3: ('coin_name', p.UnicodeType, 0), # default='Bitcoin' } - MESSAGE_WIRE_TYPE = 43 + + def __init__( + self, + outputs_count: int = None, + inputs_count: int = None, + coin_name: str = None + ) -> None: + self.outputs_count = outputs_count + self.inputs_count = inputs_count + self.coin_name = coin_name diff --git a/trezorlib/messages/EthereumAddress.py b/trezorlib/messages/EthereumAddress.py index 1a1e9962a..1363aa5ba 100644 --- a/trezorlib/messages/EthereumAddress.py +++ b/trezorlib/messages/EthereumAddress.py @@ -3,7 +3,13 @@ from .. import protobuf as p class EthereumAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 57 FIELDS = { 1: ('address', p.BytesType, 0), # required } - MESSAGE_WIRE_TYPE = 57 + + def __init__( + self, + address: bytes = None + ) -> None: + self.address = address diff --git a/trezorlib/messages/EthereumGetAddress.py b/trezorlib/messages/EthereumGetAddress.py index 99a655191..14e9c3b5d 100644 --- a/trezorlib/messages/EthereumGetAddress.py +++ b/trezorlib/messages/EthereumGetAddress.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class EthereumGetAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 56 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('show_display', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 56 + + def __init__( + self, + address_n: List[int] = None, + show_display: bool = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.show_display = show_display diff --git a/trezorlib/messages/EthereumMessageSignature.py b/trezorlib/messages/EthereumMessageSignature.py index ff0923865..31ebe1e14 100644 --- a/trezorlib/messages/EthereumMessageSignature.py +++ b/trezorlib/messages/EthereumMessageSignature.py @@ -3,8 +3,16 @@ from .. import protobuf as p class EthereumMessageSignature(p.MessageType): + MESSAGE_WIRE_TYPE = 66 FIELDS = { 1: ('address', p.BytesType, 0), 2: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 66 + + def __init__( + self, + address: bytes = None, + signature: bytes = None + ) -> None: + self.address = address + self.signature = signature diff --git a/trezorlib/messages/EthereumSignMessage.py b/trezorlib/messages/EthereumSignMessage.py index 09dfbe8a9..cda682cd9 100644 --- a/trezorlib/messages/EthereumSignMessage.py +++ b/trezorlib/messages/EthereumSignMessage.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class EthereumSignMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 64 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('message', p.BytesType, 0), # required } - MESSAGE_WIRE_TYPE = 64 + + def __init__( + self, + address_n: List[int] = None, + message: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.message = message diff --git a/trezorlib/messages/EthereumSignTx.py b/trezorlib/messages/EthereumSignTx.py index 92426c41c..c16cff198 100644 --- a/trezorlib/messages/EthereumSignTx.py +++ b/trezorlib/messages/EthereumSignTx.py @@ -1,8 +1,14 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class EthereumSignTx(p.MessageType): + MESSAGE_WIRE_TYPE = 58 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('nonce', p.BytesType, 0), @@ -15,4 +21,27 @@ class EthereumSignTx(p.MessageType): 9: ('chain_id', p.UVarintType, 0), 10: ('tx_type', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 58 + + def __init__( + self, + address_n: List[int] = None, + nonce: bytes = None, + gas_price: bytes = None, + gas_limit: bytes = None, + to: bytes = None, + value: bytes = None, + data_initial_chunk: bytes = None, + data_length: int = None, + chain_id: int = None, + tx_type: int = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.nonce = nonce + self.gas_price = gas_price + self.gas_limit = gas_limit + self.to = to + self.value = value + self.data_initial_chunk = data_initial_chunk + self.data_length = data_length + self.chain_id = chain_id + self.tx_type = tx_type diff --git a/trezorlib/messages/EthereumTxAck.py b/trezorlib/messages/EthereumTxAck.py index 9a6b62d86..4ab80993e 100644 --- a/trezorlib/messages/EthereumTxAck.py +++ b/trezorlib/messages/EthereumTxAck.py @@ -3,7 +3,13 @@ from .. import protobuf as p class EthereumTxAck(p.MessageType): + MESSAGE_WIRE_TYPE = 60 FIELDS = { 1: ('data_chunk', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 60 + + def __init__( + self, + data_chunk: bytes = None + ) -> None: + self.data_chunk = data_chunk diff --git a/trezorlib/messages/EthereumTxRequest.py b/trezorlib/messages/EthereumTxRequest.py index e4c59cfe4..39d5a8c94 100644 --- a/trezorlib/messages/EthereumTxRequest.py +++ b/trezorlib/messages/EthereumTxRequest.py @@ -3,10 +3,22 @@ from .. import protobuf as p class EthereumTxRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 59 FIELDS = { 1: ('data_length', p.UVarintType, 0), 2: ('signature_v', p.UVarintType, 0), 3: ('signature_r', p.BytesType, 0), 4: ('signature_s', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 59 + + def __init__( + self, + data_length: int = None, + signature_v: int = None, + signature_r: bytes = None, + signature_s: bytes = None + ) -> None: + self.data_length = data_length + self.signature_v = signature_v + self.signature_r = signature_r + self.signature_s = signature_s diff --git a/trezorlib/messages/EthereumVerifyMessage.py b/trezorlib/messages/EthereumVerifyMessage.py index 25481338f..07b62be76 100644 --- a/trezorlib/messages/EthereumVerifyMessage.py +++ b/trezorlib/messages/EthereumVerifyMessage.py @@ -3,9 +3,19 @@ from .. import protobuf as p class EthereumVerifyMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 65 FIELDS = { 1: ('address', p.BytesType, 0), 2: ('signature', p.BytesType, 0), 3: ('message', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 65 + + def __init__( + self, + address: bytes = None, + signature: bytes = None, + message: bytes = None + ) -> None: + self.address = address + self.signature = signature + self.message = message diff --git a/trezorlib/messages/Failure.py b/trezorlib/messages/Failure.py index 9a752029a..a3a6b4662 100644 --- a/trezorlib/messages/Failure.py +++ b/trezorlib/messages/Failure.py @@ -3,8 +3,16 @@ from .. import protobuf as p class Failure(p.MessageType): + MESSAGE_WIRE_TYPE = 3 FIELDS = { 1: ('code', p.UVarintType, 0), 2: ('message', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 3 + + def __init__( + self, + code: int = None, + message: str = None + ) -> None: + self.code = code + self.message = message diff --git a/trezorlib/messages/Features.py b/trezorlib/messages/Features.py index d1eaaa39a..f63de42fe 100644 --- a/trezorlib/messages/Features.py +++ b/trezorlib/messages/Features.py @@ -1,9 +1,15 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .CoinType import CoinType class Features(p.MessageType): + MESSAGE_WIRE_TYPE = 17 FIELDS = { 1: ('vendor', p.UnicodeType, 0), 2: ('major_version', p.UVarintType, 0), @@ -33,4 +39,61 @@ class Features(p.MessageType): 26: ('fw_vendor_keys', p.BytesType, 0), 27: ('unfinished_backup', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 17 + + def __init__( + self, + vendor: str = None, + major_version: int = None, + minor_version: int = None, + patch_version: int = None, + bootloader_mode: bool = None, + device_id: str = None, + pin_protection: bool = None, + passphrase_protection: bool = None, + language: str = None, + label: str = None, + coins: List[CoinType] = None, + initialized: bool = None, + revision: bytes = None, + bootloader_hash: bytes = None, + imported: bool = None, + pin_cached: bool = None, + passphrase_cached: bool = None, + firmware_present: bool = None, + needs_backup: bool = None, + flags: int = None, + model: str = None, + fw_major: int = None, + fw_minor: int = None, + fw_patch: int = None, + fw_vendor: str = None, + fw_vendor_keys: bytes = None, + unfinished_backup: bool = None + ) -> None: + self.vendor = vendor + self.major_version = major_version + self.minor_version = minor_version + self.patch_version = patch_version + self.bootloader_mode = bootloader_mode + self.device_id = device_id + self.pin_protection = pin_protection + self.passphrase_protection = passphrase_protection + self.language = language + self.label = label + self.coins = coins if coins is not None else [] + self.initialized = initialized + self.revision = revision + self.bootloader_hash = bootloader_hash + self.imported = imported + self.pin_cached = pin_cached + self.passphrase_cached = passphrase_cached + self.firmware_present = firmware_present + self.needs_backup = needs_backup + self.flags = flags + self.model = model + self.fw_major = fw_major + self.fw_minor = fw_minor + self.fw_patch = fw_patch + self.fw_vendor = fw_vendor + self.fw_vendor_keys = fw_vendor_keys + self.unfinished_backup = unfinished_backup diff --git a/trezorlib/messages/FirmwareErase.py b/trezorlib/messages/FirmwareErase.py index 7971b7583..a59e24482 100644 --- a/trezorlib/messages/FirmwareErase.py +++ b/trezorlib/messages/FirmwareErase.py @@ -3,7 +3,13 @@ from .. import protobuf as p class FirmwareErase(p.MessageType): + MESSAGE_WIRE_TYPE = 6 FIELDS = { 1: ('length', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 6 + + def __init__( + self, + length: int = None + ) -> None: + self.length = length diff --git a/trezorlib/messages/FirmwareRequest.py b/trezorlib/messages/FirmwareRequest.py index cb766771b..8d0319ebf 100644 --- a/trezorlib/messages/FirmwareRequest.py +++ b/trezorlib/messages/FirmwareRequest.py @@ -3,8 +3,16 @@ from .. import protobuf as p class FirmwareRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 8 FIELDS = { 1: ('offset', p.UVarintType, 0), 2: ('length', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 8 + + def __init__( + self, + offset: int = None, + length: int = None + ) -> None: + self.offset = offset + self.length = length diff --git a/trezorlib/messages/FirmwareUpload.py b/trezorlib/messages/FirmwareUpload.py index 3c726a76b..287f8b7de 100644 --- a/trezorlib/messages/FirmwareUpload.py +++ b/trezorlib/messages/FirmwareUpload.py @@ -3,8 +3,16 @@ from .. import protobuf as p class FirmwareUpload(p.MessageType): + MESSAGE_WIRE_TYPE = 7 FIELDS = { 1: ('payload', p.BytesType, 0), # required 2: ('hash', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 7 + + def __init__( + self, + payload: bytes = None, + hash: bytes = None + ) -> None: + self.payload = payload + self.hash = hash diff --git a/trezorlib/messages/GetAddress.py b/trezorlib/messages/GetAddress.py index a0dd174fa..997544e5f 100644 --- a/trezorlib/messages/GetAddress.py +++ b/trezorlib/messages/GetAddress.py @@ -1,9 +1,15 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .MultisigRedeemScriptType import MultisigRedeemScriptType class GetAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 29 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('coin_name', p.UnicodeType, 0), # default='Bitcoin' @@ -11,4 +17,17 @@ class GetAddress(p.MessageType): 4: ('multisig', MultisigRedeemScriptType, 0), 5: ('script_type', p.UVarintType, 0), # default=0 } - MESSAGE_WIRE_TYPE = 29 + + def __init__( + self, + address_n: List[int] = None, + coin_name: str = None, + show_display: bool = None, + multisig: MultisigRedeemScriptType = None, + script_type: int = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.coin_name = coin_name + self.show_display = show_display + self.multisig = multisig + self.script_type = script_type diff --git a/trezorlib/messages/GetECDHSessionKey.py b/trezorlib/messages/GetECDHSessionKey.py index e9f943997..53835f00c 100644 --- a/trezorlib/messages/GetECDHSessionKey.py +++ b/trezorlib/messages/GetECDHSessionKey.py @@ -4,9 +4,19 @@ from .IdentityType import IdentityType class GetECDHSessionKey(p.MessageType): + MESSAGE_WIRE_TYPE = 61 FIELDS = { 1: ('identity', IdentityType, 0), 2: ('peer_public_key', p.BytesType, 0), 3: ('ecdsa_curve_name', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 61 + + def __init__( + self, + identity: IdentityType = None, + peer_public_key: bytes = None, + ecdsa_curve_name: str = None + ) -> None: + self.identity = identity + self.peer_public_key = peer_public_key + self.ecdsa_curve_name = ecdsa_curve_name diff --git a/trezorlib/messages/GetEntropy.py b/trezorlib/messages/GetEntropy.py index e16043b69..1606bbfc7 100644 --- a/trezorlib/messages/GetEntropy.py +++ b/trezorlib/messages/GetEntropy.py @@ -3,7 +3,13 @@ from .. import protobuf as p class GetEntropy(p.MessageType): + MESSAGE_WIRE_TYPE = 9 FIELDS = { 1: ('size', p.UVarintType, 0), # required } - MESSAGE_WIRE_TYPE = 9 + + def __init__( + self, + size: int = None + ) -> None: + self.size = size diff --git a/trezorlib/messages/GetPublicKey.py b/trezorlib/messages/GetPublicKey.py index b89881aa5..40af6facc 100644 --- a/trezorlib/messages/GetPublicKey.py +++ b/trezorlib/messages/GetPublicKey.py @@ -1,12 +1,29 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class GetPublicKey(p.MessageType): + MESSAGE_WIRE_TYPE = 11 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('ecdsa_curve_name', p.UnicodeType, 0), 3: ('show_display', p.BoolType, 0), 4: ('coin_name', p.UnicodeType, 0), # default='Bitcoin' } - MESSAGE_WIRE_TYPE = 11 + + def __init__( + self, + address_n: List[int] = None, + ecdsa_curve_name: str = None, + show_display: bool = None, + coin_name: str = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.ecdsa_curve_name = ecdsa_curve_name + self.show_display = show_display + self.coin_name = coin_name diff --git a/trezorlib/messages/HDNodePathType.py b/trezorlib/messages/HDNodePathType.py index 720d41c3d..54a45e535 100644 --- a/trezorlib/messages/HDNodePathType.py +++ b/trezorlib/messages/HDNodePathType.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .HDNodeType import HDNodeType @@ -8,3 +13,11 @@ class HDNodePathType(p.MessageType): 1: ('node', HDNodeType, 0), # required 2: ('address_n', p.UVarintType, p.FLAG_REPEATED), } + + def __init__( + self, + node: HDNodeType = None, + address_n: List[int] = None + ) -> None: + self.node = node + self.address_n = address_n if address_n is not None else [] diff --git a/trezorlib/messages/HDNodeType.py b/trezorlib/messages/HDNodeType.py index 5bd2ed08b..082dd7f32 100644 --- a/trezorlib/messages/HDNodeType.py +++ b/trezorlib/messages/HDNodeType.py @@ -11,3 +11,19 @@ class HDNodeType(p.MessageType): 5: ('private_key', p.BytesType, 0), 6: ('public_key', p.BytesType, 0), } + + def __init__( + self, + depth: int = None, + fingerprint: int = None, + child_num: int = None, + chain_code: bytes = None, + private_key: bytes = None, + public_key: bytes = None + ) -> None: + self.depth = depth + self.fingerprint = fingerprint + self.child_num = child_num + self.chain_code = chain_code + self.private_key = private_key + self.public_key = public_key diff --git a/trezorlib/messages/IdentityType.py b/trezorlib/messages/IdentityType.py index e571d603b..93c4fcf41 100644 --- a/trezorlib/messages/IdentityType.py +++ b/trezorlib/messages/IdentityType.py @@ -11,3 +11,19 @@ class IdentityType(p.MessageType): 5: ('path', p.UnicodeType, 0), 6: ('index', p.UVarintType, 0), # default=0 } + + def __init__( + self, + proto: str = None, + user: str = None, + host: str = None, + port: str = None, + path: str = None, + index: int = None + ) -> None: + self.proto = proto + self.user = user + self.host = host + self.port = port + self.path = path + self.index = index diff --git a/trezorlib/messages/Initialize.py b/trezorlib/messages/Initialize.py index 7c816093a..38e35ec73 100644 --- a/trezorlib/messages/Initialize.py +++ b/trezorlib/messages/Initialize.py @@ -3,7 +3,13 @@ from .. import protobuf as p class Initialize(p.MessageType): + MESSAGE_WIRE_TYPE = 0 FIELDS = { 1: ('state', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 0 + + def __init__( + self, + state: bytes = None + ) -> None: + self.state = state diff --git a/trezorlib/messages/LiskAddress.py b/trezorlib/messages/LiskAddress.py index a565239fe..d071c950f 100644 --- a/trezorlib/messages/LiskAddress.py +++ b/trezorlib/messages/LiskAddress.py @@ -3,7 +3,13 @@ from .. import protobuf as p class LiskAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 115 FIELDS = { 1: ('address', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 115 + + def __init__( + self, + address: str = None + ) -> None: + self.address = address diff --git a/trezorlib/messages/LiskDelegateType.py b/trezorlib/messages/LiskDelegateType.py index 4afce0a22..741727b42 100644 --- a/trezorlib/messages/LiskDelegateType.py +++ b/trezorlib/messages/LiskDelegateType.py @@ -6,3 +6,9 @@ class LiskDelegateType(p.MessageType): FIELDS = { 1: ('username', p.UnicodeType, 0), } + + def __init__( + self, + username: str = None + ) -> None: + self.username = username diff --git a/trezorlib/messages/LiskGetAddress.py b/trezorlib/messages/LiskGetAddress.py index e9d0b3fe5..35078057b 100644 --- a/trezorlib/messages/LiskGetAddress.py +++ b/trezorlib/messages/LiskGetAddress.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class LiskGetAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 114 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('show_display', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 114 + + def __init__( + self, + address_n: List[int] = None, + show_display: bool = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.show_display = show_display diff --git a/trezorlib/messages/LiskGetPublicKey.py b/trezorlib/messages/LiskGetPublicKey.py index bb6e30f91..8cd355c03 100644 --- a/trezorlib/messages/LiskGetPublicKey.py +++ b/trezorlib/messages/LiskGetPublicKey.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class LiskGetPublicKey(p.MessageType): + MESSAGE_WIRE_TYPE = 121 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('show_display', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 121 + + def __init__( + self, + address_n: List[int] = None, + show_display: bool = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.show_display = show_display diff --git a/trezorlib/messages/LiskMessageSignature.py b/trezorlib/messages/LiskMessageSignature.py index 46e7fc610..b16145838 100644 --- a/trezorlib/messages/LiskMessageSignature.py +++ b/trezorlib/messages/LiskMessageSignature.py @@ -3,8 +3,16 @@ from .. import protobuf as p class LiskMessageSignature(p.MessageType): + MESSAGE_WIRE_TYPE = 119 FIELDS = { 1: ('address', p.UnicodeType, 0), 2: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 119 + + def __init__( + self, + address: str = None, + signature: bytes = None + ) -> None: + self.address = address + self.signature = signature diff --git a/trezorlib/messages/LiskMultisignatureType.py b/trezorlib/messages/LiskMultisignatureType.py index 223cd96ce..18363c875 100644 --- a/trezorlib/messages/LiskMultisignatureType.py +++ b/trezorlib/messages/LiskMultisignatureType.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class LiskMultisignatureType(p.MessageType): @@ -8,3 +13,13 @@ class LiskMultisignatureType(p.MessageType): 2: ('life_time', p.UVarintType, 0), 3: ('keys_group', p.UnicodeType, p.FLAG_REPEATED), } + + def __init__( + self, + min: int = None, + life_time: int = None, + keys_group: List[str] = None + ) -> None: + self.min = min + self.life_time = life_time + self.keys_group = keys_group if keys_group is not None else [] diff --git a/trezorlib/messages/LiskPublicKey.py b/trezorlib/messages/LiskPublicKey.py index 87cea3149..67db3be2f 100644 --- a/trezorlib/messages/LiskPublicKey.py +++ b/trezorlib/messages/LiskPublicKey.py @@ -3,7 +3,13 @@ from .. import protobuf as p class LiskPublicKey(p.MessageType): + MESSAGE_WIRE_TYPE = 122 FIELDS = { 1: ('public_key', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 122 + + def __init__( + self, + public_key: bytes = None + ) -> None: + self.public_key = public_key diff --git a/trezorlib/messages/LiskSignMessage.py b/trezorlib/messages/LiskSignMessage.py index 9049e0ac8..4194c8a6b 100644 --- a/trezorlib/messages/LiskSignMessage.py +++ b/trezorlib/messages/LiskSignMessage.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class LiskSignMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 118 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('message', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 118 + + def __init__( + self, + address_n: List[int] = None, + message: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.message = message diff --git a/trezorlib/messages/LiskSignTx.py b/trezorlib/messages/LiskSignTx.py index 972268a02..98587010f 100644 --- a/trezorlib/messages/LiskSignTx.py +++ b/trezorlib/messages/LiskSignTx.py @@ -1,11 +1,24 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .LiskTransactionCommon import LiskTransactionCommon class LiskSignTx(p.MessageType): + MESSAGE_WIRE_TYPE = 116 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('transaction', LiskTransactionCommon, 0), } - MESSAGE_WIRE_TYPE = 116 + + def __init__( + self, + address_n: List[int] = None, + transaction: LiskTransactionCommon = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.transaction = transaction diff --git a/trezorlib/messages/LiskSignatureType.py b/trezorlib/messages/LiskSignatureType.py index b2c8322d8..7ca584231 100644 --- a/trezorlib/messages/LiskSignatureType.py +++ b/trezorlib/messages/LiskSignatureType.py @@ -6,3 +6,9 @@ class LiskSignatureType(p.MessageType): FIELDS = { 1: ('public_key', p.BytesType, 0), } + + def __init__( + self, + public_key: bytes = None + ) -> None: + self.public_key = public_key diff --git a/trezorlib/messages/LiskSignedTx.py b/trezorlib/messages/LiskSignedTx.py index 271349ad5..df0d46d12 100644 --- a/trezorlib/messages/LiskSignedTx.py +++ b/trezorlib/messages/LiskSignedTx.py @@ -3,7 +3,13 @@ from .. import protobuf as p class LiskSignedTx(p.MessageType): + MESSAGE_WIRE_TYPE = 117 FIELDS = { 1: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 117 + + def __init__( + self, + signature: bytes = None + ) -> None: + self.signature = signature diff --git a/trezorlib/messages/LiskTransactionAsset.py b/trezorlib/messages/LiskTransactionAsset.py index 1b924a78e..15170de1e 100644 --- a/trezorlib/messages/LiskTransactionAsset.py +++ b/trezorlib/messages/LiskTransactionAsset.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .LiskDelegateType import LiskDelegateType from .LiskMultisignatureType import LiskMultisignatureType from .LiskSignatureType import LiskSignatureType @@ -13,3 +18,17 @@ class LiskTransactionAsset(p.MessageType): 4: ('multisignature', LiskMultisignatureType, 0), 5: ('data', p.UnicodeType, 0), } + + def __init__( + self, + signature: LiskSignatureType = None, + delegate: LiskDelegateType = None, + votes: List[str] = None, + multisignature: LiskMultisignatureType = None, + data: str = None + ) -> None: + self.signature = signature + self.delegate = delegate + self.votes = votes if votes is not None else [] + self.multisignature = multisignature + self.data = data diff --git a/trezorlib/messages/LiskTransactionCommon.py b/trezorlib/messages/LiskTransactionCommon.py index 159a50a53..0d3fa494b 100644 --- a/trezorlib/messages/LiskTransactionCommon.py +++ b/trezorlib/messages/LiskTransactionCommon.py @@ -15,3 +15,25 @@ class LiskTransactionCommon(p.MessageType): 8: ('timestamp', p.UVarintType, 0), 9: ('asset', LiskTransactionAsset, 0), } + + def __init__( + self, + type: int = None, + amount: int = None, + fee: int = None, + recipient_id: str = None, + sender_public_key: bytes = None, + requester_public_key: bytes = None, + signature: bytes = None, + timestamp: int = None, + asset: LiskTransactionAsset = None + ) -> None: + self.type = type + self.amount = amount + self.fee = fee + self.recipient_id = recipient_id + self.sender_public_key = sender_public_key + self.requester_public_key = requester_public_key + self.signature = signature + self.timestamp = timestamp + self.asset = asset diff --git a/trezorlib/messages/LiskVerifyMessage.py b/trezorlib/messages/LiskVerifyMessage.py index bbd144603..235ac3b0f 100644 --- a/trezorlib/messages/LiskVerifyMessage.py +++ b/trezorlib/messages/LiskVerifyMessage.py @@ -3,9 +3,19 @@ from .. import protobuf as p class LiskVerifyMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 120 FIELDS = { 1: ('signature', p.BytesType, 0), 2: ('public_key', p.BytesType, 0), 3: ('message', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 120 + + def __init__( + self, + signature: bytes = None, + public_key: bytes = None, + message: bytes = None + ) -> None: + self.signature = signature + self.public_key = public_key + self.message = message diff --git a/trezorlib/messages/LoadDevice.py b/trezorlib/messages/LoadDevice.py index c5afb35b2..f12d77414 100644 --- a/trezorlib/messages/LoadDevice.py +++ b/trezorlib/messages/LoadDevice.py @@ -4,6 +4,7 @@ from .HDNodeType import HDNodeType class LoadDevice(p.MessageType): + MESSAGE_WIRE_TYPE = 13 FIELDS = { 1: ('mnemonic', p.UnicodeType, 0), 2: ('node', HDNodeType, 0), @@ -14,4 +15,23 @@ class LoadDevice(p.MessageType): 7: ('skip_checksum', p.BoolType, 0), 8: ('u2f_counter', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 13 + + def __init__( + self, + mnemonic: str = None, + node: HDNodeType = None, + pin: str = None, + passphrase_protection: bool = None, + language: str = None, + label: str = None, + skip_checksum: bool = None, + u2f_counter: int = None + ) -> None: + self.mnemonic = mnemonic + self.node = node + self.pin = pin + self.passphrase_protection = passphrase_protection + self.language = language + self.label = label + self.skip_checksum = skip_checksum + self.u2f_counter = u2f_counter diff --git a/trezorlib/messages/MessageSignature.py b/trezorlib/messages/MessageSignature.py index fc1cad58c..b2f3d585b 100644 --- a/trezorlib/messages/MessageSignature.py +++ b/trezorlib/messages/MessageSignature.py @@ -3,8 +3,16 @@ from .. import protobuf as p class MessageSignature(p.MessageType): + MESSAGE_WIRE_TYPE = 40 FIELDS = { 1: ('address', p.UnicodeType, 0), 2: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 40 + + def __init__( + self, + address: str = None, + signature: bytes = None + ) -> None: + self.address = address + self.signature = signature diff --git a/trezorlib/messages/MultisigRedeemScriptType.py b/trezorlib/messages/MultisigRedeemScriptType.py index e818448f5..6c2cfb4f0 100644 --- a/trezorlib/messages/MultisigRedeemScriptType.py +++ b/trezorlib/messages/MultisigRedeemScriptType.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .HDNodePathType import HDNodePathType @@ -9,3 +14,13 @@ class MultisigRedeemScriptType(p.MessageType): 2: ('signatures', p.BytesType, p.FLAG_REPEATED), 3: ('m', p.UVarintType, 0), } + + def __init__( + self, + pubkeys: List[HDNodePathType] = None, + signatures: List[bytes] = None, + m: int = None + ) -> None: + self.pubkeys = pubkeys if pubkeys is not None else [] + self.signatures = signatures if signatures is not None else [] + self.m = m diff --git a/trezorlib/messages/NEMAddress.py b/trezorlib/messages/NEMAddress.py index 013b75db0..86452c87d 100644 --- a/trezorlib/messages/NEMAddress.py +++ b/trezorlib/messages/NEMAddress.py @@ -3,7 +3,13 @@ from .. import protobuf as p class NEMAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 68 FIELDS = { 1: ('address', p.UnicodeType, 0), # required } - MESSAGE_WIRE_TYPE = 68 + + def __init__( + self, + address: str = None + ) -> None: + self.address = address diff --git a/trezorlib/messages/NEMAggregateModification.py b/trezorlib/messages/NEMAggregateModification.py index 16178e07a..dd08c9db8 100644 --- a/trezorlib/messages/NEMAggregateModification.py +++ b/trezorlib/messages/NEMAggregateModification.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .NEMCosignatoryModification import NEMCosignatoryModification @@ -8,3 +13,11 @@ class NEMAggregateModification(p.MessageType): 1: ('modifications', NEMCosignatoryModification, p.FLAG_REPEATED), 2: ('relative_change', p.SVarintType, 0), } + + def __init__( + self, + modifications: List[NEMCosignatoryModification] = None, + relative_change: int = None + ) -> None: + self.modifications = modifications if modifications is not None else [] + self.relative_change = relative_change diff --git a/trezorlib/messages/NEMCosignatoryModification.py b/trezorlib/messages/NEMCosignatoryModification.py index dda8789ea..e804b7ab8 100644 --- a/trezorlib/messages/NEMCosignatoryModification.py +++ b/trezorlib/messages/NEMCosignatoryModification.py @@ -7,3 +7,11 @@ class NEMCosignatoryModification(p.MessageType): 1: ('type', p.UVarintType, 0), 2: ('public_key', p.BytesType, 0), } + + def __init__( + self, + type: int = None, + public_key: bytes = None + ) -> None: + self.type = type + self.public_key = public_key diff --git a/trezorlib/messages/NEMDecryptMessage.py b/trezorlib/messages/NEMDecryptMessage.py index f077aaa42..7ec2c90b7 100644 --- a/trezorlib/messages/NEMDecryptMessage.py +++ b/trezorlib/messages/NEMDecryptMessage.py @@ -1,12 +1,29 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class NEMDecryptMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 75 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('network', p.UVarintType, 0), 3: ('public_key', p.BytesType, 0), 4: ('payload', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 75 + + def __init__( + self, + address_n: List[int] = None, + network: int = None, + public_key: bytes = None, + payload: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.network = network + self.public_key = public_key + self.payload = payload diff --git a/trezorlib/messages/NEMDecryptedMessage.py b/trezorlib/messages/NEMDecryptedMessage.py index 551e773c7..a73ee6e2c 100644 --- a/trezorlib/messages/NEMDecryptedMessage.py +++ b/trezorlib/messages/NEMDecryptedMessage.py @@ -3,7 +3,13 @@ from .. import protobuf as p class NEMDecryptedMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 76 FIELDS = { 1: ('payload', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 76 + + def __init__( + self, + payload: bytes = None + ) -> None: + self.payload = payload diff --git a/trezorlib/messages/NEMGetAddress.py b/trezorlib/messages/NEMGetAddress.py index 55d89e149..a3d94bd37 100644 --- a/trezorlib/messages/NEMGetAddress.py +++ b/trezorlib/messages/NEMGetAddress.py @@ -1,11 +1,26 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class NEMGetAddress(p.MessageType): + MESSAGE_WIRE_TYPE = 67 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('network', p.UVarintType, 0), 3: ('show_display', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 67 + + def __init__( + self, + address_n: List[int] = None, + network: int = None, + show_display: bool = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.network = network + self.show_display = show_display diff --git a/trezorlib/messages/NEMImportanceTransfer.py b/trezorlib/messages/NEMImportanceTransfer.py index c7c4b7e21..02edce556 100644 --- a/trezorlib/messages/NEMImportanceTransfer.py +++ b/trezorlib/messages/NEMImportanceTransfer.py @@ -7,3 +7,11 @@ class NEMImportanceTransfer(p.MessageType): 1: ('mode', p.UVarintType, 0), 2: ('public_key', p.BytesType, 0), } + + def __init__( + self, + mode: int = None, + public_key: bytes = None + ) -> None: + self.mode = mode + self.public_key = public_key diff --git a/trezorlib/messages/NEMMosaic.py b/trezorlib/messages/NEMMosaic.py index 08eeb96e2..c357345c5 100644 --- a/trezorlib/messages/NEMMosaic.py +++ b/trezorlib/messages/NEMMosaic.py @@ -8,3 +8,13 @@ class NEMMosaic(p.MessageType): 2: ('mosaic', p.UnicodeType, 0), 3: ('quantity', p.UVarintType, 0), } + + def __init__( + self, + namespace: str = None, + mosaic: str = None, + quantity: int = None + ) -> None: + self.namespace = namespace + self.mosaic = mosaic + self.quantity = quantity diff --git a/trezorlib/messages/NEMMosaicCreation.py b/trezorlib/messages/NEMMosaicCreation.py index 8913ff9f3..26c7e9b0d 100644 --- a/trezorlib/messages/NEMMosaicCreation.py +++ b/trezorlib/messages/NEMMosaicCreation.py @@ -9,3 +9,13 @@ class NEMMosaicCreation(p.MessageType): 2: ('sink', p.UnicodeType, 0), 3: ('fee', p.UVarintType, 0), } + + def __init__( + self, + definition: NEMMosaicDefinition = None, + sink: str = None, + fee: int = None + ) -> None: + self.definition = definition + self.sink = sink + self.fee = fee diff --git a/trezorlib/messages/NEMMosaicDefinition.py b/trezorlib/messages/NEMMosaicDefinition.py index c57b20bf9..353694048 100644 --- a/trezorlib/messages/NEMMosaicDefinition.py +++ b/trezorlib/messages/NEMMosaicDefinition.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class NEMMosaicDefinition(p.MessageType): @@ -20,3 +25,37 @@ class NEMMosaicDefinition(p.MessageType): 14: ('description', p.UnicodeType, 0), 15: ('networks', p.UVarintType, p.FLAG_REPEATED), } + + def __init__( + self, + name: str = None, + ticker: str = None, + namespace: str = None, + mosaic: str = None, + divisibility: int = None, + levy: int = None, + fee: int = None, + levy_address: str = None, + levy_namespace: str = None, + levy_mosaic: str = None, + supply: int = None, + mutable_supply: bool = None, + transferable: bool = None, + description: str = None, + networks: List[int] = None + ) -> None: + self.name = name + self.ticker = ticker + self.namespace = namespace + self.mosaic = mosaic + self.divisibility = divisibility + self.levy = levy + self.fee = fee + self.levy_address = levy_address + self.levy_namespace = levy_namespace + self.levy_mosaic = levy_mosaic + self.supply = supply + self.mutable_supply = mutable_supply + self.transferable = transferable + self.description = description + self.networks = networks if networks is not None else [] diff --git a/trezorlib/messages/NEMMosaicSupplyChange.py b/trezorlib/messages/NEMMosaicSupplyChange.py index 258200e57..546752ea3 100644 --- a/trezorlib/messages/NEMMosaicSupplyChange.py +++ b/trezorlib/messages/NEMMosaicSupplyChange.py @@ -9,3 +9,15 @@ class NEMMosaicSupplyChange(p.MessageType): 3: ('type', p.UVarintType, 0), 4: ('delta', p.UVarintType, 0), } + + def __init__( + self, + namespace: str = None, + mosaic: str = None, + type: int = None, + delta: int = None + ) -> None: + self.namespace = namespace + self.mosaic = mosaic + self.type = type + self.delta = delta diff --git a/trezorlib/messages/NEMProvisionNamespace.py b/trezorlib/messages/NEMProvisionNamespace.py index 6388f4ab2..ec42fbcc3 100644 --- a/trezorlib/messages/NEMProvisionNamespace.py +++ b/trezorlib/messages/NEMProvisionNamespace.py @@ -9,3 +9,15 @@ class NEMProvisionNamespace(p.MessageType): 3: ('sink', p.UnicodeType, 0), 4: ('fee', p.UVarintType, 0), } + + def __init__( + self, + namespace: str = None, + parent: str = None, + sink: str = None, + fee: int = None + ) -> None: + self.namespace = namespace + self.parent = parent + self.sink = sink + self.fee = fee diff --git a/trezorlib/messages/NEMSignTx.py b/trezorlib/messages/NEMSignTx.py index aec95e2ea..fe195e4bd 100644 --- a/trezorlib/messages/NEMSignTx.py +++ b/trezorlib/messages/NEMSignTx.py @@ -10,6 +10,7 @@ from .NEMTransfer import NEMTransfer class NEMSignTx(p.MessageType): + MESSAGE_WIRE_TYPE = 69 FIELDS = { 1: ('transaction', NEMTransactionCommon, 0), 2: ('multisig', NEMTransactionCommon, 0), @@ -21,4 +22,25 @@ class NEMSignTx(p.MessageType): 8: ('aggregate_modification', NEMAggregateModification, 0), 9: ('importance_transfer', NEMImportanceTransfer, 0), } - MESSAGE_WIRE_TYPE = 69 + + def __init__( + self, + transaction: NEMTransactionCommon = None, + multisig: NEMTransactionCommon = None, + transfer: NEMTransfer = None, + cosigning: bool = None, + provision_namespace: NEMProvisionNamespace = None, + mosaic_creation: NEMMosaicCreation = None, + supply_change: NEMMosaicSupplyChange = None, + aggregate_modification: NEMAggregateModification = None, + importance_transfer: NEMImportanceTransfer = None + ) -> None: + self.transaction = transaction + self.multisig = multisig + self.transfer = transfer + self.cosigning = cosigning + self.provision_namespace = provision_namespace + self.mosaic_creation = mosaic_creation + self.supply_change = supply_change + self.aggregate_modification = aggregate_modification + self.importance_transfer = importance_transfer diff --git a/trezorlib/messages/NEMSignedTx.py b/trezorlib/messages/NEMSignedTx.py index 18eac40bb..896b0933a 100644 --- a/trezorlib/messages/NEMSignedTx.py +++ b/trezorlib/messages/NEMSignedTx.py @@ -3,8 +3,16 @@ from .. import protobuf as p class NEMSignedTx(p.MessageType): + MESSAGE_WIRE_TYPE = 70 FIELDS = { 1: ('data', p.BytesType, 0), 2: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 70 + + def __init__( + self, + data: bytes = None, + signature: bytes = None + ) -> None: + self.data = data + self.signature = signature diff --git a/trezorlib/messages/NEMTransactionCommon.py b/trezorlib/messages/NEMTransactionCommon.py index bab273d53..fe4be36ab 100644 --- a/trezorlib/messages/NEMTransactionCommon.py +++ b/trezorlib/messages/NEMTransactionCommon.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class NEMTransactionCommon(p.MessageType): @@ -11,3 +16,19 @@ class NEMTransactionCommon(p.MessageType): 5: ('deadline', p.UVarintType, 0), 6: ('signer', p.BytesType, 0), } + + def __init__( + self, + address_n: List[int] = None, + network: int = None, + timestamp: int = None, + fee: int = None, + deadline: int = None, + signer: bytes = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.network = network + self.timestamp = timestamp + self.fee = fee + self.deadline = deadline + self.signer = signer diff --git a/trezorlib/messages/NEMTransfer.py b/trezorlib/messages/NEMTransfer.py index 5bd3540d0..efcbe463c 100644 --- a/trezorlib/messages/NEMTransfer.py +++ b/trezorlib/messages/NEMTransfer.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .NEMMosaic import NEMMosaic @@ -11,3 +16,17 @@ class NEMTransfer(p.MessageType): 4: ('public_key', p.BytesType, 0), 5: ('mosaics', NEMMosaic, p.FLAG_REPEATED), } + + def __init__( + self, + recipient: str = None, + amount: int = None, + payload: bytes = None, + public_key: bytes = None, + mosaics: List[NEMMosaic] = None + ) -> None: + self.recipient = recipient + self.amount = amount + self.payload = payload + self.public_key = public_key + self.mosaics = mosaics if mosaics is not None else [] diff --git a/trezorlib/messages/PassphraseAck.py b/trezorlib/messages/PassphraseAck.py index ae4b1bda1..1e050f599 100644 --- a/trezorlib/messages/PassphraseAck.py +++ b/trezorlib/messages/PassphraseAck.py @@ -3,8 +3,16 @@ from .. import protobuf as p class PassphraseAck(p.MessageType): + MESSAGE_WIRE_TYPE = 42 FIELDS = { 1: ('passphrase', p.UnicodeType, 0), 2: ('state', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 42 + + def __init__( + self, + passphrase: str = None, + state: bytes = None + ) -> None: + self.passphrase = passphrase + self.state = state diff --git a/trezorlib/messages/PassphraseRequest.py b/trezorlib/messages/PassphraseRequest.py index 2edd3695e..cdad9f14a 100644 --- a/trezorlib/messages/PassphraseRequest.py +++ b/trezorlib/messages/PassphraseRequest.py @@ -3,7 +3,13 @@ from .. import protobuf as p class PassphraseRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 41 FIELDS = { 1: ('on_device', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 41 + + def __init__( + self, + on_device: bool = None + ) -> None: + self.on_device = on_device diff --git a/trezorlib/messages/PassphraseStateRequest.py b/trezorlib/messages/PassphraseStateRequest.py index 45dabaad4..3170b5d17 100644 --- a/trezorlib/messages/PassphraseStateRequest.py +++ b/trezorlib/messages/PassphraseStateRequest.py @@ -3,7 +3,13 @@ from .. import protobuf as p class PassphraseStateRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 77 FIELDS = { 1: ('state', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 77 + + def __init__( + self, + state: bytes = None + ) -> None: + self.state = state diff --git a/trezorlib/messages/PinMatrixAck.py b/trezorlib/messages/PinMatrixAck.py index d47a449db..ceb3a91b4 100644 --- a/trezorlib/messages/PinMatrixAck.py +++ b/trezorlib/messages/PinMatrixAck.py @@ -3,7 +3,13 @@ from .. import protobuf as p class PinMatrixAck(p.MessageType): + MESSAGE_WIRE_TYPE = 19 FIELDS = { 1: ('pin', p.UnicodeType, 0), # required } - MESSAGE_WIRE_TYPE = 19 + + def __init__( + self, + pin: str = None + ) -> None: + self.pin = pin diff --git a/trezorlib/messages/PinMatrixRequest.py b/trezorlib/messages/PinMatrixRequest.py index 3964b302b..2372383cd 100644 --- a/trezorlib/messages/PinMatrixRequest.py +++ b/trezorlib/messages/PinMatrixRequest.py @@ -3,7 +3,13 @@ from .. import protobuf as p class PinMatrixRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 18 FIELDS = { 1: ('type', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 18 + + def __init__( + self, + type: int = None + ) -> None: + self.type = type diff --git a/trezorlib/messages/Ping.py b/trezorlib/messages/Ping.py index b09a8c0ff..b595ae01c 100644 --- a/trezorlib/messages/Ping.py +++ b/trezorlib/messages/Ping.py @@ -3,10 +3,22 @@ from .. import protobuf as p class Ping(p.MessageType): + MESSAGE_WIRE_TYPE = 1 FIELDS = { 1: ('message', p.UnicodeType, 0), 2: ('button_protection', p.BoolType, 0), 3: ('pin_protection', p.BoolType, 0), 4: ('passphrase_protection', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 1 + + def __init__( + self, + message: str = None, + button_protection: bool = None, + pin_protection: bool = None, + passphrase_protection: bool = None + ) -> None: + self.message = message + self.button_protection = button_protection + self.pin_protection = pin_protection + self.passphrase_protection = passphrase_protection diff --git a/trezorlib/messages/PublicKey.py b/trezorlib/messages/PublicKey.py index bbff5c844..957fd3a1e 100644 --- a/trezorlib/messages/PublicKey.py +++ b/trezorlib/messages/PublicKey.py @@ -4,8 +4,16 @@ from .HDNodeType import HDNodeType class PublicKey(p.MessageType): + MESSAGE_WIRE_TYPE = 12 FIELDS = { 1: ('node', HDNodeType, 0), # required 2: ('xpub', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 12 + + def __init__( + self, + node: HDNodeType = None, + xpub: str = None + ) -> None: + self.node = node + self.xpub = xpub diff --git a/trezorlib/messages/RecoveryDevice.py b/trezorlib/messages/RecoveryDevice.py index 500bddd95..90b6eed11 100644 --- a/trezorlib/messages/RecoveryDevice.py +++ b/trezorlib/messages/RecoveryDevice.py @@ -3,6 +3,7 @@ from .. import protobuf as p class RecoveryDevice(p.MessageType): + MESSAGE_WIRE_TYPE = 45 FIELDS = { 1: ('word_count', p.UVarintType, 0), 2: ('passphrase_protection', p.BoolType, 0), @@ -14,4 +15,25 @@ class RecoveryDevice(p.MessageType): 9: ('u2f_counter', p.UVarintType, 0), 10: ('dry_run', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 45 + + def __init__( + self, + word_count: int = None, + passphrase_protection: bool = None, + pin_protection: bool = None, + language: str = None, + label: str = None, + enforce_wordlist: bool = None, + type: int = None, + u2f_counter: int = None, + dry_run: bool = None + ) -> None: + self.word_count = word_count + self.passphrase_protection = passphrase_protection + self.pin_protection = pin_protection + self.language = language + self.label = label + self.enforce_wordlist = enforce_wordlist + self.type = type + self.u2f_counter = u2f_counter + self.dry_run = dry_run diff --git a/trezorlib/messages/ResetDevice.py b/trezorlib/messages/ResetDevice.py index 7231cb041..bce801bd5 100644 --- a/trezorlib/messages/ResetDevice.py +++ b/trezorlib/messages/ResetDevice.py @@ -3,6 +3,7 @@ from .. import protobuf as p class ResetDevice(p.MessageType): + MESSAGE_WIRE_TYPE = 14 FIELDS = { 1: ('display_random', p.BoolType, 0), 2: ('strength', p.UVarintType, 0), # default=256 @@ -13,4 +14,23 @@ class ResetDevice(p.MessageType): 7: ('u2f_counter', p.UVarintType, 0), 8: ('skip_backup', p.BoolType, 0), } - MESSAGE_WIRE_TYPE = 14 + + def __init__( + self, + display_random: bool = None, + strength: int = None, + passphrase_protection: bool = None, + pin_protection: bool = None, + language: str = None, + label: str = None, + u2f_counter: int = None, + skip_backup: bool = None + ) -> None: + self.display_random = display_random + self.strength = strength + self.passphrase_protection = passphrase_protection + self.pin_protection = pin_protection + self.language = language + self.label = label + self.u2f_counter = u2f_counter + self.skip_backup = skip_backup diff --git a/trezorlib/messages/SelfTest.py b/trezorlib/messages/SelfTest.py index 0f4099f29..bf8bd4542 100644 --- a/trezorlib/messages/SelfTest.py +++ b/trezorlib/messages/SelfTest.py @@ -3,7 +3,13 @@ from .. import protobuf as p class SelfTest(p.MessageType): + MESSAGE_WIRE_TYPE = 32 FIELDS = { 1: ('payload', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 32 + + def __init__( + self, + payload: bytes = None + ) -> None: + self.payload = payload diff --git a/trezorlib/messages/SetU2FCounter.py b/trezorlib/messages/SetU2FCounter.py index 9598c62a1..40c56d62f 100644 --- a/trezorlib/messages/SetU2FCounter.py +++ b/trezorlib/messages/SetU2FCounter.py @@ -3,7 +3,13 @@ from .. import protobuf as p class SetU2FCounter(p.MessageType): + MESSAGE_WIRE_TYPE = 63 FIELDS = { 1: ('u2f_counter', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 63 + + def __init__( + self, + u2f_counter: int = None + ) -> None: + self.u2f_counter = u2f_counter diff --git a/trezorlib/messages/SignIdentity.py b/trezorlib/messages/SignIdentity.py index fbbcbdc4d..6b105b8ea 100644 --- a/trezorlib/messages/SignIdentity.py +++ b/trezorlib/messages/SignIdentity.py @@ -4,10 +4,22 @@ from .IdentityType import IdentityType class SignIdentity(p.MessageType): + MESSAGE_WIRE_TYPE = 53 FIELDS = { 1: ('identity', IdentityType, 0), 2: ('challenge_hidden', p.BytesType, 0), 3: ('challenge_visual', p.UnicodeType, 0), 4: ('ecdsa_curve_name', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 53 + + def __init__( + self, + identity: IdentityType = None, + challenge_hidden: bytes = None, + challenge_visual: str = None, + ecdsa_curve_name: str = None + ) -> None: + self.identity = identity + self.challenge_hidden = challenge_hidden + self.challenge_visual = challenge_visual + self.ecdsa_curve_name = ecdsa_curve_name diff --git a/trezorlib/messages/SignMessage.py b/trezorlib/messages/SignMessage.py index dde1fdd2b..5e6aa797c 100644 --- a/trezorlib/messages/SignMessage.py +++ b/trezorlib/messages/SignMessage.py @@ -1,12 +1,29 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class SignMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 38 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('message', p.BytesType, 0), # required 3: ('coin_name', p.UnicodeType, 0), # default='Bitcoin' 4: ('script_type', p.UVarintType, 0), # default=0 } - MESSAGE_WIRE_TYPE = 38 + + def __init__( + self, + address_n: List[int] = None, + message: bytes = None, + coin_name: str = None, + script_type: int = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.message = message + self.coin_name = coin_name + self.script_type = script_type diff --git a/trezorlib/messages/SignTx.py b/trezorlib/messages/SignTx.py index e182ad19d..b6cf04474 100644 --- a/trezorlib/messages/SignTx.py +++ b/trezorlib/messages/SignTx.py @@ -3,6 +3,7 @@ from .. import protobuf as p class SignTx(p.MessageType): + MESSAGE_WIRE_TYPE = 15 FIELDS = { 1: ('outputs_count', p.UVarintType, 0), # required 2: ('inputs_count', p.UVarintType, 0), # required @@ -11,4 +12,19 @@ class SignTx(p.MessageType): 5: ('lock_time', p.UVarintType, 0), # default=0 6: ('decred_expiry', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 15 + + def __init__( + self, + outputs_count: int = None, + inputs_count: int = None, + coin_name: str = None, + version: int = None, + lock_time: int = None, + decred_expiry: int = None + ) -> None: + self.outputs_count = outputs_count + self.inputs_count = inputs_count + self.coin_name = coin_name + self.version = version + self.lock_time = lock_time + self.decred_expiry = decred_expiry diff --git a/trezorlib/messages/SignedIdentity.py b/trezorlib/messages/SignedIdentity.py index 465b0c86c..dec333494 100644 --- a/trezorlib/messages/SignedIdentity.py +++ b/trezorlib/messages/SignedIdentity.py @@ -3,9 +3,19 @@ from .. import protobuf as p class SignedIdentity(p.MessageType): + MESSAGE_WIRE_TYPE = 54 FIELDS = { 1: ('address', p.UnicodeType, 0), 2: ('public_key', p.BytesType, 0), 3: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 54 + + def __init__( + self, + address: str = None, + public_key: bytes = None, + signature: bytes = None + ) -> None: + self.address = address + self.public_key = public_key + self.signature = signature diff --git a/trezorlib/messages/SimpleSignTx.py b/trezorlib/messages/SimpleSignTx.py index b6ed29bde..c66bfc0b9 100644 --- a/trezorlib/messages/SimpleSignTx.py +++ b/trezorlib/messages/SimpleSignTx.py @@ -1,11 +1,17 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .TransactionType import TransactionType from .TxInputType import TxInputType from .TxOutputType import TxOutputType class SimpleSignTx(p.MessageType): + MESSAGE_WIRE_TYPE = 16 FIELDS = { 1: ('inputs', TxInputType, p.FLAG_REPEATED), 2: ('outputs', TxOutputType, p.FLAG_REPEATED), @@ -14,4 +20,19 @@ class SimpleSignTx(p.MessageType): 5: ('version', p.UVarintType, 0), # default=1 6: ('lock_time', p.UVarintType, 0), # default=0 } - MESSAGE_WIRE_TYPE = 16 + + def __init__( + self, + inputs: List[TxInputType] = None, + outputs: List[TxOutputType] = None, + transactions: List[TransactionType] = None, + coin_name: str = None, + version: int = None, + lock_time: int = None + ) -> None: + self.inputs = inputs if inputs is not None else [] + self.outputs = outputs if outputs is not None else [] + self.transactions = transactions if transactions is not None else [] + self.coin_name = coin_name + self.version = version + self.lock_time = lock_time diff --git a/trezorlib/messages/StellarAccountMergeOp.py b/trezorlib/messages/StellarAccountMergeOp.py index 83732ae9b..7e33cef95 100644 --- a/trezorlib/messages/StellarAccountMergeOp.py +++ b/trezorlib/messages/StellarAccountMergeOp.py @@ -3,8 +3,16 @@ from .. import protobuf as p class StellarAccountMergeOp(p.MessageType): + MESSAGE_WIRE_TYPE = 218 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('destination_account', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 218 + + def __init__( + self, + source_account: bytes = None, + destination_account: bytes = None + ) -> None: + self.source_account = source_account + self.destination_account = destination_account diff --git a/trezorlib/messages/StellarAllowTrustOp.py b/trezorlib/messages/StellarAllowTrustOp.py index 2232c3ec1..0bd39f652 100644 --- a/trezorlib/messages/StellarAllowTrustOp.py +++ b/trezorlib/messages/StellarAllowTrustOp.py @@ -3,6 +3,7 @@ from .. import protobuf as p class StellarAllowTrustOp(p.MessageType): + MESSAGE_WIRE_TYPE = 217 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('trusted_account', p.BytesType, 0), @@ -10,4 +11,17 @@ class StellarAllowTrustOp(p.MessageType): 4: ('asset_code', p.UnicodeType, 0), 5: ('is_authorized', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 217 + + def __init__( + self, + source_account: bytes = None, + trusted_account: bytes = None, + asset_type: int = None, + asset_code: str = None, + is_authorized: int = None + ) -> None: + self.source_account = source_account + self.trusted_account = trusted_account + self.asset_type = asset_type + self.asset_code = asset_code + self.is_authorized = is_authorized diff --git a/trezorlib/messages/StellarAssetType.py b/trezorlib/messages/StellarAssetType.py index c997a7d67..87f066581 100644 --- a/trezorlib/messages/StellarAssetType.py +++ b/trezorlib/messages/StellarAssetType.py @@ -8,3 +8,13 @@ class StellarAssetType(p.MessageType): 2: ('code', p.UnicodeType, 0), 3: ('issuer', p.BytesType, 0), } + + def __init__( + self, + type: int = None, + code: str = None, + issuer: bytes = None + ) -> None: + self.type = type + self.code = code + self.issuer = issuer diff --git a/trezorlib/messages/StellarBumpSequenceOp.py b/trezorlib/messages/StellarBumpSequenceOp.py index ba82bd6c1..17bf76572 100644 --- a/trezorlib/messages/StellarBumpSequenceOp.py +++ b/trezorlib/messages/StellarBumpSequenceOp.py @@ -3,8 +3,16 @@ from .. import protobuf as p class StellarBumpSequenceOp(p.MessageType): + MESSAGE_WIRE_TYPE = 221 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('bump_to', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 221 + + def __init__( + self, + source_account: bytes = None, + bump_to: int = None + ) -> None: + self.source_account = source_account + self.bump_to = bump_to diff --git a/trezorlib/messages/StellarChangeTrustOp.py b/trezorlib/messages/StellarChangeTrustOp.py index 86884830e..9ae8e38f0 100644 --- a/trezorlib/messages/StellarChangeTrustOp.py +++ b/trezorlib/messages/StellarChangeTrustOp.py @@ -4,9 +4,19 @@ from .StellarAssetType import StellarAssetType class StellarChangeTrustOp(p.MessageType): + MESSAGE_WIRE_TYPE = 216 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('asset', StellarAssetType, 0), 3: ('limit', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 216 + + def __init__( + self, + source_account: bytes = None, + asset: StellarAssetType = None, + limit: int = None + ) -> None: + self.source_account = source_account + self.asset = asset + self.limit = limit diff --git a/trezorlib/messages/StellarCreateAccountOp.py b/trezorlib/messages/StellarCreateAccountOp.py index 4c5d22a43..d486e01c9 100644 --- a/trezorlib/messages/StellarCreateAccountOp.py +++ b/trezorlib/messages/StellarCreateAccountOp.py @@ -3,9 +3,19 @@ from .. import protobuf as p class StellarCreateAccountOp(p.MessageType): + MESSAGE_WIRE_TYPE = 210 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('new_account', p.BytesType, 0), 3: ('starting_balance', p.SVarintType, 0), } - MESSAGE_WIRE_TYPE = 210 + + def __init__( + self, + source_account: bytes = None, + new_account: bytes = None, + starting_balance: int = None + ) -> None: + self.source_account = source_account + self.new_account = new_account + self.starting_balance = starting_balance diff --git a/trezorlib/messages/StellarCreatePassiveOfferOp.py b/trezorlib/messages/StellarCreatePassiveOfferOp.py index e18210e8b..09764cd65 100644 --- a/trezorlib/messages/StellarCreatePassiveOfferOp.py +++ b/trezorlib/messages/StellarCreatePassiveOfferOp.py @@ -4,6 +4,7 @@ from .StellarAssetType import StellarAssetType class StellarCreatePassiveOfferOp(p.MessageType): + MESSAGE_WIRE_TYPE = 214 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('selling_asset', StellarAssetType, 0), @@ -12,4 +13,19 @@ class StellarCreatePassiveOfferOp(p.MessageType): 5: ('price_n', p.UVarintType, 0), 6: ('price_d', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 214 + + def __init__( + self, + source_account: bytes = None, + selling_asset: StellarAssetType = None, + buying_asset: StellarAssetType = None, + amount: int = None, + price_n: int = None, + price_d: int = None + ) -> None: + self.source_account = source_account + self.selling_asset = selling_asset + self.buying_asset = buying_asset + self.amount = amount + self.price_n = price_n + self.price_d = price_d diff --git a/trezorlib/messages/StellarGetPublicKey.py b/trezorlib/messages/StellarGetPublicKey.py index 2d2272aae..3629086d0 100644 --- a/trezorlib/messages/StellarGetPublicKey.py +++ b/trezorlib/messages/StellarGetPublicKey.py @@ -1,9 +1,20 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class StellarGetPublicKey(p.MessageType): + MESSAGE_WIRE_TYPE = 200 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), } - MESSAGE_WIRE_TYPE = 200 + + def __init__( + self, + address_n: List[int] = None + ) -> None: + self.address_n = address_n if address_n is not None else [] diff --git a/trezorlib/messages/StellarManageDataOp.py b/trezorlib/messages/StellarManageDataOp.py index 140019354..b63238020 100644 --- a/trezorlib/messages/StellarManageDataOp.py +++ b/trezorlib/messages/StellarManageDataOp.py @@ -3,9 +3,19 @@ from .. import protobuf as p class StellarManageDataOp(p.MessageType): + MESSAGE_WIRE_TYPE = 220 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('key', p.UnicodeType, 0), 3: ('value', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 220 + + def __init__( + self, + source_account: bytes = None, + key: str = None, + value: bytes = None + ) -> None: + self.source_account = source_account + self.key = key + self.value = value diff --git a/trezorlib/messages/StellarManageOfferOp.py b/trezorlib/messages/StellarManageOfferOp.py index 70564f151..1199b94e6 100644 --- a/trezorlib/messages/StellarManageOfferOp.py +++ b/trezorlib/messages/StellarManageOfferOp.py @@ -4,6 +4,7 @@ from .StellarAssetType import StellarAssetType class StellarManageOfferOp(p.MessageType): + MESSAGE_WIRE_TYPE = 213 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('selling_asset', StellarAssetType, 0), @@ -13,4 +14,21 @@ class StellarManageOfferOp(p.MessageType): 6: ('price_d', p.UVarintType, 0), 7: ('offer_id', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 213 + + def __init__( + self, + source_account: bytes = None, + selling_asset: StellarAssetType = None, + buying_asset: StellarAssetType = None, + amount: int = None, + price_n: int = None, + price_d: int = None, + offer_id: int = None + ) -> None: + self.source_account = source_account + self.selling_asset = selling_asset + self.buying_asset = buying_asset + self.amount = amount + self.price_n = price_n + self.price_d = price_d + self.offer_id = offer_id diff --git a/trezorlib/messages/StellarMessageSignature.py b/trezorlib/messages/StellarMessageSignature.py index 430ea9449..631a04109 100644 --- a/trezorlib/messages/StellarMessageSignature.py +++ b/trezorlib/messages/StellarMessageSignature.py @@ -3,8 +3,16 @@ from .. import protobuf as p class StellarMessageSignature(p.MessageType): + MESSAGE_WIRE_TYPE = 205 FIELDS = { 1: ('public_key', p.BytesType, 0), 2: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 205 + + def __init__( + self, + public_key: bytes = None, + signature: bytes = None + ) -> None: + self.public_key = public_key + self.signature = signature diff --git a/trezorlib/messages/StellarPathPaymentOp.py b/trezorlib/messages/StellarPathPaymentOp.py index 491d5b723..6917156aa 100644 --- a/trezorlib/messages/StellarPathPaymentOp.py +++ b/trezorlib/messages/StellarPathPaymentOp.py @@ -1,9 +1,15 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .StellarAssetType import StellarAssetType class StellarPathPaymentOp(p.MessageType): + MESSAGE_WIRE_TYPE = 212 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('send_asset', StellarAssetType, 0), @@ -13,4 +19,21 @@ class StellarPathPaymentOp(p.MessageType): 6: ('destination_amount', p.SVarintType, 0), 7: ('paths', StellarAssetType, p.FLAG_REPEATED), } - MESSAGE_WIRE_TYPE = 212 + + def __init__( + self, + source_account: bytes = None, + send_asset: StellarAssetType = None, + send_max: int = None, + destination_account: bytes = None, + destination_asset: StellarAssetType = None, + destination_amount: int = None, + paths: List[StellarAssetType] = None + ) -> None: + self.source_account = source_account + self.send_asset = send_asset + self.send_max = send_max + self.destination_account = destination_account + self.destination_asset = destination_asset + self.destination_amount = destination_amount + self.paths = paths if paths is not None else [] diff --git a/trezorlib/messages/StellarPaymentOp.py b/trezorlib/messages/StellarPaymentOp.py index 23d5be5bc..dabf12903 100644 --- a/trezorlib/messages/StellarPaymentOp.py +++ b/trezorlib/messages/StellarPaymentOp.py @@ -4,10 +4,22 @@ from .StellarAssetType import StellarAssetType class StellarPaymentOp(p.MessageType): + MESSAGE_WIRE_TYPE = 211 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('destination_account', p.BytesType, 0), 3: ('asset', StellarAssetType, 0), 4: ('amount', p.SVarintType, 0), } - MESSAGE_WIRE_TYPE = 211 + + def __init__( + self, + source_account: bytes = None, + destination_account: bytes = None, + asset: StellarAssetType = None, + amount: int = None + ) -> None: + self.source_account = source_account + self.destination_account = destination_account + self.asset = asset + self.amount = amount diff --git a/trezorlib/messages/StellarPublicKey.py b/trezorlib/messages/StellarPublicKey.py index 1229d25f4..476814078 100644 --- a/trezorlib/messages/StellarPublicKey.py +++ b/trezorlib/messages/StellarPublicKey.py @@ -3,7 +3,13 @@ from .. import protobuf as p class StellarPublicKey(p.MessageType): + MESSAGE_WIRE_TYPE = 201 FIELDS = { 1: ('public_key', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 201 + + def __init__( + self, + public_key: bytes = None + ) -> None: + self.public_key = public_key diff --git a/trezorlib/messages/StellarSetOptionsOp.py b/trezorlib/messages/StellarSetOptionsOp.py index 53d3c2ff8..ec424a82c 100644 --- a/trezorlib/messages/StellarSetOptionsOp.py +++ b/trezorlib/messages/StellarSetOptionsOp.py @@ -3,6 +3,7 @@ from .. import protobuf as p class StellarSetOptionsOp(p.MessageType): + MESSAGE_WIRE_TYPE = 215 FIELDS = { 1: ('source_account', p.BytesType, 0), 2: ('inflation_destination_account', p.BytesType, 0), @@ -17,4 +18,31 @@ class StellarSetOptionsOp(p.MessageType): 11: ('signer_key', p.BytesType, 0), 12: ('signer_weight', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 215 + + def __init__( + self, + source_account: bytes = None, + inflation_destination_account: bytes = None, + clear_flags: int = None, + set_flags: int = None, + master_weight: int = None, + low_threshold: int = None, + medium_threshold: int = None, + high_threshold: int = None, + home_domain: str = None, + signer_type: int = None, + signer_key: bytes = None, + signer_weight: int = None + ) -> None: + self.source_account = source_account + self.inflation_destination_account = inflation_destination_account + self.clear_flags = clear_flags + self.set_flags = set_flags + self.master_weight = master_weight + self.low_threshold = low_threshold + self.medium_threshold = medium_threshold + self.high_threshold = high_threshold + self.home_domain = home_domain + self.signer_type = signer_type + self.signer_key = signer_key + self.signer_weight = signer_weight diff --git a/trezorlib/messages/StellarSignMessage.py b/trezorlib/messages/StellarSignMessage.py index 5d51be39d..190a3dd11 100644 --- a/trezorlib/messages/StellarSignMessage.py +++ b/trezorlib/messages/StellarSignMessage.py @@ -1,10 +1,23 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class StellarSignMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 204 FIELDS = { 1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 2: ('message', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 204 + + def __init__( + self, + address_n: List[int] = None, + message: str = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.message = message diff --git a/trezorlib/messages/StellarSignTx.py b/trezorlib/messages/StellarSignTx.py index a78649d45..f0b252b6a 100644 --- a/trezorlib/messages/StellarSignTx.py +++ b/trezorlib/messages/StellarSignTx.py @@ -1,8 +1,14 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None class StellarSignTx(p.MessageType): + MESSAGE_WIRE_TYPE = 202 FIELDS = { 1: ('protocol_version', p.UVarintType, 0), 2: ('address_n', p.UVarintType, p.FLAG_REPEATED), @@ -18,4 +24,33 @@ class StellarSignTx(p.MessageType): 13: ('memo_hash', p.BytesType, 0), 14: ('num_operations', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 202 + + def __init__( + self, + protocol_version: int = None, + address_n: List[int] = None, + network_passphrase: str = None, + source_account: bytes = None, + fee: int = None, + sequence_number: int = None, + timebounds_start: int = None, + timebounds_end: int = None, + memo_type: int = None, + memo_text: str = None, + memo_id: int = None, + memo_hash: bytes = None, + num_operations: int = None + ) -> None: + self.protocol_version = protocol_version + self.address_n = address_n if address_n is not None else [] + self.network_passphrase = network_passphrase + self.source_account = source_account + self.fee = fee + self.sequence_number = sequence_number + self.timebounds_start = timebounds_start + self.timebounds_end = timebounds_end + self.memo_type = memo_type + self.memo_text = memo_text + self.memo_id = memo_id + self.memo_hash = memo_hash + self.num_operations = num_operations diff --git a/trezorlib/messages/StellarSignedTx.py b/trezorlib/messages/StellarSignedTx.py index 9ae7a314c..c1c03428b 100644 --- a/trezorlib/messages/StellarSignedTx.py +++ b/trezorlib/messages/StellarSignedTx.py @@ -3,8 +3,16 @@ from .. import protobuf as p class StellarSignedTx(p.MessageType): + MESSAGE_WIRE_TYPE = 230 FIELDS = { 1: ('public_key', p.BytesType, 0), 2: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 230 + + def __init__( + self, + public_key: bytes = None, + signature: bytes = None + ) -> None: + self.public_key = public_key + self.signature = signature diff --git a/trezorlib/messages/StellarVerifyMessage.py b/trezorlib/messages/StellarVerifyMessage.py index 967bdea48..2189306d9 100644 --- a/trezorlib/messages/StellarVerifyMessage.py +++ b/trezorlib/messages/StellarVerifyMessage.py @@ -3,9 +3,19 @@ from .. import protobuf as p class StellarVerifyMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 206 FIELDS = { 1: ('public_key', p.BytesType, 0), 2: ('message', p.BytesType, 0), 3: ('signature', p.BytesType, 0), } - MESSAGE_WIRE_TYPE = 206 + + def __init__( + self, + public_key: bytes = None, + message: bytes = None, + signature: bytes = None + ) -> None: + self.public_key = public_key + self.message = message + self.signature = signature diff --git a/trezorlib/messages/Success.py b/trezorlib/messages/Success.py index a7f1872aa..ea541a80a 100644 --- a/trezorlib/messages/Success.py +++ b/trezorlib/messages/Success.py @@ -3,7 +3,13 @@ from .. import protobuf as p class Success(p.MessageType): + MESSAGE_WIRE_TYPE = 2 FIELDS = { 1: ('message', p.UnicodeType, 0), } - MESSAGE_WIRE_TYPE = 2 + + def __init__( + self, + message: str = None + ) -> None: + self.message = message diff --git a/trezorlib/messages/TransactionType.py b/trezorlib/messages/TransactionType.py index d3207156d..34f0a263a 100644 --- a/trezorlib/messages/TransactionType.py +++ b/trezorlib/messages/TransactionType.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .TxInputType import TxInputType from .TxOutputBinType import TxOutputBinType from .TxOutputType import TxOutputType @@ -18,3 +23,27 @@ class TransactionType(p.MessageType): 9: ('extra_data_len', p.UVarintType, 0), 10: ('decred_expiry', p.UVarintType, 0), } + + def __init__( + self, + version: int = None, + inputs: List[TxInputType] = None, + bin_outputs: List[TxOutputBinType] = None, + outputs: List[TxOutputType] = None, + lock_time: int = None, + inputs_cnt: int = None, + outputs_cnt: int = None, + extra_data: bytes = None, + extra_data_len: int = None, + decred_expiry: int = None + ) -> None: + self.version = version + self.inputs = inputs if inputs is not None else [] + self.bin_outputs = bin_outputs if bin_outputs is not None else [] + self.outputs = outputs if outputs is not None else [] + self.lock_time = lock_time + self.inputs_cnt = inputs_cnt + self.outputs_cnt = outputs_cnt + self.extra_data = extra_data + self.extra_data_len = extra_data_len + self.decred_expiry = decred_expiry diff --git a/trezorlib/messages/TxAck.py b/trezorlib/messages/TxAck.py index 0366e0ba5..e4600b9cf 100644 --- a/trezorlib/messages/TxAck.py +++ b/trezorlib/messages/TxAck.py @@ -4,7 +4,13 @@ from .TransactionType import TransactionType class TxAck(p.MessageType): + MESSAGE_WIRE_TYPE = 22 FIELDS = { 1: ('tx', TransactionType, 0), } - MESSAGE_WIRE_TYPE = 22 + + def __init__( + self, + tx: TransactionType = None + ) -> None: + self.tx = tx diff --git a/trezorlib/messages/TxInputType.py b/trezorlib/messages/TxInputType.py index a0798aa65..05c839d81 100644 --- a/trezorlib/messages/TxInputType.py +++ b/trezorlib/messages/TxInputType.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .MultisigRedeemScriptType import MultisigRedeemScriptType @@ -16,3 +21,27 @@ class TxInputType(p.MessageType): 9: ('decred_tree', p.UVarintType, 0), 10: ('decred_script_version', p.UVarintType, 0), } + + def __init__( + self, + address_n: List[int] = None, + prev_hash: bytes = None, + prev_index: int = None, + script_sig: bytes = None, + sequence: int = None, + script_type: int = None, + multisig: MultisigRedeemScriptType = None, + amount: int = None, + decred_tree: int = None, + decred_script_version: int = None + ) -> None: + self.address_n = address_n if address_n is not None else [] + self.prev_hash = prev_hash + self.prev_index = prev_index + self.script_sig = script_sig + self.sequence = sequence + self.script_type = script_type + self.multisig = multisig + self.amount = amount + self.decred_tree = decred_tree + self.decred_script_version = decred_script_version diff --git a/trezorlib/messages/TxOutputBinType.py b/trezorlib/messages/TxOutputBinType.py index 270856e22..d8aeb308e 100644 --- a/trezorlib/messages/TxOutputBinType.py +++ b/trezorlib/messages/TxOutputBinType.py @@ -8,3 +8,13 @@ class TxOutputBinType(p.MessageType): 2: ('script_pubkey', p.BytesType, 0), # required 3: ('decred_script_version', p.UVarintType, 0), } + + def __init__( + self, + amount: int = None, + script_pubkey: bytes = None, + decred_script_version: int = None + ) -> None: + self.amount = amount + self.script_pubkey = script_pubkey + self.decred_script_version = decred_script_version diff --git a/trezorlib/messages/TxOutputType.py b/trezorlib/messages/TxOutputType.py index 63a7f199f..4f26845f6 100644 --- a/trezorlib/messages/TxOutputType.py +++ b/trezorlib/messages/TxOutputType.py @@ -1,5 +1,10 @@ # Automatically generated by pb2py from .. import protobuf as p +if __debug__: + try: + from typing import List + except ImportError: + List = None from .MultisigRedeemScriptType import MultisigRedeemScriptType @@ -13,3 +18,21 @@ class TxOutputType(p.MessageType): 6: ('op_return_data', p.BytesType, 0), 7: ('decred_script_version', p.UVarintType, 0), } + + def __init__( + self, + address: str = None, + address_n: List[int] = None, + amount: int = None, + script_type: int = None, + multisig: MultisigRedeemScriptType = None, + op_return_data: bytes = None, + decred_script_version: int = None + ) -> None: + self.address = address + self.address_n = address_n if address_n is not None else [] + self.amount = amount + self.script_type = script_type + self.multisig = multisig + self.op_return_data = op_return_data + self.decred_script_version = decred_script_version diff --git a/trezorlib/messages/TxRequest.py b/trezorlib/messages/TxRequest.py index 9eb813de7..6c76c85f3 100644 --- a/trezorlib/messages/TxRequest.py +++ b/trezorlib/messages/TxRequest.py @@ -5,9 +5,19 @@ from .TxRequestSerializedType import TxRequestSerializedType class TxRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 21 FIELDS = { 1: ('request_type', p.UVarintType, 0), 2: ('details', TxRequestDetailsType, 0), 3: ('serialized', TxRequestSerializedType, 0), } - MESSAGE_WIRE_TYPE = 21 + + def __init__( + self, + request_type: int = None, + details: TxRequestDetailsType = None, + serialized: TxRequestSerializedType = None + ) -> None: + self.request_type = request_type + self.details = details + self.serialized = serialized diff --git a/trezorlib/messages/TxRequestDetailsType.py b/trezorlib/messages/TxRequestDetailsType.py index ea49a094e..754e56ed8 100644 --- a/trezorlib/messages/TxRequestDetailsType.py +++ b/trezorlib/messages/TxRequestDetailsType.py @@ -9,3 +9,15 @@ class TxRequestDetailsType(p.MessageType): 3: ('extra_data_len', p.UVarintType, 0), 4: ('extra_data_offset', p.UVarintType, 0), } + + def __init__( + self, + request_index: int = None, + tx_hash: bytes = None, + extra_data_len: int = None, + extra_data_offset: int = None + ) -> None: + self.request_index = request_index + self.tx_hash = tx_hash + self.extra_data_len = extra_data_len + self.extra_data_offset = extra_data_offset diff --git a/trezorlib/messages/TxRequestSerializedType.py b/trezorlib/messages/TxRequestSerializedType.py index 4225a34de..c9e25a240 100644 --- a/trezorlib/messages/TxRequestSerializedType.py +++ b/trezorlib/messages/TxRequestSerializedType.py @@ -8,3 +8,13 @@ class TxRequestSerializedType(p.MessageType): 2: ('signature', p.BytesType, 0), 3: ('serialized_tx', p.BytesType, 0), } + + def __init__( + self, + signature_index: int = None, + signature: bytes = None, + serialized_tx: bytes = None + ) -> None: + self.signature_index = signature_index + self.signature = signature + self.serialized_tx = serialized_tx diff --git a/trezorlib/messages/TxSize.py b/trezorlib/messages/TxSize.py index 32713f7e7..378db7049 100644 --- a/trezorlib/messages/TxSize.py +++ b/trezorlib/messages/TxSize.py @@ -3,7 +3,13 @@ from .. import protobuf as p class TxSize(p.MessageType): + MESSAGE_WIRE_TYPE = 44 FIELDS = { 1: ('tx_size', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 44 + + def __init__( + self, + tx_size: int = None + ) -> None: + self.tx_size = tx_size diff --git a/trezorlib/messages/VerifyMessage.py b/trezorlib/messages/VerifyMessage.py index 280935739..2d861442b 100644 --- a/trezorlib/messages/VerifyMessage.py +++ b/trezorlib/messages/VerifyMessage.py @@ -3,10 +3,22 @@ from .. import protobuf as p class VerifyMessage(p.MessageType): + MESSAGE_WIRE_TYPE = 39 FIELDS = { 1: ('address', p.UnicodeType, 0), 2: ('signature', p.BytesType, 0), 3: ('message', p.BytesType, 0), 4: ('coin_name', p.UnicodeType, 0), # default='Bitcoin' } - MESSAGE_WIRE_TYPE = 39 + + def __init__( + self, + address: str = None, + signature: bytes = None, + message: bytes = None, + coin_name: str = None + ) -> None: + self.address = address + self.signature = signature + self.message = message + self.coin_name = coin_name diff --git a/trezorlib/messages/WordAck.py b/trezorlib/messages/WordAck.py index bbc9a5351..6c1c3c58f 100644 --- a/trezorlib/messages/WordAck.py +++ b/trezorlib/messages/WordAck.py @@ -3,7 +3,13 @@ from .. import protobuf as p class WordAck(p.MessageType): + MESSAGE_WIRE_TYPE = 47 FIELDS = { 1: ('word', p.UnicodeType, 0), # required } - MESSAGE_WIRE_TYPE = 47 + + def __init__( + self, + word: str = None + ) -> None: + self.word = word diff --git a/trezorlib/messages/WordRequest.py b/trezorlib/messages/WordRequest.py index f03b6b8a2..410d5cfb7 100644 --- a/trezorlib/messages/WordRequest.py +++ b/trezorlib/messages/WordRequest.py @@ -3,7 +3,13 @@ from .. import protobuf as p class WordRequest(p.MessageType): + MESSAGE_WIRE_TYPE = 46 FIELDS = { 1: ('type', p.UVarintType, 0), } - MESSAGE_WIRE_TYPE = 46 + + def __init__( + self, + type: int = None + ) -> None: + self.type = type