aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/parsing.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-07-06 16:53:21 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-07-06 16:53:21 +0800
commit35add89c879dd1d12e7ed702d7543f5a749a1d3e (patch)
tree003efe1e5d1ee270700b63264b8050c41aba14d6 /rpc/api/parsing.go
parent46e7c8512edd6de49c546467505673155ebbd1c2 (diff)
parent6c7f5e3d0e6f4166f161278fdced3d90dfd6f9cc (diff)
downloadgo-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.tar
go-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.tar.gz
go-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.tar.bz2
go-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.tar.lz
go-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.tar.xz
go-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.tar.zst
go-tangerine-35add89c879dd1d12e7ed702d7543f5a749a1d3e.zip
Merge pull request #1397 from tgerring/rpcreceipt
getTransactionReceipt RPC support
Diffstat (limited to 'rpc/api/parsing.go')
-rw-r--r--rpc/api/parsing.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go
index 632462c31..4209ea7e3 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"
@@ -402,6 +403,38 @@ func NewUncleRes(h *types.Header) *UncleRes {
// WorkProved string `json:"workProved"`
// }
+type ReceiptRes struct {
+ TransactionHash *hexdata `json:transactionHash`
+ TransactionIndex *hexnum `json:transactionIndex`
+ BlockNumber *hexnum `json:blockNumber`
+ BlockHash *hexdata `json:blockHash`
+ CumulativeGasUsed *hexnum `json:cumulativeGasUsed`
+ GasUsed *hexnum `json:gasUsed`
+ ContractAddress *hexdata `json:contractAddress`
+ Logs *[]interface{} `json:logs`
+}
+
+func NewReceiptRes(rec *types.Receipt) *ReceiptRes {
+ if rec == nil {
+ return nil
+ }
+
+ var v = new(ReceiptRes)
+ v.TransactionHash = newHexData(rec.TxHash)
+ // v.TransactionIndex = newHexNum(input)
+ // v.BlockNumber = newHexNum(input)
+ // v.BlockHash = newHexData(input)
+ v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed)
+ // v.GasUsed = newHexNum(input)
+ // 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
+}
+
func numString(raw interface{}) (*big.Int, error) {
var number *big.Int
// Parse as integer