From d3daaafbe4e7c70f691e7f2a9f3ff9efd1244826 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Sep 2020 18:43:47 +0300 Subject: [PATCH] rpc: allow to get contract scripthash from address, id or name [Server] ... for `invokefunction` RPC method. --- docs/rpc.md | 4 ++++ pkg/rpc/server/server.go | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/rpc.md b/docs/rpc.md index 045dc83db..f4189d80b 100644 --- a/docs/rpc.md +++ b/docs/rpc.md @@ -70,6 +70,10 @@ key in the server which doesn't fit the model of our node-client interactions. Lacking this signature the transaction is almost useless, so there is no point in returning it. +It's possible to use `invokefunction` not only with contract scripthash, but also +with contract name (for native contracts) or contract ID (for all contracts). This +feature is not supported by the C# node. + Both methods also don't currently support arrays in function parameters. ##### `getunclaimedgas` diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index d820d8332..92ef4b7d9 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -984,9 +984,9 @@ func (s *Server) getCommittee(_ request.Params) (interface{}, *response.Error) { // invokeFunction implements the `invokeFunction` RPC call. func (s *Server) invokeFunction(reqParams request.Params) (interface{}, *response.Error) { - scriptHash, err := reqParams.ValueWithType(0, request.StringT).GetUint160FromHex() - if err != nil { - return nil, response.ErrInvalidParams + scriptHash, responseErr := s.contractScriptHashFromParam(reqParams.Value(0)) + if responseErr != nil { + return nil, responseErr } tx := &transaction.Transaction{} checkWitnessHashesIndex := len(reqParams)