From 5a47bb1f28a7c5593ad65f9f52d735754bb2e6c8 Mon Sep 17 00:00:00 2001 From: ConnorMac Date: Wed, 1 Aug 2018 19:16:11 +0200 Subject: [PATCH 1/7] Use blake2b hash for privateKey gen --- eth_account/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eth_account/account.py b/eth_account/account.py index d797005..1513a18 100644 --- a/eth_account/account.py +++ b/eth_account/account.py @@ -27,6 +27,10 @@ to_bytes, to_int, ) +from eth_utils import ( + blake2b +) + from hexbytes import ( HexBytes, ) @@ -81,7 +85,7 @@ def create(self, extra_entropy=''): # but without the private key argument ''' extra_key_bytes = text_if_str(to_bytes, extra_entropy) - key_bytes = keccak(os.urandom(32) + extra_key_bytes) + key_bytes = blake2b(os.urandom(32) + extra_key_bytes) return self.privateKeyToAccount(key_bytes) @staticmethod From 4f90603ffd948cc1af143723818ca0b388ae273a Mon Sep 17 00:00:00 2001 From: ConnorMac Date: Wed, 8 Aug 2018 21:54:59 +0200 Subject: [PATCH 2/7] Working on rlp encoding --- eth_account/account.py | 6 ++++-- eth_account/internal/signing.py | 17 ++++++++++++----- eth_account/internal/transactions.py | 27 ++++++++++++++++++--------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/eth_account/account.py b/eth_account/account.py index 1513a18..98928b7 100644 --- a/eth_account/account.py +++ b/eth_account/account.py @@ -86,6 +86,7 @@ def create(self, extra_entropy=''): ''' extra_key_bytes = text_if_str(to_bytes, extra_entropy) key_bytes = blake2b(os.urandom(32) + extra_key_bytes) + print(key_bytes) return self.privateKeyToAccount(key_bytes) @staticmethod @@ -430,6 +431,7 @@ def signTransaction(self, transaction_dict, private_key): else: sanitized_transaction = transaction_dict + print(sanitized_transaction) # sign transaction ( v, @@ -437,8 +439,8 @@ def signTransaction(self, transaction_dict, private_key): s, rlp_encoded, ) = sign_transaction_dict(account._key_obj, sanitized_transaction) - - transaction_hash = keccak(rlp_encoded) + print(rlp_encoded) + transaction_hash = blake2b(rlp_encoded, digest_size=32) return AttributeDict({ 'rawTransaction': HexBytes(rlp_encoded), diff --git a/eth_account/internal/signing.py b/eth_account/internal/signing.py index 5cad567..8040c6b 100644 --- a/eth_account/internal/signing.py +++ b/eth_account/internal/signing.py @@ -20,7 +20,9 @@ def sign_transaction_dict(eth_key, transaction_dict): # generate RLP-serializable transaction, with defaults filled + print('DOING THE THING') unsigned_transaction = serializable_unsigned_transaction_from_dict(transaction_dict) + print(unsigned_transaction) transaction_hash = unsigned_transaction.hash() @@ -31,11 +33,15 @@ def sign_transaction_dict(eth_key, transaction_dict): chain_id = unsigned_transaction.v # sign with private key - (v, r, s) = sign_transaction_hash(eth_key, transaction_hash, chain_id) - + (v, r, s, sign_bytes) = sign_transaction_hash(eth_key, transaction_hash, chain_id) + print(v) + print(r) + print(s) + print('sig bytes') + print(sign_bytes) # serialize transaction with rlp - encoded_transaction = encode_transaction(unsigned_transaction, vrs=(v, r, s)) - + encoded_transaction = encode_transaction(unsigned_transaction, vrs=(v, r, s, sign_bytes)) + print(encoded_transaction) return (v, r, s, encoded_transaction) @@ -117,8 +123,9 @@ def to_eth_v(v_raw, chain_id=None): def sign_transaction_hash(account, transaction_hash, chain_id): signature = account.sign_msg_hash(transaction_hash) (v_raw, r, s) = signature.vrs + sig_bytes = signature.signature_bytes v = to_eth_v(v_raw, chain_id) - return (v, r, s) + return (v, r, s, sig_bytes) def _pad_to_eth_word(bytes_val): diff --git a/eth_account/internal/transactions.py b/eth_account/internal/transactions.py index 6261a25..2c6c61e 100644 --- a/eth_account/internal/transactions.py +++ b/eth_account/internal/transactions.py @@ -1,4 +1,5 @@ import itertools +import time from cytoolz import ( curry, @@ -26,6 +27,7 @@ import rlp from rlp.sedes import ( Binary, + BigEndianInt, big_endian_int, binary, ) @@ -48,9 +50,12 @@ def serializable_unsigned_transaction_from_dict(transaction_dict): def encode_transaction(unsigned_transaction, vrs): - (v, r, s) = vrs + (v, r, s, sig_bytes) = vrs + print(unsigned_transaction) + print(unsigned_transaction.as_dict()) chain_naive_transaction = dissoc(unsigned_transaction.as_dict(), 'v', 'r', 's') - signed_transaction = Transaction(v=v, r=r, s=s, **chain_naive_transaction) + signed_transaction = Transaction(s=sig_bytes, **chain_naive_transaction) + print(signed_transaction.as_dict()) return rlp.encode(signed_transaction) @@ -81,12 +86,14 @@ def is_none(val): 'value': 0, 'data': b'', 'chainId': None, + 'tx_type': 0, + 'timestamp': int(time.time()) } TRANSACTION_FORMATTERS = { 'nonce': hexstr_if_str(to_int), - 'gasPrice': hexstr_if_str(to_int), 'gas': hexstr_if_str(to_int), + 'gasPrice': hexstr_if_str(to_int), 'to': apply_one_of_formatters(( (is_string, hexstr_if_str(to_bytes)), (is_bytes, identity), @@ -116,6 +123,8 @@ def is_none(val): 'to', 'value', 'data', + 'tx_type', + 'timestamp', 'chainId', # set chainId to None if you want a transaction that can be replayed across networks } @@ -156,19 +165,19 @@ def fill_transaction_defaults(transaction): UNSIGNED_TRANSACTION_FIELDS = ( ('nonce', big_endian_int), - ('gasPrice', big_endian_int), - ('gas', big_endian_int), - ('to', Binary.fixed_length(20, allow_empty=True)), + ('to', Binary.fixed_length(32, allow_empty=True)), ('value', big_endian_int), ('data', binary), + ('timestamp', big_endian_int), + ('gas', big_endian_int), + ('gasPrice', big_endian_int), + ('tx_type', big_endian_int), ) class Transaction(HashableRLP): fields = UNSIGNED_TRANSACTION_FIELDS + ( - ('v', big_endian_int), - ('r', big_endian_int), - ('s', big_endian_int), + ('s', binary), ) From d0be352322812efd06c247db735b9c28382849f3 Mon Sep 17 00:00:00 2001 From: ConnorMac Date: Fri, 10 Aug 2018 18:02:08 +0200 Subject: [PATCH 3/7] WIP combine public key bytes and signature before RLP encoding the sig --- eth_account/internal/signing.py | 14 +++++++------ eth_account/internal/transactions.py | 30 +++++++++++++++++++--------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/eth_account/internal/signing.py b/eth_account/internal/signing.py index 8040c6b..d1039b2 100644 --- a/eth_account/internal/signing.py +++ b/eth_account/internal/signing.py @@ -33,14 +33,15 @@ def sign_transaction_dict(eth_key, transaction_dict): chain_id = unsigned_transaction.v # sign with private key - (v, r, s, sign_bytes) = sign_transaction_hash(eth_key, transaction_hash, chain_id) - print(v) - print(r) - print(s) + (v, r, s, sign_bytes, total_sig) = sign_transaction_hash(eth_key, transaction_hash, chain_id) + pub_key = bytes(eth_key.public_key.to_bytes()) + print('PUBLIC KEY') + print(pub_key) print('sig bytes') print(sign_bytes) # serialize transaction with rlp - encoded_transaction = encode_transaction(unsigned_transaction, vrs=(v, r, s, sign_bytes)) + sign_bytes = pub_key + sign_bytes + encoded_transaction = encode_transaction(unsigned_transaction, vrs=(v, r, s, sign_bytes, total_sig)) print(encoded_transaction) return (v, r, s, encoded_transaction) @@ -124,8 +125,9 @@ def sign_transaction_hash(account, transaction_hash, chain_id): signature = account.sign_msg_hash(transaction_hash) (v_raw, r, s) = signature.vrs sig_bytes = signature.signature_bytes + sig_raw = signature.total_sig v = to_eth_v(v_raw, chain_id) - return (v, r, s, sig_bytes) + return (v, r, s, sig_bytes, sig_raw) def _pad_to_eth_word(bytes_val): diff --git a/eth_account/internal/transactions.py b/eth_account/internal/transactions.py index 2c6c61e..2186f34 100644 --- a/eth_account/internal/transactions.py +++ b/eth_account/internal/transactions.py @@ -50,10 +50,13 @@ def serializable_unsigned_transaction_from_dict(transaction_dict): def encode_transaction(unsigned_transaction, vrs): - (v, r, s, sig_bytes) = vrs + (v, r, s, sig_bytes, total_sig) = vrs print(unsigned_transaction) print(unsigned_transaction.as_dict()) chain_naive_transaction = dissoc(unsigned_transaction.as_dict(), 'v', 'r', 's') + print('THE SIG BYTES') + print(len(sig_bytes)) + print(sig_bytes[1:]) signed_transaction = Transaction(s=sig_bytes, **chain_naive_transaction) print(signed_transaction.as_dict()) return rlp.encode(signed_transaction) @@ -85,15 +88,19 @@ def is_none(val): 'to': b'', 'value': 0, 'data': b'', - 'chainId': None, - 'tx_type': 0, - 'timestamp': int(time.time()) + 'tx_type': b'0x01', + 'timestamp': int(time.time()), + 'gasPrice': b'\x00\x00\x00%@\xbe@\x00' } TRANSACTION_FORMATTERS = { 'nonce': hexstr_if_str(to_int), 'gas': hexstr_if_str(to_int), - 'gasPrice': hexstr_if_str(to_int), + 'gasPrice': apply_one_of_formatters(( + (is_string, hexstr_if_str(to_bytes)), + (is_bytes, identity), + (is_none, lambda val: b''), + )), 'to': apply_one_of_formatters(( (is_string, hexstr_if_str(to_bytes)), (is_bytes, identity), @@ -103,7 +110,11 @@ def is_none(val): 'data': hexstr_if_str(to_bytes), 'v': hexstr_if_str(to_int), 'r': hexstr_if_str(to_int), - 's': hexstr_if_str(to_int), + 's': apply_one_of_formatters(( + (is_string, hexstr_if_str(to_bytes)), + (is_bytes, identity), + (is_none, lambda val: b''), + )), } TRANSACTION_VALID_VALUES = { @@ -170,14 +181,15 @@ def fill_transaction_defaults(transaction): ('data', binary), ('timestamp', big_endian_int), ('gas', big_endian_int), - ('gasPrice', big_endian_int), - ('tx_type', big_endian_int), + ('gasPrice', binary), + ('tx_type', binary), ) class Transaction(HashableRLP): fields = UNSIGNED_TRANSACTION_FIELDS + ( - ('s', binary), + ('s', Binary.fixed_length(96, allow_empty=True)), + # ('sv', Binary.fixed_length(64, allow_empty=True)), ) From 401a66384d49cf3fd623015c2064604668525ad5 Mon Sep 17 00:00:00 2001 From: Mwangi <8320816+kidynamit@users.noreply.github.com> Date: Mon, 13 Aug 2018 20:45:37 +0200 Subject: [PATCH 4/7] gitignore updated --- .gitignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 58654f8..b89cd4e 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ chains # tox/pytest cache .cache +.pytest_cache # Test output logs logs @@ -83,9 +84,6 @@ logs # Mongo Explorer plugin: .idea/mongoSettings.xml -# VIM temp files -*.swp - ## File-based project format: *.iws @@ -106,3 +104,5 @@ crashlytics.properties crashlytics-build.properties fabric.properties +# virtualenv default location +venv* From f0bea684b06534f79751582d60dedbd08608a909 Mon Sep 17 00:00:00 2001 From: Mwangi <8320816+kidynamit@users.noreply.github.com> Date: Mon, 13 Aug 2018 21:34:49 +0200 Subject: [PATCH 5/7] added test changes; removed print statement fixed the v in vrs --- eth_account/account.py | 3 --- eth_account/internal/signing.py | 20 ++++++-------------- eth_account/internal/transactions.py | 6 ------ tests/core/test_accounts.py | 4 ++-- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/eth_account/account.py b/eth_account/account.py index 98928b7..bf662fe 100644 --- a/eth_account/account.py +++ b/eth_account/account.py @@ -86,7 +86,6 @@ def create(self, extra_entropy=''): ''' extra_key_bytes = text_if_str(to_bytes, extra_entropy) key_bytes = blake2b(os.urandom(32) + extra_key_bytes) - print(key_bytes) return self.privateKeyToAccount(key_bytes) @staticmethod @@ -431,7 +430,6 @@ def signTransaction(self, transaction_dict, private_key): else: sanitized_transaction = transaction_dict - print(sanitized_transaction) # sign transaction ( v, @@ -439,7 +437,6 @@ def signTransaction(self, transaction_dict, private_key): s, rlp_encoded, ) = sign_transaction_dict(account._key_obj, sanitized_transaction) - print(rlp_encoded) transaction_hash = blake2b(rlp_encoded, digest_size=32) return AttributeDict({ diff --git a/eth_account/internal/signing.py b/eth_account/internal/signing.py index d1039b2..02f4495 100644 --- a/eth_account/internal/signing.py +++ b/eth_account/internal/signing.py @@ -20,9 +20,7 @@ def sign_transaction_dict(eth_key, transaction_dict): # generate RLP-serializable transaction, with defaults filled - print('DOING THE THING') unsigned_transaction = serializable_unsigned_transaction_from_dict(transaction_dict) - print(unsigned_transaction) transaction_hash = unsigned_transaction.hash() @@ -33,17 +31,12 @@ def sign_transaction_dict(eth_key, transaction_dict): chain_id = unsigned_transaction.v # sign with private key - (v, r, s, sign_bytes, total_sig) = sign_transaction_hash(eth_key, transaction_hash, chain_id) + (_, r, s, sign_bytes, total_sig) = sign_transaction_hash(eth_key, transaction_hash, chain_id) pub_key = bytes(eth_key.public_key.to_bytes()) - print('PUBLIC KEY') - print(pub_key) - print('sig bytes') - print(sign_bytes) # serialize transaction with rlp - sign_bytes = pub_key + sign_bytes - encoded_transaction = encode_transaction(unsigned_transaction, vrs=(v, r, s, sign_bytes, total_sig)) - print(encoded_transaction) - return (v, r, s, encoded_transaction) + sign_bytes = pub_key + sign_bytes + encoded_transaction = encode_transaction(unsigned_transaction, vrs=(1, r, s, sign_bytes, total_sig)) + return (1, r, s, encoded_transaction) # watch here for updates to signature format: https://github.com/ethereum/EIPs/issues/191 @@ -123,11 +116,10 @@ def to_eth_v(v_raw, chain_id=None): def sign_transaction_hash(account, transaction_hash, chain_id): signature = account.sign_msg_hash(transaction_hash) - (v_raw, r, s) = signature.vrs + (_, r, s) = signature.vrs sig_bytes = signature.signature_bytes sig_raw = signature.total_sig - v = to_eth_v(v_raw, chain_id) - return (v, r, s, sig_bytes, sig_raw) + return (1, r, s, sig_bytes, sig_raw) def _pad_to_eth_word(bytes_val): diff --git a/eth_account/internal/transactions.py b/eth_account/internal/transactions.py index 2186f34..8bd3a1d 100644 --- a/eth_account/internal/transactions.py +++ b/eth_account/internal/transactions.py @@ -51,14 +51,8 @@ def serializable_unsigned_transaction_from_dict(transaction_dict): def encode_transaction(unsigned_transaction, vrs): (v, r, s, sig_bytes, total_sig) = vrs - print(unsigned_transaction) - print(unsigned_transaction.as_dict()) chain_naive_transaction = dissoc(unsigned_transaction.as_dict(), 'v', 'r', 's') - print('THE SIG BYTES') - print(len(sig_bytes)) - print(sig_bytes[1:]) signed_transaction = Transaction(s=sig_bytes, **chain_naive_transaction) - print(signed_transaction.as_dict()) return rlp.encode(signed_transaction) diff --git a/tests/core/test_accounts.py b/tests/core/test_accounts.py index 5234470..946b320 100644 --- a/tests/core/test_accounts.py +++ b/tests/core/test_accounts.py @@ -54,13 +54,13 @@ ] -PRIVATE_KEY_AS_BYTES = b'unicorns' * 4 +PRIVATE_KEY_AS_BYTES = b'unicorns' * 8 PRIVATE_KEY_AS_HEXSTR = '0x756e69636f726e73756e69636f726e73756e69636f726e73756e69636f726e73' PRIVATE_KEY_AS_INT = 0x756e69636f726e73756e69636f726e73756e69636f726e73756e69636f726e73 PRIVATE_KEY_AS_OBJ = keys.PrivateKey(PRIVATE_KEY_AS_BYTES) ACCT_ADDRESS = '0xa79F6f349C853F9Ea0B29636779ae3Cb4E3BA729' -PRIVATE_KEY_AS_BYTES_ALT = b'rainbows' * 4 +PRIVATE_KEY_AS_BYTES_ALT = b'rainbows' * 8 PRIVATE_KEY_AS_HEXSTR_ALT = '0x7261696e626f77737261696e626f77737261696e626f77737261696e626f7773' PRIVATE_KEY_AS_INT_ALT = 0x7261696e626f77737261696e626f77737261696e626f77737261696e626f7773 PRIVATE_KEY_AS_OBJ_ALT = keys.PrivateKey(PRIVATE_KEY_AS_BYTES_ALT) From b0ed04c3511c81508def7798d2580de4e2ae3ffa Mon Sep 17 00:00:00 2001 From: ConnorMac Date: Thu, 23 Aug 2018 13:06:50 +0200 Subject: [PATCH 6/7] Working on RLP encoding --- eth_account/internal/transactions.py | 41 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/eth_account/internal/transactions.py b/eth_account/internal/transactions.py index 2186f34..7e7d745 100644 --- a/eth_account/internal/transactions.py +++ b/eth_account/internal/transactions.py @@ -31,6 +31,7 @@ big_endian_int, binary, ) +import hexbytes def serializable_unsigned_transaction_from_dict(transaction_dict): @@ -84,29 +85,33 @@ def is_none(val): return val is None +def int_to_hex(val): + return bytes(hex(val), encoding='utf-8') + + TRANSACTION_DEFAULTS = { 'to': b'', - 'value': 0, + 'value': b'R\x08', 'data': b'', - 'tx_type': b'0x01', - 'timestamp': int(time.time()), - 'gasPrice': b'\x00\x00\x00%@\xbe@\x00' + 'tx_type': b'\x01', + 'timestamp': bytes(hexbytes.HexBytes(int(time.time()*1000.0))), + 'gasPrice': b'R\x08' } TRANSACTION_FORMATTERS = { - 'nonce': hexstr_if_str(to_int), - 'gas': hexstr_if_str(to_int), - 'gasPrice': apply_one_of_formatters(( - (is_string, hexstr_if_str(to_bytes)), - (is_bytes, identity), - (is_none, lambda val: b''), - )), + # 'nonce': hexstr_if_str(to_int), + # 'gas': hexstr_if_str(to_int), + # 'gasPrice': apply_one_of_formatters(( + # (is_string, hexstr_if_str(to_bytes)), + # (is_bytes, identity), + # (is_none, lambda val: b''), + # )), 'to': apply_one_of_formatters(( (is_string, hexstr_if_str(to_bytes)), (is_bytes, identity), (is_none, lambda val: b''), )), - 'value': hexstr_if_str(to_int), + # 'value': hexstr_if_str(to_int), 'data': hexstr_if_str(to_bytes), 'v': hexstr_if_str(to_int), 'r': hexstr_if_str(to_int), @@ -118,9 +123,9 @@ def is_none(val): } TRANSACTION_VALID_VALUES = { - 'nonce': is_int_or_prefixed_hexstr, + 'nonce': lambda val: isinstance(val, (int, str, bytes, bytearray)), 'gasPrice': is_int_or_prefixed_hexstr, - 'gas': is_int_or_prefixed_hexstr, + 'gas': lambda val: isinstance(val, (int, str, bytes, bytearray)), 'to': is_empty_or_checksum_address, 'value': is_int_or_prefixed_hexstr, 'data': lambda val: isinstance(val, (int, str, bytes, bytearray)), @@ -175,12 +180,12 @@ def fill_transaction_defaults(transaction): UNSIGNED_TRANSACTION_FIELDS = ( - ('nonce', big_endian_int), + ('nonce', binary), ('to', Binary.fixed_length(32, allow_empty=True)), - ('value', big_endian_int), + ('value', binary), ('data', binary), - ('timestamp', big_endian_int), - ('gas', big_endian_int), + ('timestamp', binary), + ('gas', binary), ('gasPrice', binary), ('tx_type', binary), ) From 45eca8a5cf17684a2bb60ba897fb940a2e545da1 Mon Sep 17 00:00:00 2001 From: ConnorMac Date: Thu, 23 Aug 2018 14:24:29 +0200 Subject: [PATCH 7/7] Move toward expecting just the full signature bytes array --- eth_account/internal/signing.py | 7 +++---- eth_account/internal/transactions.py | 16 +++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/eth_account/internal/signing.py b/eth_account/internal/signing.py index 02f4495..8a803b7 100644 --- a/eth_account/internal/signing.py +++ b/eth_account/internal/signing.py @@ -31,11 +31,11 @@ def sign_transaction_dict(eth_key, transaction_dict): chain_id = unsigned_transaction.v # sign with private key - (_, r, s, sign_bytes, total_sig) = sign_transaction_hash(eth_key, transaction_hash, chain_id) + (_, r, s, sign_bytes) = sign_transaction_hash(eth_key, transaction_hash, chain_id) pub_key = bytes(eth_key.public_key.to_bytes()) # serialize transaction with rlp sign_bytes = pub_key + sign_bytes - encoded_transaction = encode_transaction(unsigned_transaction, vrs=(1, r, s, sign_bytes, total_sig)) + encoded_transaction = encode_transaction(unsigned_transaction, sig_bytes=sign_bytes) return (1, r, s, encoded_transaction) @@ -118,8 +118,7 @@ def sign_transaction_hash(account, transaction_hash, chain_id): signature = account.sign_msg_hash(transaction_hash) (_, r, s) = signature.vrs sig_bytes = signature.signature_bytes - sig_raw = signature.total_sig - return (1, r, s, sig_bytes, sig_raw) + return (1, r, s, sig_bytes) def _pad_to_eth_word(bytes_val): diff --git a/eth_account/internal/transactions.py b/eth_account/internal/transactions.py index 3eeface..edd448e 100644 --- a/eth_account/internal/transactions.py +++ b/eth_account/internal/transactions.py @@ -50,9 +50,8 @@ def serializable_unsigned_transaction_from_dict(transaction_dict): return serializer.from_dict(filled_transaction) -def encode_transaction(unsigned_transaction, vrs): - (v, r, s, sig_bytes, total_sig) = vrs - chain_naive_transaction = dissoc(unsigned_transaction.as_dict(), 'v', 'r', 's') +def encode_transaction(unsigned_transaction, sig_bytes): + chain_naive_transaction = dissoc(unsigned_transaction.as_dict()) signed_transaction = Transaction(s=sig_bytes, **chain_naive_transaction) return rlp.encode(signed_transaction) @@ -85,7 +84,7 @@ def int_to_hex(val): TRANSACTION_DEFAULTS = { 'to': b'', - 'value': b'R\x08', + 'value': 0, 'data': b'', 'tx_type': b'\x01', 'timestamp': bytes(hexbytes.HexBytes(int(time.time()*1000.0))), @@ -93,7 +92,7 @@ def int_to_hex(val): } TRANSACTION_FORMATTERS = { - # 'nonce': hexstr_if_str(to_int), + 'nonce': hexstr_if_str(to_int), # 'gas': hexstr_if_str(to_int), # 'gasPrice': apply_one_of_formatters(( # (is_string, hexstr_if_str(to_bytes)), @@ -105,7 +104,7 @@ def int_to_hex(val): (is_bytes, identity), (is_none, lambda val: b''), )), - # 'value': hexstr_if_str(to_int), + 'value': hexstr_if_str(to_int), 'data': hexstr_if_str(to_bytes), 'v': hexstr_if_str(to_int), 'r': hexstr_if_str(to_int), @@ -174,9 +173,9 @@ def fill_transaction_defaults(transaction): UNSIGNED_TRANSACTION_FIELDS = ( - ('nonce', binary), + ('nonce', big_endian_int), ('to', Binary.fixed_length(32, allow_empty=True)), - ('value', binary), + ('value', big_endian_int), ('data', binary), ('timestamp', binary), ('gas', binary), @@ -188,7 +187,6 @@ def fill_transaction_defaults(transaction): class Transaction(HashableRLP): fields = UNSIGNED_TRANSACTION_FIELDS + ( ('s', Binary.fixed_length(96, allow_empty=True)), - # ('sv', Binary.fixed_length(64, allow_empty=True)), )