Skip to content

Commit

Permalink
Update get output api
Browse files Browse the repository at this point in the history
  • Loading branch information
crossle committed Dec 31, 2020
1 parent 2086b70 commit 8a39834
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions multisigs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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
}

0 comments on commit 8a39834

Please sign in to comment.