From 3a983d2419cdd053f5e03193794d1663c841f4b2 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 3 Jul 2015 11:20:07 -0500 Subject: Initial getTransactionReceipt support --- rpc/api/eth.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'rpc/api/eth.go') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index db0b4b024..c556c739f 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -77,6 +77,7 @@ var ( "eth_submitWork": (*ethApi).SubmitWork, "eth_resend": (*ethApi).Resend, "eth_pendingTransactions": (*ethApi).PendingTransactions, + "eth_getTransactionReceipt": (*ethApi).GetTransactionReceipt, } ) @@ -596,3 +597,22 @@ func (self *ethApi) PendingTransactions(req *shared.Request) (interface{}, error return ltxs, nil } + +func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, error) { + args := new(HashArgs) + if err := self.codec.Decode(req.Params, &args); err != nil { + return nil, shared.NewDecodeParamError(err.Error()) + } + + rec, _ := self.xeth.GetTxReceipt(common.StringToHash(args.Hash)) + // We could have an error of "not found". Should disambiguate + // if err != nil { + // return err, nil + // } + if rec != nil { + v := NewReceiptRes(rec) + return v, nil + } + + return nil, nil +} -- cgit v1.2.3 From 80eb8f46b7991b80dffe00e52d9fb00a90531bc0 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 3 Jul 2015 23:46:59 -0500 Subject: Fix hex conversion --- rpc/api/eth.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'rpc/api/eth.go') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index c556c739f..9d78538fe 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -604,7 +604,8 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err return nil, shared.NewDecodeParamError(err.Error()) } - rec, _ := self.xeth.GetTxReceipt(common.StringToHash(args.Hash)) + v := common.BytesToHash(common.FromHex(args.Hash)) + rec := self.xeth.GetTxReceipt(v) // We could have an error of "not found". Should disambiguate // if err != nil { // return err, nil -- cgit v1.2.3 From 3be9046c21920abffa3c5ec81d5aabea8e3bab73 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 10:24:52 -0500 Subject: Rename local variable for clarity --- rpc/api/eth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rpc/api/eth.go') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 9d78538fe..0f3b14525 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -604,8 +604,8 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err return nil, shared.NewDecodeParamError(err.Error()) } - v := common.BytesToHash(common.FromHex(args.Hash)) - rec := self.xeth.GetTxReceipt(v) + txhash := common.BytesToHash(common.FromHex(args.Hash)) + rec := self.xeth.GetTxReceipt(txhash) // We could have an error of "not found". Should disambiguate // if err != nil { // return err, nil -- cgit v1.2.3 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 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'rpc/api/eth.go') 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 } -- cgit v1.2.3