From d9df63ad890e45d4bfdd2d27857a0ebdf17fa517 Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Tue, 23 Aug 2016 01:14:23 +0200 Subject: [PATCH] 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). --- trezorctl | 7 +++---- trezorlib/client.py | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/trezorctl b/trezorctl index 377813b89..61461f521 100755 --- a/trezorctl +++ b/trezorctl @@ -120,9 +120,6 @@ class Commands(object): from ethjsonrpc.utils import hex_to_dec import rlp - if not args.to: - raise Exception("Please provide to address in hex format") - value = args.value if ' ' in value: value, unit = value.split(' ', 1) @@ -145,6 +142,8 @@ class Commands(object): gas_price = eth.eth_gasPrice() gas_limit = args.gas + if args.data.startswith('0x'): + args.data = args.data[2:] data = binascii.unhexlify(args.data) if not gas_limit: gas_limit = hex_to_dec(eth.eth_estimateGas( @@ -164,7 +163,7 @@ class Commands(object): data=data) 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) if args.publish: diff --git a/trezorlib/client.py b/trezorlib/client.py index 914f30f51..aa6bcf998 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -440,9 +440,11 @@ class ProtocolMixin(object): nonce=int_to_big_endian(nonce), gas_price=int_to_big_endian(gas_price), gas_limit=int_to_big_endian(gas_limit), - to=to, value=int_to_big_endian(value)) + if to: + msg.to = to + if data: msg.data_length = len(data) data, chunk = data[1024:], data[:1024]