diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-01 18:51:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-01 18:51:44 +0800 |
commit | dba9b83aa07ced653b24c3e34d55ffe13a740243 (patch) | |
tree | 0dc20ee3807e3fe5a076fbfe2ec00bd6601792a6 /rpc/api.go | |
parent | 4e8f8cfab701bb6c4ad2b8cf166d642f408ca398 (diff) | |
parent | b0e09ec82752b48c2384c315dc420e5c39e785b6 (diff) | |
download | go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.tar go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.tar.gz go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.tar.bz2 go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.tar.lz go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.tar.xz go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.tar.zst go-tangerine-dba9b83aa07ced653b24c3e34d55ffe13a740243.zip |
Merge branch 'tgerring-hexify' into develop
Diffstat (limited to 'rpc/api.go')
-rw-r--r-- | rpc/api.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/rpc/api.go b/rpc/api.go index 502079177..c046c22fe 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -54,7 +54,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err case "net_peerCount": v := api.xeth().PeerCount() *reply = common.ToHex(big.NewInt(int64(v)).Bytes()) - case "eth_version": + case "eth_protocolVersion": *reply = api.xeth().EthVersion() case "eth_coinbase": // TODO handling of empty coinbase due to lack of accounts @@ -159,7 +159,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } *reply = v case "eth_call": - args := new(NewTxArgs) + args := new(CallArgs) if err := json.Unmarshal(req.Params, &args); err != nil { return err } @@ -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": |