diff --git a/src/apps/common/signtx.py b/src/apps/common/signtx.py index 196881d4f6..76421bc9e3 100644 --- a/src/apps/common/signtx.py +++ b/src/apps/common/signtx.py @@ -308,19 +308,13 @@ def output_derive_script(o: TxOutputType, coin: CoinType, root) -> bytes: def check_address_type(address_type, raw_address): if address_type <= 0xFF: - return raw_address[0] == address_type + return address_type == raw_address[0] if address_type <= 0xFFFF: - return raw_address[0] == (address_type >> 8) \ - and raw_address[1] == (address_type & 0xFF) + return address_type == (raw_address[0] << 8) | raw_address[1] if address_type <= 0xFFFFFF: - return raw_address[0] == (address_type >> 16) \ - and raw_address[1] == ((address_type >> 8) & 0xFF) \ - and raw_address[2] == (address_type & 0xFF) - return raw_address[0] == (address_type >> 24) \ - and raw_address[1] == ((address_type >> 16) & 0xFF) \ - and raw_address[2] == ((address_type >> 8) & 0xFF) \ - and raw_address[3] == (address_type & 0xFF) - + return address_type == (raw_address[0] << 16) | (raw_address[1] << 8) | raw_address[2] + # else + return address_type == (raw_address[0] << 24) | (raw_address[1] << 16) | (raw_address[2] << 8) | raw_address[3] def output_paytoaddress_extract_raw_address(o: TxOutputType, coin: CoinType, root, p2sh=False) -> bytes: address_type = coin.address_type_p2sh if p2sh else coin.address_type