diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-12 22:59:07 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-12 22:59:07 +0800 |
commit | 2273155e7e325a2a6a940fffae7e9f6744b2ec22 (patch) | |
tree | 1767f5b797db8988afc46e9118b61d522a9c5226 /rpc | |
parent | 26a563642431806486b595f29e22ae833abb6a8c (diff) | |
download | go-tangerine-2273155e7e325a2a6a940fffae7e9f6744b2ec22.tar.gz go-tangerine-2273155e7e325a2a6a940fffae7e9f6744b2ec22.tar.zst go-tangerine-2273155e7e325a2a6a940fffae7e9f6744b2ec22.zip |
Get transaction implemented
* Added a GetTransaction to XEth
* Implemented the `eth_getTransactionByHash` RPC method
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/api.go | 18 | ||||
-rw-r--r-- | rpc/args.go | 6 |
2 files changed, 18 insertions, 6 deletions
diff --git a/rpc/api.go b/rpc/api.go index 44b8ee834..b94d2d6dc 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -421,6 +421,14 @@ func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error { return nil } +func (p *EthereumApi) GetTransactionByHash(hash string, reply *interface{}) error { + tx := p.xeth().EthTransactionByHash(hash) + if tx != nil { + *reply = NewTransactionRes(tx) + } + return nil +} + func (p *EthereumApi) GetBlockByHash(blockhash string, includetx bool) (*BlockRes, error) { block := p.xeth().EthBlockByHash(blockhash) br := NewBlockRes(block) @@ -594,14 +602,18 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error } *reply = v case "eth_getTransactionByHash": - return errNotImplemented + // HashIndexArgs used, but only the "Hash" part we need. + args := new(HashIndexArgs) + if err := json.Unmarshal(req.Params, &args); err != nil { + } + return p.GetTransactionByHash(args.Hash, reply) case "eth_getTransactionByBlockHashAndIndex": args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { return err } - v, err := p.GetBlockByHash(args.BlockHash, true) + v, err := p.GetBlockByHash(args.Hash, true) if err != nil { return err } @@ -629,7 +641,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return err } - v, err := p.GetBlockByHash(args.BlockHash, false) + v, err := p.GetBlockByHash(args.Hash, false) if err != nil { return err } diff --git a/rpc/args.go b/rpc/args.go index 40f8575b2..faca03b63 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -280,8 +280,8 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) { } type HashIndexArgs struct { - BlockHash string - Index int64 + Hash string + Index int64 } func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) { @@ -299,7 +299,7 @@ func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) { if !ok { return errDecodeArgs } - args.BlockHash = arg0 + args.Hash = arg0 if len(obj) > 1 { arg1, ok := obj[1].(string) |