dont lose keys (#3357)

This commit is contained in:
skillful-alex 2019-08-30 07:32:08 +03:00 committed by Nishant Das
parent f0332e1131
commit 538babb7e9
2 changed files with 8 additions and 1 deletions

View File

@ -7,7 +7,7 @@ client for fast development startup times instead of using the Prysm keystore.
Usage:
```
bazel run //tools/unencrypted-keys-gen -- --num-keys 64 --output-file /path/to/output.json
bazel run //tools/unencrypted-keys-gen -- --num-keys 64 --output-json /path/to/output.json
```
Which will create 64 BLS private keys each for validator signing and withdrawals.

View File

@ -15,6 +15,7 @@ import (
var (
numKeys = flag.Int("num-keys", 0, "Number of validator private/withdrawal keys to generate")
outputJSON = flag.String("output-json", "", "JSON file to write output to")
overwrite = flag.Bool("overwrite", false, "If the key file exists, it will be overwritten")
)
type unencryptedKeysContainer struct {
@ -35,6 +36,12 @@ func main() {
log.Fatal("Please specify an --output-json file to write the unencrypted keys to")
}
if !*overwrite {
if _, err := os.Stat(*outputJSON); err == nil {
log.Fatal("The file exists. Use a different file name or the --overwrite flag")
}
}
file, err := os.Create(*outputJSON)
if err != nil {
log.Fatal(err)