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:
parent
55641dd8b5
commit
8a62d12217
10
trezorctl
10
trezorctl
@ -582,9 +582,9 @@ def ethereum_sign_message(connect, address, message):
|
|||||||
|
|
||||||
def ethereum_decode_hex(value):
|
def ethereum_decode_hex(value):
|
||||||
if value.startswith('0x') or value.startswith('0X'):
|
if value.startswith('0x') or value.startswith('0X'):
|
||||||
return value[2:].decode('hex')
|
return binascii.unhexlify(value[2:])
|
||||||
else:
|
else:
|
||||||
return value.decode('hex')
|
return binascii.unhexlify(value)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help='Verify message signed with Ethereum address.')
|
@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()
|
client = connect()
|
||||||
address_n = client.expand_path(address)
|
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:
|
if gas_price is None or gas_limit is None or nonce is None:
|
||||||
host, port = host.split(':')
|
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,
|
to_address=to,
|
||||||
from_address=address,
|
from_address=address,
|
||||||
value=('0x%x' % value),
|
value=('0x%x' % value),
|
||||||
data='0x' + data)
|
data='0x%s' % (binascii.hexlify(data).decode()))
|
||||||
|
|
||||||
if nonce is None:
|
if nonce is None:
|
||||||
nonce = eth.eth_getTransactionCount(address)
|
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(
|
transaction = rlp.encode(
|
||||||
(nonce, gas_price, gas_limit, to_address, value, data) + sig)
|
(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:
|
if publish:
|
||||||
tx_hash = eth.eth_sendRawTransaction(tx_hex)
|
tx_hash = eth.eth_sendRawTransaction(tx_hex)
|
||||||
|
Loading…
Reference in New Issue
Block a user