mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-07 16:47:07 +00:00
PrivValidator.GetAddress() and PrivValidator.GetPublicKey() return an
error instead of panic
This commit is contained in:
@@ -57,9 +57,13 @@ func initFilesWithConfig(config *cfg.Config) error {
|
||||
GenesisTime: tmtime.Now(),
|
||||
ConsensusParams: types.DefaultConsensusParams(),
|
||||
}
|
||||
key, err := pv.GetPubKey()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
genDoc.Validators = []types.GenesisValidator{{
|
||||
Address: pv.GetPubKey().Address(),
|
||||
PubKey: pv.GetPubKey(),
|
||||
Address: key.Address(),
|
||||
PubKey: key,
|
||||
Power: 10,
|
||||
}}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -17,6 +18,11 @@ var ShowValidatorCmd = &cobra.Command{
|
||||
|
||||
func showValidator(cmd *cobra.Command, args []string) {
|
||||
privValidator := privval.LoadOrGenFilePV(config.PrivValidatorFile())
|
||||
pubKeyJSONBytes, _ := cdc.MarshalJSON(privValidator.GetPubKey())
|
||||
key, err := privValidator.GetPubKey()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not read public key from FilePV %v", privValidator)
|
||||
os.Exit(1)
|
||||
}
|
||||
pubKeyJSONBytes, _ := cdc.MarshalJSON(key)
|
||||
fmt.Println(string(pubKeyJSONBytes))
|
||||
}
|
||||
|
||||
@@ -90,9 +90,13 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
|
||||
|
||||
pvFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidator)
|
||||
pv := privval.LoadFilePV(pvFile)
|
||||
pubKey, err := pv.GetPubKey()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
genVals[i] = types.GenesisValidator{
|
||||
Address: pv.GetPubKey().Address(),
|
||||
PubKey: pv.GetPubKey(),
|
||||
Address: pubKey.Address(),
|
||||
PubKey: pubKey,
|
||||
Power: 1,
|
||||
Name: nodeDirName,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user