diff --git a/docs/rpc.md b/docs/rpc.md index ba025c07d..e035a4eed 100644 --- a/docs/rpc.md +++ b/docs/rpc.md @@ -43,7 +43,6 @@ which would yield the response: | `getblockhash` | | `getblockheader` | | `getblocksysfee` | -| `getclaimable` | | `getconnectioncount` | | `getcontractstate` | | `getnep5balances` | diff --git a/pkg/rpc/client/doc.go b/pkg/rpc/client/doc.go index c21d3ebf4..983d64132 100644 --- a/pkg/rpc/client/doc.go +++ b/pkg/rpc/client/doc.go @@ -27,7 +27,6 @@ Supported methods getblockhash getblockheader getblocksysfee - getclaimable getconnectioncount getcontractstate getnep5balances diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index e0b8326bd..00f58c542 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -187,16 +187,6 @@ func (c *Client) GetBlockSysFee(index uint32) (util.Fixed8, error) { return resp, nil } -// GetClaimable returns tx outputs which can be claimed. -func (c *Client) GetClaimable(address string) (*result.ClaimableInfo, error) { - params := request.NewRawParams(address) - resp := new(result.ClaimableInfo) - if err := c.performRequest("getclaimable", params, resp); err != nil { - return nil, err - } - return resp, nil -} - // GetConnectionCount returns the current number of connections for the node. func (c *Client) GetConnectionCount() (int, error) { var ( diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 31a7fe3cc..4d9bf188c 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -399,36 +399,6 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ }, }, }, - "getclaimable": { - { - name: "positive", - invoke: func(c *Client) (interface{}, error) { - return c.GetClaimable("AGofsxAUDwt52KjaB664GYsqVAkULYvKNt") - }, - serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"claimable":[{"txid":"52ba70ef18e879785572c917795cd81422c3820b8cf44c24846a30ee7376fd77","n":1,"value":800000,"start_height":476496,"end_height":488154,"generated":746.112,"sys_fee": 3.92,"unclaimed":750.032}],"address":"AGofsxAUDwt52KjaB664GYsqVAkULYvKNt","unclaimed": 750.032}}`, - result: func(c *Client) interface{} { - txID, err := util.Uint256DecodeStringLE("52ba70ef18e879785572c917795cd81422c3820b8cf44c24846a30ee7376fd77") - if err != nil { - panic(err) - } - return &result.ClaimableInfo{ - Spents: []result.Claimable{ - { - Tx: txID, - N: 1, - Value: util.Fixed8FromInt64(800000), - StartHeight: 476496, - EndHeight: 488154, - Generated: util.Fixed8FromFloat(746.112), - SysFee: util.Fixed8FromFloat(3.92), - Unclaimed: util.Fixed8FromFloat(750.032), - }}, - Address: "AGofsxAUDwt52KjaB664GYsqVAkULYvKNt", - Unclaimed: util.Fixed8FromFloat(750.032), - } - }, - }, - }, "getconnectioncount": { { name: "positive", @@ -1087,12 +1057,6 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{ return c.GetBlockSysFee(1) }, }, - { - name: "getclaimable_invalid_params_error", - invoke: func(c *Client) (interface{}, error) { - return c.GetClaimable("") - }, - }, { name: "getconnectioncount_invalid_params_error", invoke: func(c *Client) (interface{}, error) { @@ -1269,12 +1233,6 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{ return c.GetBlockSysFee(1) }, }, - { - name: "getclaimable_unmarshalling_error", - invoke: func(c *Client) (interface{}, error) { - return c.GetClaimable("") - }, - }, { name: "getconnectioncount_unmarshalling_error", invoke: func(c *Client) (interface{}, error) { diff --git a/pkg/rpc/response/result/claimable.go b/pkg/rpc/response/result/claimable.go deleted file mode 100644 index 71dbc60b8..000000000 --- a/pkg/rpc/response/result/claimable.go +++ /dev/null @@ -1,22 +0,0 @@ -package result - -import "github.com/nspcc-dev/neo-go/pkg/util" - -// ClaimableInfo is a result of a getclaimable RPC call. -type ClaimableInfo struct { - Spents []Claimable `json:"claimable"` - Address string `json:"address"` - Unclaimed util.Fixed8 `json:"unclaimed"` -} - -// Claimable represents spent outputs which can be claimed. -type Claimable struct { - Tx util.Uint256 `json:"txid"` - N int `json:"n"` - Value util.Fixed8 `json:"value"` - StartHeight uint32 `json:"start_height"` - EndHeight uint32 `json:"end_height"` - Generated util.Fixed8 `json:"generated"` - SysFee util.Fixed8 `json:"sys_fee"` - Unclaimed util.Fixed8 `json:"unclaimed"` -} diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index fad04857e..2e4fe7716 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -88,7 +88,6 @@ var rpcHandlers = map[string]func(*Server, request.Params) (interface{}, *respon "getblockhash": (*Server).getBlockHash, "getblockheader": (*Server).getBlockHeader, "getblocksysfee": (*Server).getBlockSysFee, - "getclaimable": (*Server).getClaimable, "getconnectioncount": (*Server).getConnectionCount, "getcontractstate": (*Server).getContractState, "getnep5balances": (*Server).getNEP5Balances, @@ -522,58 +521,6 @@ func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, *resp return result.NewApplicationLog(appExecResult, scriptHash), nil } -func (s *Server) getClaimable(ps request.Params) (interface{}, *response.Error) { - p, ok := ps.ValueWithType(0, request.StringT) - if !ok { - return nil, response.ErrInvalidParams - } - u, err := p.GetUint160FromAddress() - if err != nil { - return nil, response.ErrInvalidParams - } - - var unclaimed []state.UnclaimedBalance - if acc := s.chain.GetAccountState(u); acc != nil { - err := acc.Unclaimed.ForEach(func(b *state.UnclaimedBalance) error { - unclaimed = append(unclaimed, *b) - return nil - }) - if err != nil { - return nil, response.NewInternalServerError("Unclaimed processing failure", err) - } - } - - var sum util.Fixed8 - claimable := make([]result.Claimable, 0, len(unclaimed)) - for _, ub := range unclaimed { - gen, sys, err := s.chain.CalculateClaimable(ub.Value, ub.Start, ub.End) - if err != nil { - s.log.Info("error while calculating claim bonus", zap.Error(err)) - continue - } - - uc := gen.Add(sys) - sum += uc - - claimable = append(claimable, result.Claimable{ - Tx: ub.Tx, - N: int(ub.Index), - Value: ub.Value, - StartHeight: ub.Start, - EndHeight: ub.End, - Generated: gen, - SysFee: sys, - Unclaimed: uc, - }) - } - - return result.ClaimableInfo{ - Spents: claimable, - Address: p.String(), - Unclaimed: sum, - }, nil -} - func (s *Server) getNEP5Balances(ps request.Params) (interface{}, *response.Error) { p, ok := ps.ValueWithType(0, request.StringT) if !ok { diff --git a/pkg/rpc/server/server_test.go b/pkg/rpc/server/server_test.go index f880cf777..17ac9c414 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/rpc/server/server_test.go @@ -504,40 +504,6 @@ var rpcTestCases = map[string][]rpcTestCase{ fail: true, }, }, - "getclaimable": { - { - name: "no params", - params: "[]", - fail: true, - }, - { - name: "invalid address", - params: `["invalid"]`, - fail: true, - }, - { - name: "normal address", - params: `["` + testchain.MultisigAddress() + `"]`, - result: func(*executor) interface{} { - // hash of the issueTx - h, _ := util.Uint256DecodeStringBE("d3a4f2249fe33b18bde73901c1ecc66200485f1c1dcd941b406a630b479090ae") - amount := util.Fixed8FromInt64(1 * 8) // (endHeight - startHeight) * genAmount[0] - return &result.ClaimableInfo{ - Spents: []result.Claimable{ - { - Tx: h, - Value: util.Fixed8FromInt64(100000000), - EndHeight: 1, - Generated: amount, - Unclaimed: amount, - }, - }, - Address: testchain.MultisigAddress(), - Unclaimed: amount, - } - }, - }, - }, "getconnectioncount": { { params: "[]",