Skip to content

Commit

Permalink
Add command to display private keys from keystore (prysmaticlabs#4793)
Browse files Browse the repository at this point in the history
* Add command to display private keys from keystore

* Update output format

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
  • Loading branch information
2 people authored and cryptomental committed Feb 28, 2020
1 parent 9723394 commit 26a7b94
Showing 1 changed file with 23 additions and 0 deletions.
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("Public key: %#x private key: %#x\n", v.PublicKey.Marshal(), v.SecretKey.Marshal())
}
},
},
},
},
}
Expand Down

0 comments on commit 26a7b94

Please sign in to comment.