From e6d93c593322ceeb73e5bee4a1d9b72826be5c1d Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 8 May 2017 18:04:05 +0200 Subject: [PATCH] wallet: fix GetPublicKey msg, regenerate protobuf --- src/apps/wallet/get_public_key.py | 11 +- src/trezor/messages/CoinType.py | 3 + src/trezor/messages/EthereumSignTx.py | 1 + src/trezor/messages/FirmwareRequest.py | 9 ++ src/trezor/messages/FirmwareUpload.py | 1 + src/trezor/messages/GetPublicKey.py | 1 + src/trezor/messages/MessageType.py | 1 + src/trezor/messages/RecoveryDevice.py | 3 +- src/trezor/messages/RecoveryDeviceType.py | 3 + src/trezor/messages/WordRequest.py | 3 + src/trezor/messages/WordRequestType.py | 4 + src/trezor/messages/wire_types.py | 133 +++++++++++----------- 12 files changed, 103 insertions(+), 70 deletions(-) create mode 100644 src/trezor/messages/FirmwareRequest.py create mode 100644 src/trezor/messages/RecoveryDeviceType.py create mode 100644 src/trezor/messages/WordRequestType.py diff --git a/src/apps/wallet/get_public_key.py b/src/apps/wallet/get_public_key.py index 22910a4bf0..66a2beff2f 100644 --- a/src/apps/wallet/get_public_key.py +++ b/src/apps/wallet/get_public_key.py @@ -5,12 +5,17 @@ from trezor.utils import unimport async def layout_get_public_key(session_id, msg): from trezor.messages.HDNodeType import HDNodeType from trezor.messages.PublicKey import PublicKey + from ..common import coins from ..common import seed - node = await seed.get_root(session_id) - node.derive_path(msg.address_n or ()) + address_n = msg.address_n or () + coin_name = msg.coin_name or 'Bitcoin' - node_xpub = node.serialize_public() + node = await seed.get_root(session_id) + node.derive_path(address_n) + coin = coins.by_name(coin_name) + + node_xpub = node.serialize_public(coin.xpub_magic) node_type = HDNodeType( depth=node.depth(), child_num=node.child_num(), diff --git a/src/trezor/messages/CoinType.py b/src/trezor/messages/CoinType.py index c4d192cecd..9bb455113c 100644 --- a/src/trezor/messages/CoinType.py +++ b/src/trezor/messages/CoinType.py @@ -11,4 +11,7 @@ class CoinType(p.MessageType): 6: ('address_type_p2wpkh', p.UVarintType, 0), # default=6 7: ('address_type_p2wsh', p.UVarintType, 0), # default=10 8: ('signed_message_header', p.UnicodeType, 0), + 9: ('xpub_magic', p.UVarintType, 0), # default=76067358 + 10: ('xprv_magic', p.UVarintType, 0), # default=76066276 + 11: ('segwit', p.BoolType, 0), } diff --git a/src/trezor/messages/EthereumSignTx.py b/src/trezor/messages/EthereumSignTx.py index 35f6b035af..17d65ce45d 100644 --- a/src/trezor/messages/EthereumSignTx.py +++ b/src/trezor/messages/EthereumSignTx.py @@ -11,5 +11,6 @@ class EthereumSignTx(p.MessageType): 6: ('value', p.BytesType, 0), 7: ('data_initial_chunk', p.BytesType, 0), 8: ('data_length', p.UVarintType, 0), + 9: ('chain_id', p.UVarintType, 0), } MESSAGE_WIRE_TYPE = 58 diff --git a/src/trezor/messages/FirmwareRequest.py b/src/trezor/messages/FirmwareRequest.py new file mode 100644 index 0000000000..8a8c9a61fd --- /dev/null +++ b/src/trezor/messages/FirmwareRequest.py @@ -0,0 +1,9 @@ +# Automatically generated by pb2py +import protobuf as p + +class FirmwareRequest(p.MessageType): + FIELDS = { + 1: ('offset', p.UVarintType, 0), + 2: ('length', p.UVarintType, 0), + } + MESSAGE_WIRE_TYPE = 8 diff --git a/src/trezor/messages/FirmwareUpload.py b/src/trezor/messages/FirmwareUpload.py index 8dec297631..aaa4f31e30 100644 --- a/src/trezor/messages/FirmwareUpload.py +++ b/src/trezor/messages/FirmwareUpload.py @@ -4,5 +4,6 @@ import protobuf as p class FirmwareUpload(p.MessageType): FIELDS = { 1: ('payload', p.BytesType, 0), # required + 2: ('hash', p.BytesType, 0), } MESSAGE_WIRE_TYPE = 7 diff --git a/src/trezor/messages/GetPublicKey.py b/src/trezor/messages/GetPublicKey.py index 5a2317cadb..e37fa5c3a6 100644 --- a/src/trezor/messages/GetPublicKey.py +++ b/src/trezor/messages/GetPublicKey.py @@ -6,5 +6,6 @@ class GetPublicKey(p.MessageType): 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=u'Bitcoin' } MESSAGE_WIRE_TYPE = 11 diff --git a/src/trezor/messages/MessageType.py b/src/trezor/messages/MessageType.py index 9cdcccf692..927f5a0ef1 100644 --- a/src/trezor/messages/MessageType.py +++ b/src/trezor/messages/MessageType.py @@ -7,6 +7,7 @@ ChangePin = const(4) WipeDevice = const(5) FirmwareErase = const(6) FirmwareUpload = const(7) +FirmwareRequest = const(8) GetEntropy = const(9) Entropy = const(10) GetPublicKey = const(11) diff --git a/src/trezor/messages/RecoveryDevice.py b/src/trezor/messages/RecoveryDevice.py index 1ab03940ce..f0d07d0525 100644 --- a/src/trezor/messages/RecoveryDevice.py +++ b/src/trezor/messages/RecoveryDevice.py @@ -9,6 +9,7 @@ class RecoveryDevice(p.MessageType): 4: ('language', p.UnicodeType, 0), # default=u'english' 5: ('label', p.UnicodeType, 0), 6: ('enforce_wordlist', p.BoolType, 0), - 7: ('u2f_counter', p.UVarintType, 0), + 8: ('type', p.UVarintType, 0), + 9: ('u2f_counter', p.UVarintType, 0), } MESSAGE_WIRE_TYPE = 45 diff --git a/src/trezor/messages/RecoveryDeviceType.py b/src/trezor/messages/RecoveryDeviceType.py new file mode 100644 index 0000000000..0223a03ff2 --- /dev/null +++ b/src/trezor/messages/RecoveryDeviceType.py @@ -0,0 +1,3 @@ +# Automatically generated by pb2py +ScrambledWords = const(0) +Matrix = const(1) diff --git a/src/trezor/messages/WordRequest.py b/src/trezor/messages/WordRequest.py index 25d88bb128..763bc88f0f 100644 --- a/src/trezor/messages/WordRequest.py +++ b/src/trezor/messages/WordRequest.py @@ -2,4 +2,7 @@ import protobuf as p class WordRequest(p.MessageType): + FIELDS = { + 1: ('type', p.UVarintType, 0), + } MESSAGE_WIRE_TYPE = 46 diff --git a/src/trezor/messages/WordRequestType.py b/src/trezor/messages/WordRequestType.py new file mode 100644 index 0000000000..e0baf37631 --- /dev/null +++ b/src/trezor/messages/WordRequestType.py @@ -0,0 +1,4 @@ +# Automatically generated by pb2py +Plain = const(0) +Matrix9 = const(1) +Matrix6 = const(2) diff --git a/src/trezor/messages/wire_types.py b/src/trezor/messages/wire_types.py index b8baec2b05..ad84d3111d 100644 --- a/src/trezor/messages/wire_types.py +++ b/src/trezor/messages/wire_types.py @@ -1,66 +1,67 @@ -WordRequest = 46 -DebugLinkMemoryWrite = 112 -ButtonAck = 27 -MessageSignature = 40 -EthereumAddress = 57 -EthereumTxAck = 60 -Ping = 1 -EncryptedMessage = 50 -DebugLinkStop = 103 -EstimateTxSize = 43 -GetPublicKey = 11 -GetFeatures = 55 -GetECDHSessionKey = 61 -PinMatrixRequest = 18 -ClearSession = 24 -LoadDevice = 13 -VerifyMessage = 39 -EthereumSignTx = 58 -PassphraseRequest = 41 -TxAck = 22 -ChangePin = 4 -DebugLinkLog = 104 -FirmwareErase = 6 -TxRequest = 21 -EthereumGetAddress = 56 -DebugLinkState = 102 -EthereumTxRequest = 59 -FirmwareUpload = 7 -SignedIdentity = 54 -Failure = 3 -EntropyRequest = 35 -ApplySettings = 25 -DebugLinkFlashErase = 113 -Address = 30 -Initialize = 0 -PinMatrixAck = 19 -SetU2FCounter = 63 -SignTx = 15 -DebugLinkGetState = 101 -Success = 2 -ResetDevice = 14 -WordAck = 47 -SimpleSignTx = 16 -GetAddress = 29 -TxSize = 44 -PassphraseAck = 42 -SignMessage = 38 -DecryptedMessage = 52 -DecryptMessage = 51 -GetEntropy = 9 -EntropyAck = 36 -WipeDevice = 5 -CipherKeyValue = 23 -Features = 17 -RecoveryDevice = 45 -SignIdentity = 53 -DebugLinkDecision = 100 -CipheredKeyValue = 48 -ButtonRequest = 26 -PublicKey = 12 -DebugLinkMemory = 111 -Entropy = 10 -Cancel = 20 -DebugLinkMemoryRead = 110 -EncryptMessage = 49 -ECDHSessionKey = 62 +WordRequest = const(46) +DebugLinkMemoryWrite = const(112) +ButtonAck = const(27) +MessageSignature = const(40) +EthereumAddress = const(57) +EthereumTxAck = const(60) +Ping = const(1) +EncryptedMessage = const(50) +DebugLinkStop = const(103) +EstimateTxSize = const(43) +GetPublicKey = const(11) +GetFeatures = const(55) +GetECDHSessionKey = const(61) +PinMatrixRequest = const(18) +ClearSession = const(24) +LoadDevice = const(13) +VerifyMessage = const(39) +EthereumSignTx = const(58) +PassphraseRequest = const(41) +TxAck = const(22) +ChangePin = const(4) +DebugLinkLog = const(104) +FirmwareErase = const(6) +TxRequest = const(21) +EthereumGetAddress = const(56) +DebugLinkState = const(102) +EthereumTxRequest = const(59) +FirmwareUpload = const(7) +SignedIdentity = const(54) +Failure = const(3) +EntropyRequest = const(35) +ApplySettings = const(25) +DebugLinkFlashErase = const(113) +Address = const(30) +Initialize = const(0) +PinMatrixAck = const(19) +SetU2FCounter = const(63) +SignTx = const(15) +DebugLinkGetState = const(101) +FirmwareRequest = const(8) +Success = const(2) +ResetDevice = const(14) +WordAck = const(47) +SimpleSignTx = const(16) +GetAddress = const(29) +TxSize = const(44) +PassphraseAck = const(42) +SignMessage = const(38) +DecryptedMessage = const(52) +DecryptMessage = const(51) +GetEntropy = const(9) +EntropyAck = const(36) +WipeDevice = const(5) +CipherKeyValue = const(23) +Features = const(17) +RecoveryDevice = const(45) +SignIdentity = const(53) +DebugLinkDecision = const(100) +CipheredKeyValue = const(48) +ButtonRequest = const(26) +PublicKey = const(12) +DebugLinkMemory = const(111) +Entropy = const(10) +Cancel = const(20) +DebugLinkMemoryRead = const(110) +EncryptMessage = const(49) +ECDHSessionKey = const(62)