diff --git a/core/transaction_util.go b/core/transaction_util.go index cb5d6c7f74e0da98d9da34ac6f2542e643af235f..61bf023a693f785cb7303bcaeb8939850167ebe4 100644 --- a/core/transaction_util.go +++ b/core/transaction_util.go @@ -54,6 +54,21 @@ func PutReceipts(db common.Database, receipts types.Receipts) error { return nil } +// GetReceipt returns a receipt by hash +func GetFullReceipt(db common.Database, txHash common.Hash) *types.ReceiptForStorage { + data, _ := db.Get(append(receiptsPre, txHash[:]...)) + if len(data) == 0 { + return nil + } + + var receipt types.ReceiptForStorage + err := rlp.DecodeBytes(data, &receipt) + if err != nil { + glog.V(logger.Error).Infoln("GetReceipt err:", err) + } + return &receipt +} + // GetReceipt returns a receipt by hash func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt { data, _ := db.Get(append(receiptsPre, txHash[:]...)) diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index d1f9ccac2261bd1c272c26e252ded1ffd83dbb07..c7edf43256cf77e15d188fcb7de380b26a1ae57b 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -413,15 +413,17 @@ type ReceiptRes struct { Logs *[]interface{} `json:logs` } -func NewReceiptRes(rec *types.Receipt) *ReceiptRes { +func NewReceiptRes(rec *types.ReceiptForStorage) *ReceiptRes { if rec == nil { return nil } 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) return v } diff --git a/xeth/xeth.go b/xeth/xeth.go index cbc8dbbdef54e4ec38393e552e87c43dae9f0d75..1b7f0682187e739850ff152ed8d2da479813237a 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -368,8 +368,8 @@ func (self *XEth) GetBlockReceipts(bhash common.Hash) types.Receipts { return self.backend.BlockProcessor().GetBlockReceipts(bhash) } -func (self *XEth) GetTxReceipt(txhash common.Hash) *types.Receipt { - return core.GetReceipt(self.backend.ExtraDb(), txhash) +func (self *XEth) GetTxReceipt(txhash common.Hash) *types.ReceiptForStorage { + return core.GetFullReceipt(self.backend.ExtraDb(), txhash) } func (self *XEth) GasLimit() *big.Int {