1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

Update ethereum_sign_tx to python3 (#227)

This commit is contained in:
Jochen Hoenicke 2018-03-05 13:09:57 +01:00 committed by Pavol Rusnak
parent 55641dd8b5
commit 8a62d12217

View File

@ -582,9 +582,9 @@ def ethereum_sign_message(connect, address, message):
def ethereum_decode_hex(value):
if value.startswith('0x') or value.startswith('0X'):
return value[2:].decode('hex')
return binascii.unhexlify(value[2:])
else:
return value.decode('hex')
return binascii.unhexlify(value)
@cli.command(help='Verify message signed with Ethereum address.')
@ -731,7 +731,7 @@ def ethereum_sign_tx(connect, host, chain_id, address, value, gas_limit, gas_pri
client = connect()
address_n = client.expand_path(address)
address = '0x%s' % (binascii.hexlify(client.ethereum_get_address(address_n)),)
address = '0x%s' % (binascii.hexlify(client.ethereum_get_address(address_n)).decode())
if gas_price is None or gas_limit is None or nonce is None:
host, port = host.split(':')
@ -749,7 +749,7 @@ def ethereum_sign_tx(connect, host, chain_id, address, value, gas_limit, gas_pri
to_address=to,
from_address=address,
value=('0x%x' % value),
data='0x' + data)
data='0x%s' % (binascii.hexlify(data).decode()))
if nonce is None:
nonce = eth.eth_getTransactionCount(address)
@ -766,7 +766,7 @@ def ethereum_sign_tx(connect, host, chain_id, address, value, gas_limit, gas_pri
transaction = rlp.encode(
(nonce, gas_price, gas_limit, to_address, value, data) + sig)
tx_hex = '0x%s' % binascii.hexlify(transaction)
tx_hex = '0x%s' % binascii.hexlify(transaction).decode()
if publish:
tx_hash = eth.eth_sendRawTransaction(tx_hex)