diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c0d1d833..89f6014a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Changelog for NeoFS Node ### Fixed - Do not require MainNet attributes in "Without MainNet" mode ([#663](https://github.com/nspcc-dev/neofs-node/issues/663)). - Stable alphabet list merge in Inner Ring governance ([#670](https://github.com/nspcc-dev/neofs-node/issues/670)). +- User can specify only wallet section without node key ([#690](https://github.com/nspcc-dev/neofs-node/pull/690)). ### Removed - Debug output of public key in Inner Ring log ([#689](https://github.com/nspcc-dev/neofs-node/pull/689)). diff --git a/cmd/neofs-node/config/node/config.go b/cmd/neofs-node/config/node/config.go index 2aad548b5..c7f12771c 100644 --- a/cmd/neofs-node/config/node/config.go +++ b/cmd/neofs-node/config/node/config.go @@ -1,7 +1,6 @@ package nodeconfig import ( - "errors" "fmt" "os" "strconv" @@ -18,16 +17,16 @@ const ( attributePrefix = "attribute" ) -var errKeyNotSet = errors.New("empty/not set key address, see `node.key` section") - // Key returns value of "key" config parameter // from "node" section. // -// Panics if value is not a non-empty string. +// If value is not set, fallbacks to Wallet section. +// +// Panics if value is incorrect filename of binary encoded private key. func Key(c *config.Config) *keys.PrivateKey { v := config.StringSafe(c.Sub(subsection), "key") if v == "" { - panic(errKeyNotSet) + return Wallet(c) } var ( @@ -40,13 +39,15 @@ func Key(c *config.Config) *keys.PrivateKey { } if err != nil { - return Wallet(c) + panic(fmt.Errorf("invalid private key in node section: %w", err)) } return key } // Wallet returns value of node private key from "node" section. +// +// Panics if section contains invalid values. func Wallet(c *config.Config) *keys.PrivateKey { v := c.Sub(subsection).Sub("wallet") acc, err := utilConfig.LoadAccount( diff --git a/cmd/neofs-node/config/node/config_test.go b/cmd/neofs-node/config/node/config_test.go index 6e49a8554..54ced7d94 100644 --- a/cmd/neofs-node/config/node/config_test.go +++ b/cmd/neofs-node/config/node/config_test.go @@ -14,9 +14,8 @@ func TestNodeSection(t *testing.T) { t.Run("defaults", func(t *testing.T) { empty := configtest.EmptyConfig() - require.PanicsWithError( + require.Panics( t, - errKeyNotSet.Error(), func() { Key(empty) },