Skip to content

Commit

Permalink
Check whether key passed with --name exists before redirecting to tx …
Browse files Browse the repository at this point in the history
…create-validator

Closes: #2804
  • Loading branch information
Alessio Treglia committed Nov 16, 2018
1 parent 7b7d45d commit f2b3887
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/gaia/init/gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package init
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
Expand Down Expand Up @@ -61,6 +62,14 @@ following delegation and commission default parameters:
return err
}

kb, err := keys.GetKeyBaseFromDir(viper.GetString(flagClientHome))
if err != nil {
return err
}
if _, err = kb.Get(viper.GetString(client.FlagName)); err != nil {
return err
}

// Read --pubkey, if empty take it from priv_validator.json
if valPubKeyString := viper.GetString(cli.FlagPubKey); valPubKeyString != "" {
valPubKey, err = sdk.GetConsPubKeyBech32(valPubKeyString)
Expand Down

0 comments on commit f2b3887

Please sign in to comment.