From 841af5406108736ba89578b587ed145f710c54d9 Mon Sep 17 00:00:00 2001 From: Saleem Rashid Date: Tue, 25 Jul 2017 15:23:10 +0100 Subject: [PATCH] vendor: Update trezor-common --- firmware/coins-gen.py | 5 ++++- firmware/coins.c | 18 ++++++++++-------- firmware/coins.h | 2 +- firmware/protob/messages.options | 2 +- firmware/protob/messages.pb.h | 8 ++++---- firmware/protob/types.pb.c | 3 ++- firmware/protob/types.pb.h | 11 +++++++---- vendor/trezor-common | 2 +- 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/firmware/coins-gen.py b/firmware/coins-gen.py index 59c88a868f..ca05d43406 100755 --- a/firmware/coins-gen.py +++ b/firmware/coins-gen.py @@ -32,7 +32,10 @@ for c in coins: '0x%s' % c['xprv_magic'] if c['xprv_magic'] is not None else '00000000', 'true' if c['segwit'] is not None else 'false', - 'true' if c['segwit'] else 'false' + 'true' if c['segwit'] else 'false', + + 'true' if c['forkid'] is not None else 'false', + '%d' % c['forkid'] if c['forkid'] else '0' ]) for j in range(len(fields[0])): diff --git a/firmware/coins.c b/firmware/coins.c index aea568101e..8525d05006 100644 --- a/firmware/coins.c +++ b/firmware/coins.c @@ -26,14 +26,16 @@ // filled CoinType Protobuf structure defined in https://github.com/trezor/trezor-common/blob/master/protob/types.proto#L133 // address types > 0xFF represent a two-byte prefix in big-endian order const CoinType coins[COINS_COUNT] = { - {true, "Bitcoin", true, " BTC", true, 0, true, 500000, true, 5, true, "\x18" "Bitcoin Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, true, }, - {true, "Testnet", true, " TEST", true, 111, true, 10000000, true, 196, true, "\x18" "Bitcoin Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, true, }, - {true, "Namecoin", true, " NMC", true, 52, true, 10000000, true, 5, true, "\x19" "Namecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, true, false, }, - {true, "Litecoin", true, " LTC", true, 48, true, 40000000, true, 50, true, "\x19" "Litecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, true, true, }, - {true, "Dogecoin", true, " DOGE", true, 30, true, 1000000000, true, 22, true, "\x19" "Dogecoin Signed Message:\n", true, 0x02facafd, true, 0x02fac398, true, false, }, - {true, "Dash", true, " DASH", true, 76, true, 100000, true, 16, true, "\x19" "DarkCoin Signed Message:\n", true, 0x02fe52cc, true, 0x02fe52f8, true, false, }, - {true, "Zcash", true, " ZEC", true, 7352, true, 1000000, true, 7357, true, "\x16" "Zcash Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, false, }, - {true, "Zcash Testnet", true, " TAZ", true, 7461, true, 10000000, true, 7354, true, "\x16" "Zcash Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, false, }, + {true, "Bitcoin", true, " BTC", true, 0, true, 500000, true, 5, true, "\x18" "Bitcoin Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, true, false, 0, }, + {true, "Testnet", true, " TEST", true, 111, true, 10000000, true, 196, true, "\x18" "Bitcoin Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, true, false, 0, }, + {true, "Bitcoin Cash", true, " BCH", true, 0, true, 500000, true, 5, true, "\x18" "Bitcoin Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, false, true, 0, }, + {true, "Testnet Cash", true, " TBCH", true, 111, true, 10000000, true, 196, true, "\x18" "Bitcoin Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, false, true, 0, }, + {true, "Namecoin", true, " NMC", true, 52, true, 10000000, true, 5, true, "\x19" "Namecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, true, false, false, 0, }, + {true, "Litecoin", true, " LTC", true, 48, true, 40000000, true, 50, true, "\x19" "Litecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, true, true, false, 0, }, + {true, "Dogecoin", true, " DOGE", true, 30, true, 1000000000, true, 22, true, "\x19" "Dogecoin Signed Message:\n", true, 0x02facafd, true, 0x02fac398, true, false, false, 0, }, + {true, "Dash", true, " DASH", true, 76, true, 100000, true, 16, true, "\x19" "DarkCoin Signed Message:\n", true, 0x02fe52cc, true, 0x02fe52f8, true, false, false, 0, }, + {true, "Zcash", true, " ZEC", true, 7352, true, 1000000, true, 7357, true, "\x16" "Zcash Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, false, false, 0, }, + {true, "Zcash Testnet", true, " TAZ", true, 7461, true, 10000000, true, 7354, true, "\x16" "Zcash Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, false, false, 0, }, }; const CoinType *coinByName(const char *name) diff --git a/firmware/coins.h b/firmware/coins.h index 1ae87eb846..42e9e2f915 100644 --- a/firmware/coins.h +++ b/firmware/coins.h @@ -22,7 +22,7 @@ #include "types.pb.h" -#define COINS_COUNT 8 +#define COINS_COUNT 10 extern const CoinType coins[COINS_COUNT]; diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index 47d0d9b2ca..a6aa613c5f 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -2,7 +2,7 @@ Features.vendor max_size:33 Features.device_id max_size:25 Features.language max_size:17 Features.label max_size:33 -Features.coins max_count:8 +Features.coins max_count:10 Features.revision max_size:20 Features.bootloader_hash max_size:32 diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index 3ebb54e19a..25beba025d 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -506,7 +506,7 @@ typedef struct _Features { bool has_label; char label[33]; size_t coins_count; - CoinType coins[8]; + CoinType coins[10]; bool has_initialized; bool initialized; bool has_revision; @@ -803,7 +803,7 @@ extern const uint32_t SignTx_lock_time_default; /* Initializer values for message structs */ #define Initialize_init_default {0} #define GetFeatures_init_default {0} -#define Features_init_default {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define Features_init_default {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define ClearSession_init_default {0} #define ApplySettings_init_default {false, "", false, "", false, 0, false, {0, {0}}} #define ApplyFlags_init_default {false, 0} @@ -865,7 +865,7 @@ extern const uint32_t SignTx_lock_time_default; #define DebugLinkFlashErase_init_default {false, 0} #define Initialize_init_zero {0} #define GetFeatures_init_zero {0} -#define Features_init_zero {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define Features_init_zero {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define ClearSession_init_zero {0} #define ApplySettings_init_zero {false, "", false, "", false, 0, false, {0, {0}}} #define ApplyFlags_init_zero {false, 0} @@ -1159,7 +1159,7 @@ extern const pb_field_t DebugLinkFlashErase_fields[2]; /* Maximum encoded size of messages (where known) */ #define Initialize_size 0 #define GetFeatures_size 0 -#define Features_size (267 + 8*CoinType_size) +#define Features_size (279 + 10*CoinType_size) #define ClearSession_size 0 #define ApplySettings_size 1083 #define ApplyFlags_size 6 diff --git a/firmware/protob/types.pb.c b/firmware/protob/types.pb.c index c35f3d10d8..7974a2811f 100644 --- a/firmware/protob/types.pb.c +++ b/firmware/protob/types.pb.c @@ -28,7 +28,7 @@ const pb_field_t HDNodePathType_fields[3] = { PB_LAST_FIELD }; -const pb_field_t CoinType_fields[10] = { +const pb_field_t CoinType_fields[11] = { PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, CoinType, coin_name, coin_name, 0), PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CoinType, coin_shortcut, coin_name, 0), PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type, coin_shortcut, &CoinType_address_type_default), @@ -38,6 +38,7 @@ const pb_field_t CoinType_fields[10] = { PB_FIELD2( 9, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, xpub_magic, signed_message_header, &CoinType_xpub_magic_default), PB_FIELD2( 10, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, xprv_magic, xpub_magic, &CoinType_xprv_magic_default), PB_FIELD2( 11, BOOL , OPTIONAL, STATIC , OTHER, CoinType, segwit, xprv_magic, 0), + PB_FIELD2( 12, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, forkid, segwit, 0), PB_LAST_FIELD }; diff --git a/firmware/protob/types.pb.h b/firmware/protob/types.pb.h index 8ddbee4ffe..9bfd3dd9df 100644 --- a/firmware/protob/types.pb.h +++ b/firmware/protob/types.pb.h @@ -100,6 +100,8 @@ typedef struct _CoinType { uint32_t xprv_magic; bool has_segwit; bool segwit; + bool has_forkid; + uint32_t forkid; } CoinType; typedef struct { @@ -299,7 +301,7 @@ extern const uint32_t IdentityType_index_default; /* Initializer values for message structs */ #define HDNodeType_init_default {0, 0, 0, {0, {0}}, false, {0, {0}}, false, {0, {0}}} #define HDNodePathType_init_default {HDNodeType_init_default, 0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, "", false, 76067358u, false, 76066276u, false, 0} +#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, "", false, 76067358u, false, 76066276u, false, 0, false, 0} #define MultisigRedeemScriptType_init_default {0, {HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} #define TxInputType_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 4294967295u, false, InputScriptType_SPENDADDRESS, false, MultisigRedeemScriptType_init_default, false, 0} #define TxOutputType_init_default {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_default, false, {0, {0}}} @@ -310,7 +312,7 @@ extern const uint32_t IdentityType_index_default; #define IdentityType_init_default {false, "", false, "", false, "", false, "", false, "", false, 0u} #define HDNodeType_init_zero {0, 0, 0, {0, {0}}, false, {0, {0}}, false, {0, {0}}} #define HDNodePathType_init_zero {HDNodeType_init_zero, 0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, 0} +#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, 0, false, 0} #define MultisigRedeemScriptType_init_zero {0, {HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} #define TxInputType_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 0, false, (InputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, 0} #define TxOutputType_init_zero {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, {0, {0}}} @@ -330,6 +332,7 @@ extern const uint32_t IdentityType_index_default; #define CoinType_xpub_magic_tag 9 #define CoinType_xprv_magic_tag 10 #define CoinType_segwit_tag 11 +#define CoinType_forkid_tag 12 #define HDNodeType_depth_tag 1 #define HDNodeType_fingerprint_tag 2 #define HDNodeType_child_num_tag 3 @@ -389,7 +392,7 @@ extern const uint32_t IdentityType_index_default; /* Struct field encoding specification for nanopb */ extern const pb_field_t HDNodeType_fields[7]; extern const pb_field_t HDNodePathType_fields[3]; -extern const pb_field_t CoinType_fields[10]; +extern const pb_field_t CoinType_fields[11]; extern const pb_field_t MultisigRedeemScriptType_fields[4]; extern const pb_field_t TxInputType_fields[9]; extern const pb_field_t TxOutputType_fields[7]; @@ -402,7 +405,7 @@ extern const pb_field_t IdentityType_fields[7]; /* Maximum encoded size of messages (where known) */ #define HDNodeType_size 121 #define HDNodePathType_size 171 -#define CoinType_size 101 +#define CoinType_size 107 #define MultisigRedeemScriptType_size 3741 #define TxInputType_size 5508 #define TxOutputType_size 3947 diff --git a/vendor/trezor-common b/vendor/trezor-common index 00900951e0..dc1ed85c96 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit 00900951e072aaa2d7c48da807bb0032b6b898c1 +Subproject commit dc1ed85c96e3766f9e99dc4c8af12ecf6de22f1e