Add sender to getReceipt, calculate transaction hash once

This commit is contained in:
coffeepots 2018-08-23 18:01:31 +01:00 committed by zah
parent d901c20bb2
commit 53bd7774db
1 changed files with 2 additions and 4 deletions

View File

@ -423,9 +423,8 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
bytes[64] = (cast[uint64](transaction.V.data.lo) and 0xff'u64).uint8 bytes[64] = (cast[uint64](transaction.V.data.lo) and 0xff'u64).uint8
initSignature(bytes) initSignature(bytes)
proc getSender(transaction: Transaction): EthAddress = proc getSender(transaction: Transaction, txHash: Hash256): EthAddress =
let let
txHash = transaction.rlpHash
sig = transaction.toSignature() sig = transaction.toSignature()
pubKey = recoverKeyFromSignature(sig, txHash) pubKey = recoverKeyFromSignature(sig, txHash)
const pubKeySize = 64 const pubKeySize = 64
@ -436,8 +435,7 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
result.transactionIndex = txIndex result.transactionIndex = txIndex
result.blockHash = blockHeader.hash result.blockHash = blockHeader.hash
result.blockNumber = blockHeader.blockNumber result.blockNumber = blockHeader.blockNumber
# TODO: Get sender result.sender = transaction.getSender(result.transactionHash)
#result.sender: EthAddress
result.to = new EthAddress result.to = new EthAddress
result.to[] = transaction.to result.to[] = transaction.to
result.cumulativeGasUsed = cumulativeGas result.cumulativeGasUsed = cumulativeGas