mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
legacy: refactor check_cointype into a separate function
This commit is contained in:
parent
96c38315df
commit
5359509483
@ -508,6 +508,11 @@ int cryptoIdentityFingerprint(const IdentityType *identity, uint8_t *hash) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool check_cointype(const CoinInfo *coin, uint32_t slip44, bool full) {
|
||||||
|
(void)full;
|
||||||
|
return coin->coin_type == slip44;
|
||||||
|
}
|
||||||
|
|
||||||
bool coin_known_path_check(const CoinInfo *coin, InputScriptType script_type,
|
bool coin_known_path_check(const CoinInfo *coin, InputScriptType script_type,
|
||||||
uint32_t address_n_count, const uint32_t *address_n,
|
uint32_t address_n_count, const uint32_t *address_n,
|
||||||
bool full) {
|
bool full) {
|
||||||
@ -521,7 +526,7 @@ bool coin_known_path_check(const CoinInfo *coin, InputScriptType script_type,
|
|||||||
} else {
|
} else {
|
||||||
valid &= (address_n_count >= 2);
|
valid &= (address_n_count >= 2);
|
||||||
}
|
}
|
||||||
valid &= (address_n[1] == coin->coin_type);
|
valid &= check_cointype(coin, address_n[1], full);
|
||||||
if (full) {
|
if (full) {
|
||||||
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
||||||
valid &= (address_n[3] & 0x80000000) == 0;
|
valid &= (address_n[3] & 0x80000000) == 0;
|
||||||
@ -556,7 +561,7 @@ bool coin_known_path_check(const CoinInfo *coin, InputScriptType script_type,
|
|||||||
} else {
|
} else {
|
||||||
valid &= (address_n_count >= 2);
|
valid &= (address_n_count >= 2);
|
||||||
}
|
}
|
||||||
valid &= (address_n[1] == coin->coin_type);
|
valid &= check_cointype(coin, address_n[1], full);
|
||||||
if (full) {
|
if (full) {
|
||||||
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
||||||
valid &= (address_n[4] & 0x80000000) == 0;
|
valid &= (address_n[4] & 0x80000000) == 0;
|
||||||
@ -574,7 +579,7 @@ bool coin_known_path_check(const CoinInfo *coin, InputScriptType script_type,
|
|||||||
} else {
|
} else {
|
||||||
valid &= (address_n_count >= 2);
|
valid &= (address_n_count >= 2);
|
||||||
}
|
}
|
||||||
valid &= (address_n[1] == coin->coin_type);
|
valid &= check_cointype(coin, address_n[1], full);
|
||||||
if (full) {
|
if (full) {
|
||||||
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
||||||
valid &= (address_n[3] & 0x80000000) == 0;
|
valid &= (address_n[3] & 0x80000000) == 0;
|
||||||
@ -594,7 +599,7 @@ bool coin_known_path_check(const CoinInfo *coin, InputScriptType script_type,
|
|||||||
} else {
|
} else {
|
||||||
valid &= (address_n_count >= 2);
|
valid &= (address_n_count >= 2);
|
||||||
}
|
}
|
||||||
valid &= (address_n[1] == coin->coin_type);
|
valid &= check_cointype(coin, address_n[1], full);
|
||||||
if (full) {
|
if (full) {
|
||||||
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
valid &= (address_n[2] & 0x80000000) == 0x80000000;
|
||||||
valid &= (address_n[3] & 0x80000000) == 0;
|
valid &= (address_n[3] & 0x80000000) == 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user