Skip to content

Commit

Permalink
Force manual validator account creation (#6165)
Browse files Browse the repository at this point in the history
* Force manual validator account creation

* Fix

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
0xKiwi and prylabs-bulldozer[bot] committed Jun 8, 2020
1 parent 8ffe985 commit cb2813f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 4 additions & 7 deletions validator/keymanager/direct_keystore.go
Expand Up @@ -2,6 +2,7 @@ package keymanager

import (
"encoding/json"
"errors"
"os"
"strings"

Expand Down Expand Up @@ -53,13 +54,7 @@ func NewKeystore(input string) (KeyManager, string, error) {
if err != nil {
return nil, keystoreOptsHelp, err
}
if !exists {
// If an account does not exist, we create a new one and start the node.
opts.Path, opts.Passphrase, err = accounts.CreateValidatorAccount(opts.Path, opts.Passphrase)
if err != nil {
return nil, keystoreOptsHelp, err
}
} else {
if exists {
if opts.Passphrase == "" {
log.Info("Enter your validator account password:")
bytePassword, err := terminal.ReadPassword(int(os.Stdin.Fd()))
Expand All @@ -73,6 +68,8 @@ func NewKeystore(input string) (KeyManager, string, error) {
if err := accounts.VerifyAccountNotExists(opts.Path, opts.Passphrase); err == nil {
log.Info("No account found, creating new validator account...")
}
} else {
return nil, "", errors.New("no validator keys found, please use validator accounts create")
}

keyMap, err := accounts.DecryptKeysFromKeystore(opts.Path, params.BeaconConfig().ValidatorPrivkeyFileName, opts.Passphrase)
Expand Down
6 changes: 4 additions & 2 deletions validator/node/node.go
Expand Up @@ -295,8 +295,10 @@ func selectKeyManager(ctx *cli.Context) (keymanager.KeyManager, error) {
return nil, fmt.Errorf("unknown keymanager %q", manager)
}
if err != nil {
// Print help for the keymanager
fmt.Println(help)
if help != "" {
// Print help for the keymanager
fmt.Println(help)
}
return nil, err
}
return km, nil
Expand Down

0 comments on commit cb2813f

Please sign in to comment.