1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

tools/cointool: collisions in SLIP44 should be fatal (if not testnet)

This commit is contained in:
Pavol Rusnak 2018-12-17 23:11:30 +01:00
parent 5f24bc927f
commit 5b31341c6d
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -210,7 +210,7 @@ def check_btc(coins):
coin_strings.append(prefix + hl)
return ", ".join(coin_strings)
def print_collision_buckets(buckets, prefix, maxlevel=logging.ERROR):
def print_collision_buckets(buckets, prefix, maxlevel=logging.ERROR, strict=False):
"""Intelligently print collision buckets.
For each bucket, if there are any collision with a mainnet, print it.
@ -233,7 +233,7 @@ def check_btc(coins):
supported_networks = [c for c in bucket if not c.get("unsupported")]
if len(mainnets) > 1:
if have_bitcoin and len(supported_networks) > 1:
if (have_bitcoin or strict) and len(supported_networks) > 1:
# ANY collision with Bitcoin is bad
level = maxlevel
failed = True
@ -243,14 +243,14 @@ def check_btc(coins):
else:
# collision between some unsupported networks is OK
level = logging.INFO
print_log(level, "prefix {}:".format(key), collision_str(bucket))
print_log(level, "{} {}:".format(prefix, key), collision_str(bucket))
return failed
# slip44 collisions
print("Checking SLIP44 prefix collisions...")
print("Checking SLIP44 values collisions...")
slip44 = find_collisions(coins, "slip44")
if print_collision_buckets(slip44, "key"):
if print_collision_buckets(slip44, "value", strict=True):
check_passed = False
# only check address_type on coins that don't use cashaddr