From d8b04223d48d04eb9841c1257569b379f4d5f6b1 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Tue, 2 Aug 2022 00:52:07 +0400 Subject: [PATCH] [#186] Improve wallet params Signed-off-by: Angira Kekteeva --- app.go | 10 ++-------- settings.go | 8 ++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app.go b/app.go index 56cf01a..ee979c4 100644 --- a/app.go +++ b/app.go @@ -181,10 +181,7 @@ func remove(list []string, element string) []string { } func getNeoFSKey(a *app) (*ecdsa.PrivateKey, error) { - walletPath := a.cfg.GetString(cmdWallet) - if len(walletPath) == 0 { - walletPath = a.cfg.GetString(cfgWalletPath) - } + walletPath := a.cfg.GetString(cfgWalletPath) if len(walletPath) == 0 { a.log.Info("no wallet path specified, creating ephemeral key automatically for this run") @@ -205,10 +202,7 @@ func getNeoFSKey(a *app) (*ecdsa.PrivateKey, error) { password = &pwd } - address := a.cfg.GetString(cmdAddress) - if len(address) == 0 { - address = a.cfg.GetString(cfgWalletAddress) - } + address := a.cfg.GetString(cfgWalletAddress) return getKeyFromWallet(w, address, password) } diff --git a/settings.go b/settings.go index 52de560..c9e6648 100644 --- a/settings.go +++ b/settings.go @@ -154,6 +154,14 @@ func settings() *viper.Viper { panic(err) } + if err := v.BindPFlag(cfgWalletPath, flags.Lookup(cmdWallet)); err != nil { + panic(err) + } + + if err := v.BindPFlag(cfgWalletAddress, flags.Lookup(cmdAddress)); err != nil { + panic(err) + } + if err := v.BindPFlags(flags); err != nil { panic(err) }