prysm-pulse/validator/accounts/keys.go
Nishant Das 9b008522b8 Refactor Validator Start Routine (#3594)
* make demo default

* make minimal config a flag

* lint

* initialize config at the start

* gaz

* make main method cleaner

* remove interop.go

* fix test

* lint

* gaz

* Update validator/accounts/interop.go

Co-Authored-By: terence tsao <terence@prysmaticlabs.com>

* fix docker build

* fix docker build
2019-09-26 13:23:25 -05:00

35 lines
816 B
Go

package accounts
import (
"encoding/json"
"io"
"io/ioutil"
)
type unencryptedKeysContainer struct {
Keys []*unencryptedKeys `json:"keys"`
}
type unencryptedKeys struct {
ValidatorKey []byte `json:"validator_key"`
WithdrawalKey []byte `json:"withdrawal_key"`
}
func parseUnencryptedKeysFile(r io.Reader) ([][]byte, [][]byte, error) {
encoded, err := ioutil.ReadAll(r)
if err != nil {
return nil, nil, err
}
var ctnr *unencryptedKeysContainer
if err := json.Unmarshal(encoded, &ctnr); err != nil {
return nil, nil, err
}
validatorKeys := make([][]byte, 0)
withdrawalKeys := make([][]byte, 0)
for _, item := range ctnr.Keys {
validatorKeys = append(validatorKeys, item.ValidatorKey)
withdrawalKeys = append(withdrawalKeys, item.WithdrawalKey)
}
return validatorKeys, withdrawalKeys, nil
}