github.com/number571/tendermint@v0.34.11-gost/cmd/tendermint/commands/gen_validator.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 8 tmjson "github.com/number571/tendermint/libs/json" 9 "github.com/number571/tendermint/privval" 10 "github.com/number571/tendermint/types" 11 12 "github.com/number571/tendermint/crypto/gost256" 13 "github.com/number571/tendermint/crypto/gost512" 14 ) 15 16 // GenValidatorCmd allows the generation of a keypair for a 17 // validator. 18 var GenValidatorCmd = &cobra.Command{ 19 Use: "gen-validator", 20 Aliases: []string{"gen_validator"}, 21 Short: "Generate new validator keypair", 22 RunE: genValidator, 23 PreRun: deprecateSnakeCase, 24 } 25 26 func init() { 27 GenValidatorCmd.Flags().StringVar(&keyType, "key", types.ABCIPubKeyTypeGost512, 28 "Key type to generate privval file with. Options: '"+gost512.KeyType+"', '"+gost256.KeyType+"'") 29 } 30 31 func genValidator(cmd *cobra.Command, args []string) error { 32 pv, err := privval.GenFilePV("", "", keyType) 33 if err != nil { 34 return err 35 } 36 37 jsbz, err := tmjson.Marshal(pv) 38 if err != nil { 39 return fmt.Errorf("validator -> json: %w", err) 40 } 41 42 fmt.Printf(`%v 43 `, string(jsbz)) 44 45 return nil 46 }