mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 07:18:09 +00:00
fix ethereum_sign_tx
This commit is contained in:
parent
6a1564ba87
commit
78c6328b36
@ -423,7 +423,7 @@ class ProtocolMixin(object):
|
|||||||
n = self._convert_prime(n)
|
n = self._convert_prime(n)
|
||||||
return self.call(proto.EthereumGetAddress(address_n=n, show_display=show_display))
|
return self.call(proto.EthereumGetAddress(address_n=n, show_display=show_display))
|
||||||
|
|
||||||
def ethereum_sign_tx(self, n, nonce, gas_price, gas_limit, to, value, data=''):
|
def ethereum_sign_tx(self, n, nonce, gas_price, gas_limit, to, value, data=None):
|
||||||
from rlp.utils import int_to_big_endian
|
from rlp.utils import int_to_big_endian
|
||||||
|
|
||||||
n = self._convert_prime(n)
|
n = self._convert_prime(n)
|
||||||
@ -431,23 +431,28 @@ class ProtocolMixin(object):
|
|||||||
try:
|
try:
|
||||||
self.transport.session_begin()
|
self.transport.session_begin()
|
||||||
|
|
||||||
response = self.call(proto.EthereumSignTx(
|
msg = proto.EthereumSignTx(
|
||||||
address_n=n,
|
address_n=n,
|
||||||
nonce=int_to_big_endian(nonce),
|
nonce=int_to_big_endian(nonce),
|
||||||
gas_price=int_to_big_endian(gas_price),
|
gas_price=int_to_big_endian(gas_price),
|
||||||
gas_limit=int_to_big_endian(gas_limit),
|
gas_limit=int_to_big_endian(gas_limit),
|
||||||
to=to,
|
to=to,
|
||||||
value=int_to_big_endian(value)))
|
value=int_to_big_endian(value))
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
|
msg.data_length = len(data)
|
||||||
data, chunk = data[1024:], data[:1024]
|
data, chunk = data[1024:], data[:1024]
|
||||||
response.data_initial_chunk = chunk
|
msg.data_initial_chunk = chunk
|
||||||
response.data_length = len(data)
|
|
||||||
|
response = self.call(msg)
|
||||||
|
|
||||||
while response.HasField('data_length'):
|
while response.HasField('data_length'):
|
||||||
data, chunk = data[1024:], data[:1024]
|
data_length = response.data_length
|
||||||
|
data, chunk = data[data_length:], data[:data_length]
|
||||||
response = self.call(proto.EthereumTxAck(data_chunk=chunk))
|
response = self.call(proto.EthereumTxAck(data_chunk=chunk))
|
||||||
|
|
||||||
return response.signature_v, response.signature_r, response.signature_s
|
return response.signature_v, response.signature_r, response.signature_s
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.transport.session_end()
|
self.transport.session_end()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user