diff --git a/multisigs.go b/multisigs.go index edf30f5..678f3fc 100644 --- a/multisigs.go +++ b/multisigs.go @@ -230,12 +230,8 @@ type GhostKeyRequest struct { Hint string `json:"hint"` } -func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint string, uid, sid, sessionKey string) (*GhostKeys, error) { - data, err := json.Marshal(map[string]interface{}{ - "receivers": receivers, - "index": index, - "hint": hint, - }) +func ReadGhostKeys(ctx context.Context, gkr []GhostKeyRequest, uid, sid, sessionKey string) ([]*GhostKeys, error) { + data, err := json.Marshal(gkr) if err != nil { return nil, err } @@ -245,8 +241,8 @@ func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint stri return nil, ServerError(ctx, err) } var resp struct { - Data *GhostKeys `json:"data"` - Error Error `json:"error"` + Data []*GhostKeys `json:"data"` + Error Error `json:"error"` } err = json.Unmarshal(body, &resp) if err != nil { @@ -257,3 +253,18 @@ func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint stri } return resp.Data, nil } + +func ReadGhostKey(ctx context.Context, receivers []string, index int, hint string, uid, sid, sessionKey string) (*GhostKeys, error) { + r := GhostKeyRequest{ + Receivers: receivers, + Index: index, + Hint: hint, + } + + result, err := ReadGhostKeys(ctx, []GhostKeyRequest{r}, uid, sid, sessionKey) + if err != nil { + return nil, err + } + + return result[0], nil +}