1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00
trezor-firmware/tools/codegen/gen_coins.py

40 lines
937 B
Python
Raw Normal View History

#!/usr/bin/env python3
import json
2016-11-09 13:52:43 +00:00
fields = [
'coin_name',
'coin_shortcut',
'address_type',
'address_type_p2sh',
2017-05-12 20:51:07 +00:00
'maxfee_kb',
2016-11-09 13:52:43 +00:00
'signed_message_header',
2017-11-09 14:37:22 +00:00
'xpub_magic',
'bech32_prefix',
'cashaddr_prefix',
2017-04-26 13:46:08 +00:00
'segwit',
'fork_id',
2018-02-08 17:58:03 +00:00
'force_bip143',
'version_group_id',
2016-11-09 13:52:43 +00:00
]
support = json.load(open('../../vendor/trezor-common/defs/support.json', 'r'))
coins = support['trezor2'].keys()
2016-11-11 17:11:37 +00:00
print('COINS = [')
for c in coins:
print(' CoinInfo(')
name = c.replace(' ', '_').lower()
if name == 'testnet':
name = 'bitcoin_testnet'
data = json.load(open('../../vendor/trezor-common/defs/coins/%s.json' % name, 'r'))
2016-11-09 13:52:43 +00:00
for n in fields:
if n in ['xpub_magic', 'version_group_id']:
v = '0x%08x' % data[n] if data[n] is not None else 'None'
else:
v = repr(data[n])
print(' %s=%s,' % (n, v))
print(' ),')
print(']')