mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-13 19:18:56 +00:00
firmware: use new coin definitions from trezor-common
This commit is contained in:
parent
0ae5e91fcb
commit
e2275a8b83
@ -119,6 +119,6 @@ clean::
|
||||
rm -f $(1).h $(3)
|
||||
endef
|
||||
|
||||
$(eval $(call GENERATE_CODE,coin_info,coins.json,coin_info.c))
|
||||
$(eval $(call GENERATE_CODE,nem_mosaics,nem_mosaics.json,nem_mosaics.c))
|
||||
$(eval $(call GENERATE_CODE,coin_info,defs,coin_info.c))
|
||||
$(eval $(call GENERATE_CODE,nem_mosaics,defs/nem/nem_mosaics.json,nem_mosaics.c))
|
||||
$(eval $(call GENERATE_CODE,bl_data,../bootloader/bootloader.bin))
|
||||
|
@ -63,7 +63,7 @@ def format_string(value):
|
||||
def format_hex(value):
|
||||
if value is None:
|
||||
value = "0"
|
||||
return "0x{:08x}".format(int(value, 16))
|
||||
return "0x{:08x}".format(value)
|
||||
|
||||
|
||||
def prepend_varint(string):
|
||||
@ -78,22 +78,22 @@ def coin_to_struct(coin):
|
||||
("coin_name", format_string(coin["coin_name"])),
|
||||
("coin_shortcut", format_string(" " + coin["coin_shortcut"])),
|
||||
("maxfee_kb", format_number(coin["maxfee_kb"])),
|
||||
("signed_message_header", prepend_varint(coin["signed_message_header"])), # noqa: E501
|
||||
("has_address_type", format_bool(coin["address_type"] is not None)), # noqa: E501
|
||||
("has_address_type_p2sh", format_bool(coin["address_type_p2sh"] is not None)), # noqa: E501
|
||||
("signed_message_header", prepend_varint(coin["signed_message_header"])), # noqa: E501
|
||||
("has_address_type", format_bool(coin["address_type"] is not None)), # noqa: E501
|
||||
("has_address_type_p2sh", format_bool(coin["address_type_p2sh"] is not None)), # noqa: E501
|
||||
("has_segwit", format_bool(coin["segwit"])),
|
||||
("has_forkid", format_bool(coin["forkid"] is not None)),
|
||||
("has_fork_id", format_bool(coin["fork_id"] is not None)),
|
||||
("force_bip143", format_bool(coin["force_bip143"])),
|
||||
("decred", format_bool(coin["decred"])),
|
||||
("address_type", format_number(coin["address_type"])),
|
||||
("address_type_p2sh", format_number(coin["address_type_p2sh"])),
|
||||
("xpub_magic", format_hex(coin["xpub_magic"])),
|
||||
("xprv_magic", format_hex(coin["xprv_magic"])),
|
||||
("forkid", format_number(coin["forkid"])),
|
||||
("fork_id", format_number(coin["fork_id"])),
|
||||
("bech32_prefix", format_string(coin["bech32_prefix"])),
|
||||
("cashaddr_prefix", format_string(coin["cashaddr_prefix"])),
|
||||
("coin_type", "({} | 0x80000000)".format(format_number(coin["bip44"]))), # noqa: E501
|
||||
("curve_name", "{}_NAME".format(coin["curve_name"].upper())), # noqa: E501
|
||||
("coin_type", "({} | 0x80000000)".format(format_number(coin["slip44"]))), # noqa: E501
|
||||
("curve_name", "{}_NAME".format(coin["curve_name"].upper())), # noqa: E501
|
||||
("curve", "&{}_info".format(coin["curve_name"])),
|
||||
))
|
||||
|
||||
@ -118,9 +118,16 @@ if __name__ == "__main__":
|
||||
|
||||
coins = collections.defaultdict(list)
|
||||
|
||||
for coin in json.load(open("coins.json")):
|
||||
firmware = coin["firmware"]
|
||||
coins[firmware].append(coin)
|
||||
support = json.load(open('defs/support.json', 'r'), object_pairs_hook=collections.OrderedDict)
|
||||
defs = support['trezor1'].keys()
|
||||
|
||||
for c in defs:
|
||||
name = c.replace(' ', '_').lower()
|
||||
firmware = 'debug' if name.endswith('_testnet') else 'stable'
|
||||
if name == 'testnet':
|
||||
name = 'bitcoin_testnet'
|
||||
data = json.load(open('defs/coins/%s.json' % name, 'r'))
|
||||
coins[firmware].append(data)
|
||||
|
||||
with open("coin_info.h", "w+") as f:
|
||||
f.write(HEADER_TEMPLATE.format(**{
|
||||
|
@ -34,7 +34,7 @@ typedef struct _CoinInfo {
|
||||
bool has_address_type;
|
||||
bool has_address_type_p2sh;
|
||||
bool has_segwit;
|
||||
bool has_forkid;
|
||||
bool has_fork_id;
|
||||
bool force_bip143;
|
||||
bool decred;
|
||||
// address types > 0xFF represent a two-byte prefix in big-endian order
|
||||
@ -42,7 +42,7 @@ typedef struct _CoinInfo {
|
||||
uint32_t address_type_p2sh;
|
||||
uint32_t xpub_magic;
|
||||
uint32_t xprv_magic;
|
||||
uint32_t forkid;
|
||||
uint32_t fork_id;
|
||||
const char *bech32_prefix;
|
||||
const char *cashaddr_prefix;
|
||||
uint32_t coin_type;
|
||||
|
@ -1 +0,0 @@
|
||||
../vendor/trezor-common/coins.json
|
1
firmware/defs
Symbolic link
1
firmware/defs
Symbolic link
@ -0,0 +1 @@
|
||||
../vendor/trezor-common/defs
|
@ -1 +0,0 @@
|
||||
../vendor/trezor-common/defs/nem/nem_mosaics.json
|
@ -109,7 +109,7 @@ if __name__ == "__main__":
|
||||
sys.path.insert(0, "protob")
|
||||
import types_pb2 as types
|
||||
|
||||
messages = json.load(open("nem_mosaics.json"))
|
||||
messages = json.load(open("defs/nem/nem_mosaics.json"))
|
||||
|
||||
with open("nem_mosaics.h", "w+") as f:
|
||||
f.write(HEADER_TEMPLATE.format(
|
||||
|
@ -702,8 +702,8 @@ static bool signing_check_fee(void) {
|
||||
static uint32_t signing_hash_type(void) {
|
||||
uint32_t hash_type = SIGHASH_ALL;
|
||||
|
||||
if (coin->has_forkid) {
|
||||
hash_type |= (coin->forkid << 8) | SIGHASH_FORKID;
|
||||
if (coin->has_fork_id) {
|
||||
hash_type |= (coin->fork_id << 8) | SIGHASH_FORKID;
|
||||
}
|
||||
|
||||
return hash_type;
|
||||
|
2
vendor/trezor-common
vendored
2
vendor/trezor-common
vendored
@ -1 +1 @@
|
||||
Subproject commit 0c9d67954c871553a7d44575a7a9198cba83df88
|
||||
Subproject commit a0d37a0371aba597d3e0f3f1055adf1a9683a5e4
|
Loading…
Reference in New Issue
Block a user