apps.common.signtx: fix outputs for multibyte address prefixes

pull/25/head
Pavol Rusnak 8 years ago
parent ea12087de7
commit cfdd517bf4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -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…
Cancel
Save