lets assume I have this private key (test account on ropsten, no need to worry):
785cdcd731a1b2438ec4511a25d04efbdc499ed350df612364af1aa6f4fd6abd
When I use Pyethereum to run
v, r, s = ecsign(tx['hash'], normalize_key(private_key))
then v, r, s = (28, 70432465444433342622726730664370509023990924819271715983647847605365849029795, 7960080711554037742197166599216482712965266632510536462814358773930726674178)
When I compare this with the actual transaction:
{'blockHash': HexBytes('0x47b8f62c1400dae65105d2f8e03824bfc58481c0b32f45788ad3378fbc05e9f6'),
'blockNumber': 4156209,
'from': '0x4e5C95B38bd0B18B83f130a1ffae58cFC58961DE',
'gas': 21000,
'gasPrice': 8000000000,
'hash': HexBytes('0x8ec420a3ba331f2a967ecdaf69b78bbb604ebbb2554a8c635142b7b306defaae'),
'input': '0x',
'nonce': 0,
'r': HexBytes('0xe298a05754cc5a24790bb8c21ecb60fd93f2d096146af7397440697a338dff46'),
's': HexBytes('0x5999f680f17e505c979c43a3a9e7707c817efde705f967681d8a5066b49e5352'),
'to': '0xED6CA7d908f897d0B0D5f9B9E7Aa470698E10b1b',
'transactionIndex': 27,
'v': 42,
'value': 1000000000000000000}
The Values for r,s,v are very different. (Event when I convert them with bytes.from_hex(tx['r']))
Q1: Dose anyone know what I am doing Wrong?
Just to make sure: The transaction was made with metamask and then the key was exported from metamask, so there is no chance that the key to sign the transaction was different.
Q2: Is there a better way to do this?
Thanks in advance :)