rpc: implement getunclaimed

closes #712
This commit is contained in:
Anna Shaleva 2020-03-06 20:38:17 +03:00
parent aab7dd515f
commit c23a522d25
5 changed files with 139 additions and 33 deletions

View file

@ -298,6 +298,10 @@ Methods:
gettxoutCalled.Inc()
results, resultsErr = s.getTxOut(reqParams)
case "getunclaimed":
getunclaimedCalled.Inc()
results, resultsErr = s.getUnclaimed(reqParams)
case "getunspents":
getunspentsCalled.Inc()
results, resultsErr = s.getAccountState(reqParams, true)
@ -768,6 +772,25 @@ func (s *Server) getBlockHeader(reqParams request.Params) (interface{}, error) {
return hex.EncodeToString(buf.Bytes()), nil
}
// getUnclaimed returns unclaimed GAS amount of the specified address.
func (s *Server) getUnclaimed(ps request.Params) (interface{}, 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
}
acc := s.chain.GetAccountState(u)
if acc == nil {
return nil, response.NewInternalServerError("unknown account", nil)
}
return result.NewUnclaimed(acc, s.chain)
}
// getValidators returns the current NEO consensus nodes information and voting status.
func (s *Server) getValidators() (interface{}, error) {
var validators keys.PublicKeys