MCPcopy
hub / github.com/canopy-network/canopy / keystoreNewKey

Function keystoreNewKey

plugin/go/tutorial/rpc_test.go:202–216  ·  view source on GitHub ↗

keystoreNewKey creates a new key in the keystore using raw JSON

(rpcURL, nickname, password string)

Source from the content-addressed store, hash-verified

200
201// keystoreNewKey creates a new key in the keystore using raw JSON
202func keystoreNewKey(rpcURL, nickname, password string) (string, error) {
203 reqJSON := fmt.Sprintf(`{"nickname":"%s","password":"%s"}`, nickname, password)
204
205 respBody, err := postRawJSON(rpcURL+"/v1/admin/keystore-new-key", reqJSON)
206 if err != nil {
207 return "", err
208 }
209
210 var address string
211 if err := json.Unmarshal(respBody, &address); err != nil {
212 return "", fmt.Errorf("failed to parse response: %v, body: %s", err, string(respBody))
213 }
214
215 return address, nil
216}
217
218// keystoreGetKey gets the key info from the keystore using raw JSON
219func keystoreGetKey(rpcURL, address, password string) (*keyGroup, error) {

Callers 1

TestPluginTransactionsFunction · 0.70

Calls 3

postRawJSONFunction · 0.70
UnmarshalMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected