1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

add bip44 coin_type to CoinInfo

This commit is contained in:
Pavol Rusnak 2017-11-16 18:34:50 +01:00
parent 54659d49d8
commit cc0896c334
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 14 additions and 1 deletions

View File

@ -27,7 +27,8 @@ def get_fields(coin):
'0x%s' % coin['xpub_magic'] if coin['xpub_magic'] is not None else '0x00000000',
'0x%s' % coin['xprv_magic'] if coin['xprv_magic'] is not None else '0x00000000',
'%d' % coin['forkid'] if coin['forkid'] else '0',
'"%s"' % coin['bech32_prefix'] if coin.get('bech32_prefix') is not None else 'NULL'
'"%s"' % coin['bech32_prefix'] if coin.get('bech32_prefix') is not None else 'NULL',
'0x%08x' % (0x80000000 + coin['bip44']),
]

View File

@ -49,6 +49,16 @@ const CoinInfo *coinByAddressType(uint32_t address_type)
return 0;
}
const CoinInfo *coinByCoinType(uint32_t coin_type)
{
for (int i = 0; i < COINS_COUNT; i++) {
if (coin_type == coins[i].coin_type) {
return &(coins[i]);
}
}
return 0;
}
bool coinExtractAddressType(const CoinInfo *coin, const char *addr, uint32_t *address_type)
{
if (!addr) return false;

View File

@ -42,12 +42,14 @@ typedef struct _CoinInfo {
uint32_t xprv_magic;
uint32_t forkid;
const char *bech32_prefix;
uint32_t coin_type;
} CoinInfo;
extern const CoinInfo coins[COINS_COUNT];
const CoinInfo *coinByName(const char *name);
const CoinInfo *coinByAddressType(uint32_t address_type);
const CoinInfo *coinByCoinType(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);