|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
|
|
|
|
"github.com/spf13/cobra" |
|
|
|
|
|
|
|
cmn "github.com/tendermint/tendermint/libs/common" |
|
|
|
"github.com/tendermint/tendermint/privval" |
|
|
|
) |
|
|
|
|
|
|
@ -12,11 +13,21 @@ import ( |
|
|
|
var ShowValidatorCmd = &cobra.Command{ |
|
|
|
Use: "show_validator", |
|
|
|
Short: "Show this node's validator info", |
|
|
|
Run: showValidator, |
|
|
|
RunE: showValidator, |
|
|
|
} |
|
|
|
|
|
|
|
func showValidator(cmd *cobra.Command, args []string) { |
|
|
|
privValidator := privval.LoadOrGenFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile()) |
|
|
|
pubKeyJSONBytes, _ := cdc.MarshalJSON(privValidator.GetPubKey()) |
|
|
|
fmt.Println(string(pubKeyJSONBytes)) |
|
|
|
func showValidator(cmd *cobra.Command, args []string) error { |
|
|
|
keyFilePath := config.PrivValidatorKeyFile() |
|
|
|
if !cmn.FileExists(keyFilePath) { |
|
|
|
return fmt.Errorf("private validator file %s does not exist", keyFilePath) |
|
|
|
} |
|
|
|
|
|
|
|
pv := privval.LoadFilePV(keyFilePath, config.PrivValidatorStateFile()) |
|
|
|
bz, err := cdc.MarshalJSON(pv.GetPubKey()) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println(string(bz)) |
|
|
|
return nil |
|
|
|
} |