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

apps.common.signtx: rework check_address_type function

This commit is contained in:
Pavol Rusnak 2016-11-15 18:10:27 +01:00
parent e556aea42b
commit ceb4ed8c59
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -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