mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
apps.common.signtx: fix outputs for multibyte address prefixes
This commit is contained in:
parent
ea12087de7
commit
cfdd517bf4
@ -312,14 +312,25 @@ def get_tx_hash(w, double: bool, reverse: bool=False) -> bytes:
|
||||
# TX Outputs
|
||||
# ===
|
||||
|
||||
def len_address_type(address_type):
|
||||
if address_type <= 0xFF:
|
||||
return 1
|
||||
if address_type <= 0xFFFF:
|
||||
return 2
|
||||
if address_type <= 0xFFFFFF:
|
||||
return 3
|
||||
# else
|
||||
return 4
|
||||
|
||||
def output_derive_script(o: TxOutputType, coin: CoinType, root) -> bytes:
|
||||
if o.script_type == OutputScriptType.PAYTOADDRESS:
|
||||
ra = output_paytoaddress_extract_raw_address(o, coin, root)
|
||||
return script_paytoaddress_new(ra[1:])
|
||||
at = len_address_type(coin.address_type)
|
||||
return script_paytoaddress_new(ra[at:])
|
||||
elif o.script_type == OutputScriptType.PAYTOSCRIPTHASH:
|
||||
ra = output_paytoaddress_extract_raw_address(o, coin, root, p2sh=True)
|
||||
return script_paytoscripthash_new(ra[1:])
|
||||
at = len_address_type(coin.address_type_p2sh)
|
||||
return script_paytoscripthash_new(ra[at:])
|
||||
elif o.script_type == OutputScriptType.PAYTOOPRETURN:
|
||||
if o.amount == 0:
|
||||
return script_paytoopreturn_new(o.op_return_data)
|
||||
|
Loading…
Reference in New Issue
Block a user