Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to display private keys from keystore #4793

Merged
merged 10 commits into from Feb 10, 2020
23 changes: 23 additions & 0 deletions validator/main.go
Expand Up @@ -114,6 +114,29 @@ contract in order to activate the validator client`,
}
},
},
cli.Command{
Name: "keys",
Description: `lists the private keys for 'keystore' keymanager keys`,
Flags: []cli.Flag{
flags.KeystorePathFlag,
flags.PasswordFlag,
},
Action: func(ctx *cli.Context) {
if ctx.String(flags.KeystorePathFlag.Name) == "" {
log.Fatalf("%s is required", flags.KeystorePathFlag.Name)
}
if ctx.String(flags.PasswordFlag.Name) == "" {
log.Fatalf("%s is required", flags.PasswordFlag.Name)
}
keystores, err := accounts.DecryptKeysFromKeystore(ctx.String(flags.KeystorePathFlag.Name), ctx.String(flags.PasswordFlag.Name))
if err != nil {
log.WithError(err).Fatalf("Failed to decrypt keystore keys at path %s", ctx.String(flags.KeystorePathFlag.Name))
}
for _, v := range keystores {
fmt.Printf("Validator %#x has private key %#x\n", v.PublicKey.Marshal(), v.SecretKey.Marshal())
mcdee marked this conversation as resolved.
Show resolved Hide resolved
}
},
},
},
},
}
Expand Down