1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-03 12:00:59 +00:00

tools/cointool: add check for segwit fields

This commit is contained in:
Pavol Rusnak 2019-02-12 10:56:34 +01:00
parent ba562876bd
commit aa64119b96
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 42 additions and 2 deletions

View File

@ -14,8 +14,8 @@
"hash_genesis_block": "00000d23fa0fc52c90893adb1181c9ddffb6c797a3e41864b9a23aa2f2981fe3",
"xprv_magic": 76066276,
"xpub_magic": 76067358,
"xpub_magic_segwit_p2sh": 77429938,
"xpub_magic_segwit_native": 78792518,
"xpub_magic_segwit_p2sh": null,
"xpub_magic_segwit_native": null,
"bech32_prefix": null,
"cashaddr_prefix": null,
"slip44": 289,

View File

@ -411,6 +411,42 @@ def check_key_uniformity(coins):
return False
def check_segwit(coins):
for coin in coins:
segwit = coin["segwit"]
if segwit:
if coin["xpub_magic_segwit_native"] is None:
print_log(
logging.WARNING,
coin["name"],
"segwit is True => xpub_magic_segwit_native should be set",
)
# return False
if coin["xpub_magic_segwit_p2sh"] is None:
print_log(
logging.WARNING,
coin["name"],
"segwit is True => xpub_magic_segwit_p2sh should be set",
)
# return False
else:
if coin["xpub_magic_segwit_native"] is not None:
print_log(
logging.ERROR,
coin["name"],
"segwit is False => xpub_magic_segwit_native should NOT be set",
)
return False
if coin["xpub_magic_segwit_p2sh"] is not None:
print_log(
logging.ERROR,
coin["name"],
"segwit is False => xpub_magic_segwit_p2sh should NOT be set",
)
return False
return True
# ====== coindefs generators ======
@ -564,6 +600,10 @@ def check(backend, icons, show_duplicates):
if not check_backends(defs.bitcoin):
all_checks_passed = False
print("Checking segwit fields...")
if not check_segwit(defs.bitcoin):
all_checks_passed = False
print("Checking key uniformity...")
for cointype, coinlist in defs.items():
if cointype in ("erc20", "nem"):