[#562] cmd/neofs-cli: use NEP-6 wallet for keys

Encrypted NEP-2 is still supported.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-05-31 11:55:38 +03:00 committed by Alex Vanin
parent 3f07313604
commit fcdef227e4

View file

@ -2,9 +2,7 @@ package cmd
import (
"crypto/ecdsa"
"crypto/rand"
"crypto/tls"
"encoding/hex"
"errors"
"fmt"
"os"
@ -18,7 +16,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/client"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -138,21 +135,11 @@ const nep2Base58Length = 58
func getKey() (*ecdsa.PrivateKey, error) {
privateKey := viper.GetString("key")
if privateKey == generateKeyConst {
buf := make([]byte, crypto.PrivateKeyCompressedSize)
_, err := rand.Read(buf)
priv, err := keys.NewPrivateKey()
if err != nil {
return nil, errCantGenerateKey
}
printVerbose("Generating private key:", hex.EncodeToString(buf))
return crypto.UnmarshalPrivateKey(buf)
}
key, err := crypto.LoadPrivateKey(privateKey)
if err == nil {
return key, nil
return &priv.PrivateKey, nil
}
w, err := wallet.NewWalletFromFile(privateKey)