diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-11 11:25:07 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-11 11:25:07 +0800 |
commit | 9ce5229ddfccfccf1215e44477b665de031e4e1e (patch) | |
tree | 7f2789a1bce5c8c41a7363121e52e8a7757b09a5 /rpc/api.go | |
parent | ece29c5d8da2a8477ec2a95c8d0307a55ab21b76 (diff) | |
download | dexon-9ce5229ddfccfccf1215e44477b665de031e4e1e.tar.gz dexon-9ce5229ddfccfccf1215e44477b665de031e4e1e.tar.zst dexon-9ce5229ddfccfccf1215e44477b665de031e4e1e.zip |
Get transaction via block & index
Diffstat (limited to 'rpc/api.go')
-rw-r--r-- | rpc/api.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/rpc/api.go b/rpc/api.go index a8c365b22..510939cd7 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -593,8 +593,35 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error } *reply = v case "eth_getTransactionByHash": + return errNotImplemented case "eth_getTransactionByBlockHashAndIndex": + args := new(HashIndexArgs) + if err := json.Unmarshal(req.Params, &args); err != nil { + return err + } + + v, err := p.GetBlockByHash(args.BlockHash, true) + if err != nil { + return err + } + if args.TxIndex > int64(len(v.Transactions)) || args.TxIndex < 0 { + return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist") + } + *reply = v.Transactions[args.TxIndex] case "eth_getTransactionByBlockNumberAndIndex": + args := new(BlockNumIndexArgs) + if err := json.Unmarshal(req.Params, &args); err != nil { + return err + } + + v, err := p.GetBlockByNumber(args.BlockNumber, true) + if err != nil { + return err + } + if args.TxIndex > int64(len(v.Transactions)) || args.TxIndex < 0 { + return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist") + } + *reply = v.Transactions[args.TxIndex] case "eth_getUncleByBlockHashAndIndex": case "eth_getUncleByBlockNumberAndIndex": return errNotImplemented |