1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

protob: don't return coins in Features message

This commit is contained in:
Pavol Rusnak 2018-05-22 18:40:15 +02:00
parent ae82735b6b
commit a83c64fbdb
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
6 changed files with 7 additions and 36 deletions

View File

@ -44,7 +44,7 @@ const CoinInfo *coinByAddressType(uint32_t address_type)
return 0;
}
const CoinInfo *coinByCoinType(uint32_t coin_type)
const CoinInfo *coinBySlip44(uint32_t coin_type)
{
for (int i = 0; i < COINS_COUNT; i++) {
if (coin_type == coins[i].coin_type) {

View File

@ -54,7 +54,7 @@ typedef struct _CoinInfo {
const CoinInfo *coinByName(const char *name);
const CoinInfo *coinByAddressType(uint32_t address_type);
const CoinInfo *coinByCoinType(uint32_t coin_type);
const CoinInfo *coinBySlip44(uint32_t coin_type);
bool coinExtractAddressType(const CoinInfo *coin, const char *addr, uint32_t *address_type);
bool coinExtractAddressTypeRaw(const CoinInfo *coin, const uint8_t *addr_raw, uint32_t *address_type);

View File

@ -42,36 +42,7 @@ void fsm_msgGetFeatures(GetFeatures *msg)
resp->has_label = true;
strlcpy(resp->label, storage_getLabel(), sizeof(resp->label));
}
_Static_assert(pb_arraysize(Features, coins) >= COINS_COUNT, "Features.coins max_count not large enough");
resp->coins_count = COINS_COUNT;
for (int i = 0; i < COINS_COUNT; i++) {
if (coins[i].coin_name) {
resp->coins[i].has_coin_name = true;
strlcpy(resp->coins[i].coin_name, coins[i].coin_name, sizeof(resp->coins[i].coin_name));
}
if (coins[i].coin_shortcut) {
resp->coins[i].has_coin_shortcut = true;
strlcpy(resp->coins[i].coin_shortcut, coins[i].coin_shortcut + 1, sizeof(resp->coins[i].coin_shortcut));
}
resp->coins[i].has_address_type = coins[i].has_address_type;
resp->coins[i].address_type = coins[i].address_type;
resp->coins[i].has_maxfee_kb = true;
resp->coins[i].maxfee_kb = coins[i].maxfee_kb;
resp->coins[i].has_address_type_p2sh = coins[i].has_address_type_p2sh;
resp->coins[i].address_type_p2sh = coins[i].address_type_p2sh;
resp->coins[i].has_xpub_magic = coins[i].xpub_magic != 0;
resp->coins[i].xpub_magic = coins[i].xpub_magic;
resp->coins[i].has_xprv_magic = coins[i].xprv_magic != 0;
resp->coins[i].xprv_magic = coins[i].xprv_magic;
resp->coins[i].has_segwit = true;
resp->coins[i].segwit = coins[i].has_segwit;
resp->coins[i].has_forkid = coins[i].has_forkid;
resp->coins[i].forkid = coins[i].forkid;
resp->coins[i].has_force_bip143 = true;
resp->coins[i].force_bip143 = coins[i].force_bip143;
}
resp->has_initialized = true; resp->initialized = storage_isInitialized();
resp->has_imported = true; resp->imported = storage_isImported();
resp->has_pin_cached = true; resp->pin_cached = session_isPinCached();

View File

@ -75,7 +75,7 @@ static const char *address_n_str(const uint32_t *address_n, size_t address_n_cou
bool native_segwit = (address_n[0] == (0x80000000 + 84));
bool p2sh_segwit = (address_n[0] == (0x80000000 + 49));
bool legacy = false;
const CoinInfo *coin = coinByCoinType(address_n[1]);
const CoinInfo *coin = coinBySlip44(address_n[1]);
const char *abbr = 0;
if (native_segwit) {
if (coin && coin->has_segwit && coin->bech32_prefix) {

View File

@ -4,7 +4,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:16
Features.coins max_count:0
Features.revision max_size:20
Features.bootloader_hash max_size:32
Features.model max_size:17

View File

@ -4,9 +4,9 @@ HDNodeType.public_key max_size:33
HDNodePathType.address_n max_count:8
CoinType.coin_name max_size:17
CoinType.coin_shortcut max_size:9
CoinType.signed_message_header max_size:32
CoinType.coin_name max_size:0
CoinType.coin_shortcut max_size:0
CoinType.signed_message_header max_size:0
TxInputType.address_n max_count:8
TxInputType.prev_hash max_size:32