mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-30 03:18:20 +00:00
Allow leading 0x in data. Handle new contracts.
Specify 0x or "" as destination to create a new contract. Leading 0x in data is just ignored (data must always be given in hex).
This commit is contained in:
parent
29154811bd
commit
d9df63ad89
@ -120,9 +120,6 @@ class Commands(object):
|
|||||||
from ethjsonrpc.utils import hex_to_dec
|
from ethjsonrpc.utils import hex_to_dec
|
||||||
import rlp
|
import rlp
|
||||||
|
|
||||||
if not args.to:
|
|
||||||
raise Exception("Please provide to address in hex format")
|
|
||||||
|
|
||||||
value = args.value
|
value = args.value
|
||||||
if ' ' in value:
|
if ' ' in value:
|
||||||
value, unit = value.split(' ', 1)
|
value, unit = value.split(' ', 1)
|
||||||
@ -145,6 +142,8 @@ class Commands(object):
|
|||||||
|
|
||||||
gas_price = eth.eth_gasPrice()
|
gas_price = eth.eth_gasPrice()
|
||||||
gas_limit = args.gas
|
gas_limit = args.gas
|
||||||
|
if args.data.startswith('0x'):
|
||||||
|
args.data = args.data[2:]
|
||||||
data = binascii.unhexlify(args.data)
|
data = binascii.unhexlify(args.data)
|
||||||
if not gas_limit:
|
if not gas_limit:
|
||||||
gas_limit = hex_to_dec(eth.eth_estimateGas(
|
gas_limit = hex_to_dec(eth.eth_estimateGas(
|
||||||
@ -164,7 +163,7 @@ class Commands(object):
|
|||||||
data=data)
|
data=data)
|
||||||
|
|
||||||
transaction = rlp.encode(
|
transaction = rlp.encode(
|
||||||
(nonce, gas_price, gas_limit, hex_to_dec(args.to), 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)
|
||||||
|
|
||||||
if args.publish:
|
if args.publish:
|
||||||
|
@ -440,9 +440,11 @@ class ProtocolMixin(object):
|
|||||||
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,
|
|
||||||
value=int_to_big_endian(value))
|
value=int_to_big_endian(value))
|
||||||
|
|
||||||
|
if to:
|
||||||
|
msg.to = to
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
msg.data_length = len(data)
|
msg.data_length = len(data)
|
||||||
data, chunk = data[1024:], data[:1024]
|
data, chunk = data[1024:], data[:1024]
|
||||||
|
Loading…
Reference in New Issue
Block a user