rpc: drop support for gettxout method

Neo 3 doesn't need it.
This commit is contained in:
Roman Khimov 2020-06-01 22:18:22 +03:00
parent 232e1a2598
commit d856df36a7
7 changed files with 0 additions and 139 deletions

View file

@ -51,7 +51,6 @@ which would yield the response:
| `getrawtransaction` |
| `getstorage` |
| `gettransactionheight` |
| `gettxout` |
| `getunclaimed` |
| `getvalidators` |
| `getversion` |

View file

@ -35,7 +35,6 @@ Supported methods
getrawtransaction
getstorage
gettransactionheight
gettxout
getunclaimed
getvalidators
getversion

View file

@ -307,19 +307,6 @@ func (c *Client) GetTransactionHeight(hash util.Uint256) (uint32, error) {
return resp, nil
}
// GetTxOut returns the corresponding unspent transaction output information (returned change),
// based on the specified hash and index.
func (c *Client) GetTxOut(hash util.Uint256, num int) (*result.TransactionOutput, error) {
var (
params = request.NewRawParams(hash.StringLE(), num)
resp = &result.TransactionOutput{}
)
if err := c.performRequest("gettxout", params, resp); err != nil {
return resp, err
}
return resp, nil
}
// GetUnclaimed returns unclaimed GAS amount of the specified address.
func (c *Client) GetUnclaimed(address string) (*result.Unclaimed, error) {
var (

View file

@ -670,27 +670,6 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
},
},
},
"gettxout": {
{
name: "positive",
invoke: func(c *Client) (interface{}, error) {
hash, err := util.Uint256DecodeStringLE("f4250dab094c38d8265acc15c366dc508d2e14bf5699e12d9df26577ed74d657")
if err != nil {
panic(err)
}
return c.GetTxOut(hash, 0)
},
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"N":0,"Asset":"c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","Value":"2950","Address":"AHCNSDkh2Xs66SzmyKGdoDKY752uyeXDrt"}}`,
result: func(c *Client) interface{} {
return &result.TransactionOutput{
N: 0,
Asset: "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
Value: util.Fixed8FromInt64(2950),
Address: "AHCNSDkh2Xs66SzmyKGdoDKY752uyeXDrt",
}
},
},
},
"getunclaimed": {
{
name: "positive",
@ -1059,12 +1038,6 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
return c.GetTransactionHeight(util.Uint256{})
},
},
{
name: "gettxoutput_invalid_params_error",
invoke: func(c *Client) (interface{}, error) {
return c.GetTxOut(util.Uint256{}, 0)
},
},
{
name: "getunclaimed_invalid_params_error",
invoke: func(c *Client) (interface{}, error) {
@ -1235,12 +1208,6 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
return c.GetTransactionHeight(util.Uint256{})
},
},
{
name: "getxoutput_unmarshalling_error",
invoke: func(c *Client) (interface{}, error) {
return c.GetTxOut(util.Uint256{}, 0)
},
},
{
name: "getunclaimed_unmarshalling_error",
invoke: func(c *Client) (interface{}, error) {

View file

@ -26,12 +26,6 @@ type Raw struct {
Result json.RawMessage `json:"result,omitempty"`
}
// GetTxOut represents result of `gettxout` RPC call.
type GetTxOut struct {
HeaderAndError
Result *result.TransactionOutput
}
// GetRawTx represents verbose output of `getrawtransaction` RPC call.
type GetRawTx struct {
HeaderAndError

View file

@ -96,7 +96,6 @@ var rpcHandlers = map[string]func(*Server, request.Params) (interface{}, *respon
"getrawtransaction": (*Server).getrawtransaction,
"getstorage": (*Server).getStorage,
"gettransactionheight": (*Server).getTransactionHeight,
"gettxout": (*Server).getTxOut,
"getunclaimed": (*Server).getUnclaimed,
"getvalidators": (*Server).getValidators,
"getversion": (*Server).getVersion,
@ -723,40 +722,6 @@ func (s *Server) getTransactionHeight(ps request.Params) (interface{}, *response
return height, nil
}
func (s *Server) getTxOut(ps request.Params) (interface{}, *response.Error) {
p, ok := ps.Value(0)
if !ok {
return nil, response.ErrInvalidParams
}
h, err := p.GetUint256()
if err != nil {
return nil, response.ErrInvalidParams
}
p, ok = ps.ValueWithType(1, request.NumberT)
if !ok {
return nil, response.ErrInvalidParams
}
num, err := p.GetInt()
if err != nil || num < 0 {
return nil, response.ErrInvalidParams
}
tx, _, err := s.chain.GetTransaction(h)
if err != nil {
return nil, response.NewInvalidParamsError(err.Error(), err)
}
if num >= len(tx.Outputs) {
return nil, response.NewInvalidParamsError("invalid index", errors.New("too big index"))
}
out := tx.Outputs[num]
return result.NewTxOutput(&out), nil
}
// getContractState returns contract state (contract information, according to the contract script hash).
func (s *Server) getContractState(reqParams request.Params) (interface{}, *response.Error) {
var results interface{}

View file

@ -312,38 +312,6 @@ var rpcTestCases = map[string][]rpcTestCase{
fail: true,
},
},
"gettxout": {
{
name: "no params",
params: `[]`,
fail: true,
},
{
name: "invalid hash",
params: `["notahex"]`,
fail: true,
},
{
name: "missing hash",
params: `["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0]`,
fail: true,
},
{
name: "invalid index",
params: `["7aadf91ca8ac1e2c323c025a7e492bee2dd90c783b86ebfc3b18db66b530a76d", "string"]`,
fail: true,
},
{
name: "negative index",
params: `["7aadf91ca8ac1e2c323c025a7e492bee2dd90c783b86ebfc3b18db66b530a76d", -1]`,
fail: true,
},
{
name: "too big index",
params: `["7aadf91ca8ac1e2c323c025a7e492bee2dd90c783b86ebfc3b18db66b530a76d", 100]`,
fail: true,
},
},
"getblock": {
{
name: "positive",
@ -966,24 +934,6 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
})
})
t.Run("gettxout", func(t *testing.T) {
block, _ := chain.GetBlock(chain.GetHeaderHash(0))
require.Equal(t, 4, len(block.Transactions))
tx := block.Transactions[2]
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "gettxout", "params": [%s, %d]}"`,
`"`+tx.Hash().StringLE()+`"`, 0)
body := doRPCCall(rpc, httpSrv.URL, t)
res := checkErrGetResult(t, body, false)
var txOut result.TransactionOutput
err := json.Unmarshal(res, &txOut)
require.NoErrorf(t, err, "could not parse response: %s", res)
assert.Equal(t, 0, txOut.N)
assert.Equal(t, "0x787cc0a786adfe829bc2dffc5637e6855c0a82e02deee97dedbc2aac3e0e5e1a", txOut.Asset)
assert.Equal(t, util.Fixed8FromInt64(100000000), txOut.Value)
assert.Equal(t, testchain.MultisigAddress(), txOut.Address)
})
t.Run("getrawmempool", func(t *testing.T) {
mp := chain.GetMemPool()
// `expected` stores hashes of previously added txs