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

apps.common.coins: update to return CoinType, not dict (also modify generator)

This commit is contained in:
Pavol Rusnak 2016-11-09 14:46:59 +01:00
parent 25ab4dd2ea
commit 3015045df6
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 90 additions and 113 deletions

View File

@ -1,128 +1,107 @@
from trezor.messages.CoinType import CoinType
# the following list is generated using tools/coins-gen.py # the following list is generated using tools/coins-gen.py
# do not edit manually!
_coins = [ _coins = [
{ CoinType(
'coin_name': 'Bitcoin', coin_name='Bitcoin',
'coin_shortcut': 'BTC', coin_shortcut='BTC',
'maxfee_kb': 100000, address_type=0,
'address_type': 0, maxfee_kb=100000,
'address_type_p2sh': 5, address_type_p2sh=5,
'address_type_p2wpkh': 6, address_type_p2wpkh=6,
'address_type_p2wsh': 10, address_type_p2wsh=10,
'signed_message_header': 'Bitcoin Signed Message:\n', signed_message_header='Bitcoin Signed Message:\n',
'bip44': 0, ),
'xpub_magic': 76067358, CoinType(
'xprv_magic': 76066276, coin_name='Testnet',
}, coin_shortcut='TEST',
{ address_type=111,
'coin_name': 'Testnet', maxfee_kb=10000000,
'coin_shortcut': 'TEST', address_type_p2sh=196,
'maxfee_kb': 10000000, address_type_p2wpkh=3,
'address_type': 111, address_type_p2wsh=40,
'address_type_p2sh': 196, signed_message_header='Bitcoin Signed Message:\n',
'address_type_p2wpkh': 3, ),
'address_type_p2wsh': 40, CoinType(
'signed_message_header': 'Bitcoin Signed Message:\n', coin_name='Namecoin',
'bip44': 1, coin_shortcut='NMC',
'xpub_magic': 70617039, address_type=52,
'xprv_magic': 70615956, maxfee_kb=10000000,
}, address_type_p2sh=5,
{ address_type_p2wpkh=None,
'coin_name': 'Namecoin', address_type_p2wsh=None,
'coin_shortcut': 'NMC', signed_message_header='Namecoin Signed Message:\n',
'maxfee_kb': 10000000, ),
'address_type': 52, CoinType(
'address_type_p2sh': 5, coin_name='Litecoin',
'address_type_p2wpkh': None, coin_shortcut='LTC',
'address_type_p2wsh': None, address_type=48,
'signed_message_header': 'Namecoin Signed Message:\n', maxfee_kb=1000000,
'bip44': 7, address_type_p2sh=5,
'xpub_magic': 27108450, address_type_p2wpkh=None,
'xprv_magic': 27106558, address_type_p2wsh=None,
}, signed_message_header='Litecoin Signed Message:\n',
{ ),
'coin_name': 'Litecoin', CoinType(
'coin_shortcut': 'LTC', coin_name='Dogecoin',
'maxfee_kb': 1000000, coin_shortcut='DOGE',
'address_type': 48, address_type=30,
'address_type_p2sh': 5, maxfee_kb=1000000000,
'address_type_p2wpkh': None, address_type_p2sh=22,
'address_type_p2wsh': None, address_type_p2wpkh=None,
'signed_message_header': 'Litecoin Signed Message:\n', address_type_p2wsh=None,
'bip44': 2, signed_message_header='Dogecoin Signed Message:\n',
'xpub_magic': 27108450, ),
'xprv_magic': 27106558, CoinType(
}, coin_name='Dash',
{ coin_shortcut='DASH',
'coin_name': 'Dogecoin', address_type=76,
'coin_shortcut': 'DOGE', maxfee_kb=100000,
'maxfee_kb': 1000000000, address_type_p2sh=16,
'address_type': 30, address_type_p2wpkh=None,
'address_type_p2sh': 22, address_type_p2wsh=None,
'address_type_p2wpkh': None, signed_message_header='DarkCoin Signed Message:\n',
'address_type_p2wsh': None, ),
'signed_message_header': 'Dogecoin Signed Message:\n', CoinType(
'bip44': 3, coin_name='Zcash',
'xpub_magic': 49990397, coin_shortcut='ZEC',
'xprv_magic': 49988504, address_type=7352,
}, maxfee_kb=1000000,
{ address_type_p2sh=7357,
'coin_name': 'Dash', address_type_p2wpkh=None,
'coin_shortcut': 'DASH', address_type_p2wsh=None,
'maxfee_kb': 100000, signed_message_header='Zcash Signed Message:\n',
'address_type': 76, ),
'address_type_p2sh': 16, CoinType(
'address_type_p2wpkh': None, coin_name='Zcash Testnet',
'address_type_p2wsh': None, coin_shortcut='TAZ',
'signed_message_header': 'DarkCoin Signed Message:\n', address_type=7461,
'bip44': 5, maxfee_kb=10000000,
'xpub_magic': 50221772, address_type_p2sh=7354,
'xprv_magic': 50221816, address_type_p2wpkh=None,
}, address_type_p2wsh=None,
{ signed_message_header='Zcash Signed Message:\n',
'coin_name': 'Zcash', ),
'coin_shortcut': 'ZEC',
'maxfee_kb': 1000000,
'address_type': 7352,
'address_type_p2sh': 7357,
'address_type_p2wpkh': None,
'address_type_p2wsh': None,
'signed_message_header': 'Zcash Signed Message:\n',
'bip44': 133,
'xpub_magic': 76067358,
'xprv_magic': 76066276,
},
{
'coin_name': 'Zcash Testnet',
'coin_shortcut': 'TAZ',
'maxfee_kb': 10000000,
'address_type': 7461,
'address_type_p2sh': 7354,
'address_type_p2wpkh': None,
'address_type_p2wsh': None,
'signed_message_header': 'Zcash Signed Message:\n',
'bip44': 1,
'xpub_magic': 70617039,
'xprv_magic': 70615956,
},
] ]
def by_shortcut(shortcut): def by_shortcut(shortcut):
for c in _coins: for c in _coins:
if c['coin_shortcut'] == shortcut: if c.coin_shortcut == shortcut:
return c return c
raise Exception('Unknown coin shortcut "%s"' % shortcut) raise Exception('Unknown coin shortcut "%s"' % shortcut)
def by_name(name): def by_name(name):
for c in _coins: for c in _coins:
if c['coin_name'] == name: if c.coin_name == name:
return c return c
raise Exception('Unknown coin name "%s"' % name) raise Exception('Unknown coin name "%s"' % name)
def by_address_type(version): def by_address_type(version):
for c in _coins: for c in _coins:
if c['address_type'] == version: if c.address_type == version:
return c return c
raise Exception('Unknown coin address type %d' % version) raise Exception('Unknown coin address type %d' % version)

View File

@ -7,12 +7,10 @@ coins = json.load(open('../../trezor-common/coins.json', 'r'))
print('_coins = [') print('_coins = [')
for c in coins: for c in coins:
d = OrderedDict() d = OrderedDict()
for n in ['coin_name', 'coin_shortcut', 'maxfee_kb', 'address_type', 'address_type_p2sh', 'address_type_p2wpkh', 'address_type_p2wsh', 'signed_message_header', 'bip44']: for n in ['coin_name', 'coin_shortcut', 'address_type', 'maxfee_kb', 'address_type_p2sh', 'address_type_p2wpkh', 'address_type_p2wsh', 'signed_message_header']:
d[n] = c[n] d[n] = c[n]
d['xpub_magic'] = int(c['xpub_magic'], 16) print(' CoinType(')
d['xprv_magic'] = int(c['xprv_magic'], 16)
print(' {')
for k in d: for k in d:
print(' %s: %s,' % (repr(k), repr(d[k]))) print(' %s=%s,' % (k, repr(d[k])))
print(' },') print(' ),')
print(']\n') print(']\n')