github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/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/ari-anchor/sei-tendermint/libs/json" 9 "github.com/ari-anchor/sei-tendermint/privval" 10 "github.com/ari-anchor/sei-tendermint/types" 11 ) 12 13 // GenValidatorCmd allows the generation of a keypair for a 14 // validator. 15 func MakeGenValidatorCommand() *cobra.Command { 16 var keyType string 17 cmd := &cobra.Command{ 18 Use: "gen-validator", 19 Short: "Generate new validator keypair", 20 RunE: func(cmd *cobra.Command, args []string) error { 21 pv, err := privval.GenFilePV("", "", keyType) 22 if err != nil { 23 return err 24 } 25 26 jsbz, err := tmjson.Marshal(pv) 27 if err != nil { 28 return fmt.Errorf("validator -> json: %w", err) 29 } 30 31 fmt.Printf("%v\n", string(jsbz)) 32 33 return nil 34 }, 35 } 36 37 cmd.Flags().StringVar(&keyType, "key", types.ABCIPubKeyTypeEd25519, 38 "Key type to generate privval file with. Options: ed25519, secp256k1") 39 40 return cmd 41 }