aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/rpc/api.go b/rpc/api.go
index bcd073ed2..7f10f16e3 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -199,9 +199,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
args := new(HashIndexArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
}
- tx := api.xeth().EthTransactionByHash(args.Hash)
+ tx, bhash, bnum, txi := api.xeth().EthTransactionByHash(args.Hash)
if tx != nil {
- *reply = NewTransactionRes(tx)
+ v := NewTransactionRes(tx)
+ v.BlockHash = newHexData(bhash)
+ v.BlockNumber = newHexNum(bnum)
+ v.TxIndex = newHexNum(txi)
+ *reply = v
}
case "eth_getTransactionByBlockHashAndIndex":
args := new(HashIndexArgs)
@@ -213,7 +217,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
br := NewBlockRes(block)
br.fullTx = true
- if args.Index > int64(len(br.Transactions)) || args.Index < 0 {
+ if args.Index >= int64(len(br.Transactions)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
*reply = br.Transactions[args.Index]
@@ -227,7 +231,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
v := NewBlockRes(block)
v.fullTx = true
- if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
+ if args.Index >= int64(len(v.Transactions)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
*reply = v.Transactions[args.Index]
@@ -239,12 +243,12 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash))
- if args.Index > int64(len(br.Uncles)) || args.Index < 0 {
+ if args.Index >= int64(len(br.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
uhash := br.Uncles[args.Index]
- uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.Hex()))
+ uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.String()))
*reply = uncle
case "eth_getUncleByBlockNumberAndIndex":
@@ -257,12 +261,12 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
v := NewBlockRes(block)
v.fullTx = true
- if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
+ if args.Index >= int64(len(v.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
uhash := v.Uncles[args.Index]
- uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.Hex()))
+ uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.String()))
*reply = uncle
case "eth_getCompilers":