github.com/franono/tendermint@v0.32.2-0.20200527150959-749313264ce9/cmd/tendermint/commands/show_validator.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 8 tmos "github.com/franono/tendermint/libs/os" 9 "github.com/franono/tendermint/privval" 10 ) 11 12 // ShowValidatorCmd adds capabilities for showing the validator info. 13 var ShowValidatorCmd = &cobra.Command{ 14 Use: "show_validator", 15 Short: "Show this node's validator info", 16 RunE: showValidator, 17 } 18 19 func showValidator(cmd *cobra.Command, args []string) error { 20 keyFilePath := config.PrivValidatorKeyFile() 21 if !tmos.FileExists(keyFilePath) { 22 return fmt.Errorf("private validator file %s does not exist", keyFilePath) 23 } 24 25 pv := privval.LoadFilePV(keyFilePath, config.PrivValidatorStateFile()) 26 27 pubKey, err := pv.GetPubKey() 28 if err != nil { 29 return fmt.Errorf("can't get pubkey: %w", err) 30 } 31 32 bz, err := cdc.MarshalJSON(pubKey) 33 if err != nil { 34 return fmt.Errorf("failed to marshal private validator pubkey: %w", err) 35 } 36 37 fmt.Println(string(bz)) 38 return nil 39 }