Skip to content

Commit

Permalink
Revert "[nspcc-dev#610] neofs-cli: replace --key flag with --wif"
Browse files Browse the repository at this point in the history
This reverts commit c172fcc.
  • Loading branch information
Abhimanyu121 committed Jul 27, 2021
1 parent a6e70fc commit 00e46c6
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions cmd/neofs-cli/modules/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func init() {
rootCmd.PersistentFlags().StringP("binary-key", "", "", "path to the raw private key file")
_ = viper.BindPFlag("binary-key", rootCmd.PersistentFlags().Lookup("binary-key"))

rootCmd.PersistentFlags().StringP("wif", "", "", "WIF or NEP-2")
_ = viper.BindPFlag("wif", rootCmd.PersistentFlags().Lookup("wif"))
rootCmd.PersistentFlags().StringP("key", "k", "", "private key in hex, WIF, NEP-2 or filepath")
_ = viper.BindPFlag("key", rootCmd.PersistentFlags().Lookup("key"))

rootCmd.PersistentFlags().StringP("wallet", "w", "", "path to the wallet")
_ = viper.BindPFlag("wallet", rootCmd.PersistentFlags().Lookup("wallet"))
Expand Down Expand Up @@ -176,17 +176,12 @@ func getKey() (*ecdsa.PrivateKey, error) {
return getKeyFromWallet(w, viper.GetString("address"))
}

wif := viper.GetString("wif")
if len(wif) == nep2Base58Length {
return getKeyFromNEP2(wif)
privateKey := viper.GetString("key")
if len(privateKey) == nep2Base58Length {
return getKeyFromNEP2(privateKey)
}

priv, err := keys.NewPrivateKeyFromWIF(wif)
if err != nil {
return nil, fmt.Errorf("%w: %v", errInvalidKey, err)
}

return &priv.PrivateKey, nil
return nil, errInvalidKey
}

func getKeyFromFile(keyPath string) (*ecdsa.PrivateKey, error) {
Expand Down

0 comments on commit 00e46c6

Please sign in to comment.