Allow creating new accounts to be non-interactive (#6602)

* Allow accounts to be made non-interactively
* Merge branch 'master' of github.com:prysmaticlabs/prysm into make-accounts-noninteractive
* Update validator/node/node.go
* Update validator/accounts/v2/list.go
This commit is contained in:
Ivan Martinez
2020-07-14 19:00:58 -04:00
committed by GitHub
parent eef9a760ec
commit d7bcea7906
8 changed files with 57 additions and 14 deletions

View File

@@ -85,12 +85,14 @@ func DefaultConfig() *Config {
}
// NewKeymanager instantiates a new direct keymanager from configuration options.
func NewKeymanager(ctx context.Context, wallet Wallet, cfg *Config) (*Keymanager, error) {
func NewKeymanager(ctx context.Context, wallet Wallet, cfg *Config, skipMnemonicConfirm bool) (*Keymanager, error) {
k := &Keymanager{
wallet: wallet,
cfg: cfg,
mnemonicGenerator: &EnglishMnemonicGenerator{},
keysCache: make(map[[48]byte]bls.SecretKey),
wallet: wallet,
cfg: cfg,
mnemonicGenerator: &EnglishMnemonicGenerator{
skipMnemonicConfirm: skipMnemonicConfirm,
},
keysCache: make(map[[48]byte]bls.SecretKey),
}
// If the wallet has the capability of unlocking accounts using
// passphrases, then we initialize a cache of public key -> secret keys

View File

@@ -20,7 +20,9 @@ type SeedPhraseFactory interface {
// EnglishMnemonicGenerator implements methods for creating
// mnemonic seed phrases in english using a given
// source of entropy such as a private key.
type EnglishMnemonicGenerator struct{}
type EnglishMnemonicGenerator struct {
skipMnemonicConfirm bool
}
// Generate a mnemonic seed phrase in english using a source of
// entropy given as raw bytes.
@@ -42,6 +44,9 @@ func (m *EnglishMnemonicGenerator) ConfirmAcknowledgement(phrase string) error {
===================================================================
`, phrase)
if m.skipMnemonicConfirm {
return nil
}
// Confirm the user has written down the mnemonic phrase offline.
prompt := promptui.Prompt{
Label: "Confirm you have written down the recovery words somewhere safe (offline)",