rpc/client: ensure compatibility with preview2 C# node for invoke*

It won't work with proper cosigners and the client must be compatible both
with neo-go and C# node. See neo/neo-modules#260 also.
This commit is contained in:
Roman Khimov 2020-07-02 16:00:07 +03:00
parent cc95d559cc
commit 17ea6411a2

View file

@ -369,6 +369,18 @@ func (c *Client) invokeSomething(method string, p request.RawParams, cosigners [
p.Values = append(p.Values, cosigners)
}
if err := c.performRequest(method, p, resp); err != nil {
// Retry with old-fashioned hashes (see neo/neo-modules#260).
if cosigners != nil {
var hashes = make([]util.Uint160, len(cosigners))
for i := range cosigners {
hashes[i] = cosigners[i].Account
}
p.Values[len(p.Values)-1] = hashes
err = c.performRequest(method, p, resp)
if err == nil {
return resp, nil
}
}
return nil, err
}
return resp, nil