Skip to content

Commit

Permalink
Fix signing transactions with network_id
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan committed Aug 9, 2018
1 parent 28ac6d0 commit 7c7ea05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions ethereum/tests/test_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def test_mining(db):


@pytest.fixture(scope="module")
def get_transaction(gasprice=0, nonce=0):
def get_transaction(gasprice=0, nonce=0, network_id=None):
k, v, k2, v2 = accounts()
tx = transactions.Transaction(
nonce, gasprice, startgas=100000,
to=v2, value=utils.denoms.finney * 10, data=b'').sign(k)
to=v2, value=utils.denoms.finney * 10, data=b'').sign(k, network_id=network_id)
return tx


Expand Down Expand Up @@ -431,6 +431,10 @@ def test_get_blockhash_by_number():

test_chain.chain.get_blockhash_by_number(2) == test_chain.chain.head.hash

def test_sign_with_network_id():
tx = get_transaction(network_id=66)
assert tx.network_id == 66


# TODO ##########################################
#
Expand Down
4 changes: 2 additions & 2 deletions ethereum/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def sign(self, key, network_id=None):

v, r, s = ecsign(rawhash, key)
if network_id is not None:
self.v += 8 + network_id * 2
v += 8 + network_id * 2

ret = self.copy(
v=v,r=r,s=s
v=v, r=r, s=s
)
ret._sender = utils.privtoaddr(key)
return ret
Expand Down

0 comments on commit 7c7ea05

Please sign in to comment.