From 30afd37604da40416b0dd4fdc8cad322c12651cf Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 12:03:37 -0500 Subject: Compose additional fields --- rpc/api/eth.go | 7 ++++++- rpc/api/parsing.go | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'rpc') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 0f3b14525..6d759a087 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -605,13 +605,18 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err } txhash := common.BytesToHash(common.FromHex(args.Hash)) + tx, bhash, bnum, txi := self.xeth.EthTransactionByHash(args.Hash) rec := self.xeth.GetTxReceipt(txhash) // We could have an error of "not found". Should disambiguate // if err != nil { // return err, nil // } - if rec != nil { + if rec != nil && tx != nil { v := NewReceiptRes(rec) + v.BlockHash = newHexData(bhash) + v.BlockNumber = newHexNum(bnum) + v.GasUsed = newHexNum(tx.Gas().Bytes()) + v.TransactionIndex = newHexNum(txi) return v, nil } diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 70e9bf942..cc7f60cad 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -1,6 +1,7 @@ package api import ( + "bytes" "encoding/binary" "encoding/hex" "encoding/json" @@ -419,11 +420,18 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes { } var v = new(ReceiptRes) - // TODO fill out rest of object - // ContractAddress is all 0 when not a creation tx - v.ContractAddress = newHexData(rec.ContractAddress) - v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) v.TransactionHash = newHexData(rec.TxHash) + // v.TransactionIndex = newHexNum(input) // transaction + // v.BlockNumber = newHexNum(input) // transaction + // v.BlockHash = newHexData(input) //transaction + v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) + // v.GasUsed = newHexNum(input) // CumulativeGasUsed (blocknum-1) + // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation + if bytes.Compare(rec.ContractAddress.Bytes(), bytes.Repeat([]byte{0}, 20)) != 0 { + v.ContractAddress = newHexData(rec.ContractAddress) + } + // v.Logs = rec.Logs() + return v } -- cgit