diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 636c0ffbd..cf89eeae9 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -635,6 +635,26 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ }, }, }, + "getproof": { + { + name: "positive", + serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"proof":"256f20ccfbd5f01d5b9633387428b8bab95a9e78c2746573746b657900000000000000000009026d014a060f02000c0c0f0b0d050f00010d050b090603030308070402080b080b0a0b09050a090e07080c020704060507030704060b0605070900000000000000000000000000000000000000092068ae9a1a2c6b6b64216df47b4c44086141569d5d20dc9bd65fdfabed54d2c3250e030c00097465737476616c756500","success":true}}`, + invoke: func(c *Client) (interface{}, error) { + return c.GetProof(util.Uint256{}, util.Uint160{}, []byte{}) + }, + result: func(c *Client) interface{} { + var p result.ProofWithKey + err := p.FromString("256f20ccfbd5f01d5b9633387428b8bab95a9e78c2746573746b657900000000000000000009026d014a060f02000c0c0f0b0d050f00010d050b090603030308070402080b080b0a0b09050a090e07080c020704060507030704060b0605070900000000000000000000000000000000000000092068ae9a1a2c6b6b64216df47b4c44086141569d5d20dc9bd65fdfabed54d2c3250e030c00097465737476616c756500") + if err != nil { + panic(err) + } + return &result.GetProof{ + Result: p, + Success: true, + } + }, + }, + }, "getstateroot": { { name: "positive", diff --git a/pkg/rpc/client/state.go b/pkg/rpc/client/state.go index 6dbc324cf..b3259279d 100644 --- a/pkg/rpc/client/state.go +++ b/pkg/rpc/client/state.go @@ -1,6 +1,8 @@ package client import ( + "encoding/hex" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" @@ -35,3 +37,14 @@ func (c *Client) GetStateHeight() (*result.StateHeight, error) { } return resp, nil } + +// GetProof returns proof that key belongs to a contract sc state rooted at root. +func (c *Client) GetProof(root util.Uint256, sc util.Uint160, key []byte) (*result.GetProof, error) { + var resp result.GetProof + ps := request.NewRawParams(root, sc, hex.EncodeToString(key)) + err := c.performRequest("getproof", ps, &resp) + if err != nil { + return nil, err + } + return &resp, nil +}