1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-07 00:28:45 +00:00

firmware: support also testnet coins in stable firmware

This commit is contained in:
Pavol Rusnak 2018-06-21 15:22:56 +02:00
parent 01933e68fb
commit 156fab867b
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -12,11 +12,7 @@ HEADER_TEMPLATE = """
#include "coins.h" #include "coins.h"
#if DEBUG_LINK #define COINS_COUNT ({count})
#define COINS_COUNT ({stable} + {debug})
#else
#define COINS_COUNT ({stable})
#endif
extern const CoinInfo coins[COINS_COUNT]; extern const CoinInfo coins[COINS_COUNT];
@ -32,10 +28,7 @@ CODE_TEMPLATE = """
#include "secp256k1.h" #include "secp256k1.h"
const CoinInfo coins[COINS_COUNT] = {{ const CoinInfo coins[COINS_COUNT] = {{
{stable} {coins}
#if DEBUG_LINK
{debug}
#endif
}}; }};
""".lstrip() """.lstrip()
@ -117,25 +110,20 @@ def format_coins(coins):
if __name__ == "__main__": if __name__ == "__main__":
os.chdir(os.path.abspath(os.path.dirname(__file__))) os.chdir(os.path.abspath(os.path.dirname(__file__)))
coins = collections.defaultdict(list) coins = []
support = json.load(open('defs/support.json', 'r'), object_pairs_hook=collections.OrderedDict) support = json.load(open('defs/support.json', 'r'), object_pairs_hook=collections.OrderedDict)
defs = support['trezor1'].keys() defs = support['trezor1'].keys()
for c in defs: for c in defs:
name = c.replace(' ', '_').lower() name = c.replace(' ', '_').lower()
firmware = 'debug' if name.endswith('_testnet') else 'stable'
if name == 'testnet': if name == 'testnet':
name = 'bitcoin_testnet' name = 'bitcoin_testnet'
data = json.load(open('defs/coins/%s.json' % name, 'r')) data = json.load(open('defs/coins/%s.json' % name, 'r'))
coins[firmware].append(data) coins.append(data)
with open("coin_info.h", "w+") as f: with open("coin_info.h", "w+") as f:
f.write(HEADER_TEMPLATE.format(**{ f.write(HEADER_TEMPLATE.format(count=len(coins)))
k: format_number(len(v)) for k, v in coins.items()
}))
with open("coin_info.c", "w+") as f: with open("coin_info.c", "w+") as f:
f.write(CODE_TEMPLATE.format(**{ f.write(CODE_TEMPLATE.format(coins=format_coins(coins)))
k: format_coins(v) for k, v in coins.items()
}))