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