aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/api/eth.go26
-rw-r--r--rpc/api/parsing.go33
-rw-r--r--rpc/api/utils.go1
-rw-r--r--xeth/xeth.go1
4 files changed, 60 insertions, 1 deletions
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index db0b4b024..6d759a087 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,28 @@ 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())
+ }
+
+ 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 && 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
+ }
+
+ return nil, nil
+}
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
diff --git a/rpc/api/utils.go b/rpc/api/utils.go
index e6a01d3d6..54ca28774 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.go
@@ -86,6 +86,7 @@ var (
"submitWork",
"pendingTransactions",
"resend",
+ "getTransactionReceipt",
},
"miner": []string{
"hashrate",
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 1cec82e5e..88d802820 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -969,7 +969,6 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
if contractCreation {
addr := crypto.CreateAddress(from, nonce)
glog.V(logger.Info).Infof("Tx(%x) created: %x\n", tx.Hash(), addr)
- return addr.Hex(), nil
} else {
glog.V(logger.Info).Infof("Tx(%x) to: %x\n", tx.Hash(), tx.To())
}