diff --git a/firmware/coins-gen.py b/firmware/coins-gen.py new file mode 100755 index 0000000000..d3109ec8d1 --- /dev/null +++ b/firmware/coins-gen.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +import json + +coins = json.load(open('../vendor/trezor-common/coins.json', 'r')) + +fields = [] + +for c in coins: + fields.append([ + 'true' if c['coin_name'] is not None else 'false', + '"%s"' % c['coin_name'] if c['coin_name'] is not None else 'NULL', + + 'true' if c['coin_shortcut'] is not None else 'false', + '"%s"' % c['coin_shortcut'] if c['coin_shortcut'] is not None else 'NULL', + + 'true' if c['address_type'] is not None else 'false', + '%d' % c['address_type'] if c['address_type'] is not None else '0', + + 'true' if c['maxfee_kb'] is not None else 'false', + '%d' % c['maxfee_kb'] if c['maxfee_kb'] is not None else '0', + + 'true' if c['address_type_p2sh'] is not None else 'false', + '%d' % c['address_type_p2sh'] if c['address_type_p2sh'] is not None else '0', + + 'true' if c['address_type_p2wpkh'] is not None else 'false', + '%d' % c['address_type_p2wpkh'] if c['address_type_p2wpkh'] is not None else '0', + + 'true' if c['address_type_p2wsh'] is not None else 'false', + '%d' % c['address_type_p2wsh'] if c['address_type_p2wsh'] is not None else '0', + + 'true' if c['signed_message_header'] is not None else 'false', + '"\\x%02x" "%s"' % (len(c['signed_message_header']), c['signed_message_header'].replace('\n', '\\n')) if c['signed_message_header'] is not None else 'NULL', + ]) + +for j in range(len(fields[0])): + l = max([len(x[j]) for x in fields]) + 1 + for i in range(len(fields)): + if fields[i][j][0] in '0123456789': + fields[i][j] = (fields[i][j] + ',').rjust(l) + else: + fields[i][j] = (fields[i][j] + ',').ljust(l) + +for row in fields: + print('\t{' + ' '.join(row) + ' },') diff --git a/firmware/coins.c b/firmware/coins.c index 0dfe09e6aa..5c862f80a2 100644 --- a/firmware/coins.c +++ b/firmware/coins.c @@ -24,14 +24,14 @@ // 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, 100000, true, 5, true, 6, true, 10, true, "\x18" "Bitcoin Signed Message:\n"}, - {true, "Testnet", true, "TEST", true, 111, true, 10000000, true, 196, true, 3, true, 40, true, "\x18" "Bitcoin Signed Message:\n"}, - {true, "Namecoin", true, "NMC", true, 52, true, 10000000, true, 5, false, 0, false, 0, true, "\x19" "Namecoin Signed Message:\n"}, - {true, "Litecoin", true, "LTC", true, 48, true, 1000000, true, 5, false, 0, false, 0, true, "\x19" "Litecoin Signed Message:\n"}, - {true, "Dogecoin", true, "DOGE", true, 30, true, 1000000000, true, 22, false, 0, false, 0, true, "\x19" "Dogecoin Signed Message:\n"}, - {true, "Dash", true, "DASH", true, 76, true, 100000, true, 16, false, 0, false, 0, true, "\x19" "DarkCoin Signed Message:\n"}, - {true, "Zcash", true, "ZEC", true, 0x1CBD, true, 1000000, true, 0x1CB8, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n"}, - {true, "Zcash Testnet", true, "TAZ", true, 0x1D25, true, 1000000, true, 0x1CBA, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n"}, + {true, "Bitcoin", true, "BTC", true, 0, true, 100000, true, 5, true, 6, true, 10, true, "\x18" "Bitcoin Signed Message:\n", }, + {true, "Testnet", true, "TEST", true, 111, true, 10000000, true, 196, true, 3, true, 40, true, "\x18" "Bitcoin Signed Message:\n", }, + {true, "Namecoin", true, "NMC", true, 52, true, 10000000, true, 5, false, 0, false, 0, true, "\x19" "Namecoin Signed Message:\n", }, + {true, "Litecoin", true, "LTC", true, 48, true, 1000000, true, 5, false, 0, false, 0, true, "\x19" "Litecoin Signed Message:\n", }, + {true, "Dogecoin", true, "DOGE", true, 30, true, 1000000000, true, 22, false, 0, false, 0, true, "\x19" "Dogecoin Signed Message:\n", }, + {true, "Dash", true, "DASH", true, 76, true, 100000, true, 16, false, 0, false, 0, true, "\x19" "DarkCoin Signed Message:\n", }, + {true, "Zcash", true, "ZEC", true, 7352, true, 1000000, true, 7357, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", }, + {true, "Zcash Testnet", true, "TAZ", true, 7461, true, 10000000, true, 7354, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", }, }; const CoinType *coinByShortcut(const char *shortcut)