Created
October 11, 2017 23:35
-
-
Save kvhnuke/f8cc29994e0aac5eb343a6426864955e to your computer and use it in GitHub Desktop.
add Input to receipt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) { | |
tx, blockHash, blockNumber, index := core.GetTransaction(s.b.ChainDb(), hash) | |
if tx == nil { | |
return nil, nil | |
} | |
receipt, _, _, _ := core.GetReceipt(s.b.ChainDb(), hash) // Old receipts don't have the lookup data available | |
var signer types.Signer = types.FrontierSigner{} | |
if tx.Protected() { | |
signer = types.NewEIP155Signer(tx.ChainId()) | |
} | |
from, _ := types.Sender(signer, tx) | |
fields := map[string]interface{}{ | |
"blockHash": blockHash, | |
"blockNumber": hexutil.Uint64(blockNumber), | |
"transactionHash": hash, | |
"transactionIndex": hexutil.Uint64(index), | |
"from": from, | |
"to": tx.To(), | |
"Input": hexutil.Bytes(tx.Data()), | |
"gasUsed": (*hexutil.Big)(receipt.GasUsed), | |
"cumulativeGasUsed": (*hexutil.Big)(receipt.CumulativeGasUsed), | |
"contractAddress": nil, | |
"logs": receipt.Logs, | |
"logsBloom": receipt.Bloom, | |
} | |
// Assign receipt status or post state. | |
if len(receipt.PostState) > 0 { | |
fields["root"] = hexutil.Bytes(receipt.PostState) | |
} else { | |
fields["status"] = hexutil.Uint(receipt.Status) | |
} | |
if receipt.Logs == nil { | |
fields["logs"] = [][]*types.Log{} | |
} | |
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation | |
if receipt.ContractAddress != (common.Address{}) { | |
fields["contractAddress"] = receipt.ContractAddress | |
} | |
return fields, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment