Skip to content

Commit dd0c0a2

Browse files
authored
[CRE-1000] simplify capabilities - add OCR2 keys export fn (#2186)
1 parent 53751a5 commit dd0c0a2

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

framework/.changeset/v0.10.35.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add function that exports OCR2 keys to the clnode's REST client

framework/clclient/client.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,22 @@ func (c *ChainlinkClient) DeleteOCR2Key(id string) (*http.Response, error) {
548548
return resp.RawResponse, err
549549
}
550550

551+
func (c *ChainlinkClient) ExportOCR2Key(id string) (*ExportedOCR2Key, *http.Response, error) {
552+
ocr2Key := &ExportedOCR2Key{}
553+
framework.L.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Exporting OCR2 Key")
554+
resp, err := c.APIClient.R().
555+
SetResult(ocr2Key).
556+
SetPathParams(map[string]string{
557+
"id": id,
558+
}).
559+
SetQueryParam("newpassword", ChainlinkKeyPassword).
560+
Post("/v2/keys/ocr2/export/{id}")
561+
if err != nil {
562+
return nil, nil, err
563+
}
564+
return ocr2Key, resp.RawResponse, err
565+
}
566+
551567
// CreateP2PKey creates an P2PKey on the Chainlink node
552568
func (c *ChainlinkClient) CreateP2PKey() (*P2PKey, *http.Response, error) {
553569
p2pKey := &P2PKey{}

framework/clclient/models.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,31 @@ type OCR2KeyAttributes struct {
275275
OnChainPublicKey string `json:"onchainPublicKey"`
276276
}
277277

278+
type ExportedOCR2Key struct {
279+
KeyType string `json:"keyType"`
280+
ChainType string `json:"chainType"`
281+
ID string `json:"id"`
282+
OnchainPublicKey string `json:"onchainPublicKey"`
283+
OffchainPublicKey string `json:"offchainPublicKey"`
284+
ConfigPublicKey string `json:"configPublicKey"`
285+
Crypto struct {
286+
Cipher string `json:"cipher"`
287+
Ciphertext string `json:"ciphertext"`
288+
Cipherparams struct {
289+
Iv string `json:"iv"`
290+
} `json:"cipherparams"`
291+
Kdf string `json:"kdf"`
292+
Kdfparams struct {
293+
Dklen int `json:"dklen"`
294+
N int `json:"n"`
295+
P int `json:"p"`
296+
R int `json:"r"`
297+
Salt string `json:"salt"`
298+
} `json:"kdfparams"`
299+
Mac string `json:"mac"`
300+
} `json:"crypto"`
301+
}
302+
278303
// P2PKeys is the model that represents the created P2P keys when read
279304
type P2PKeys struct {
280305
Data []P2PKeyData `json:"data"`

0 commit comments

Comments
 (0)