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

Also use neo-go private key wrapper where possible, as it
already has methods for (un)marshaling.

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 1553967328
commit 3f07313604
17 changed files with 119 additions and 53 deletions

View file

@ -5,8 +5,10 @@ import (
"fmt"
"strconv"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
"github.com/nspcc-dev/neofs-node/pkg/network"
utilConfig "github.com/nspcc-dev/neofs-node/pkg/util/config"
)
const (
@ -36,6 +38,20 @@ func Key(c *config.Config) string {
return v
}
// Wallet returns value of node private key from "node" section.
func Wallet(c *config.Config) *keys.PrivateKey {
v := c.Sub(subsection).Sub("wallet")
acc, err := utilConfig.LoadAccount(
config.String(v, "path"),
config.String(v, "address"),
config.String(v, "password"))
if err != nil {
panic(fmt.Errorf("invalid wallet config: %w", err))
}
return acc.PrivateKey()
}
// BootstrapAddress returns value of "address" config parameter
// from "node" section as network.Address.
//