Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Wallet config #186

Merged
merged 2 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
Expand Down
15 changes: 14 additions & 1 deletion settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -182,8 +190,13 @@ func settings() *viper.Viper {
continue
}

defaultValue := v.GetString(keys[i])
if len(defaultValue) == 0 {
continue
}

k := strings.Replace(keys[i], ".", "_", -1)
fmt.Printf("%s_%s = %v\n", Prefix, strings.ToUpper(k), v.Get(keys[i]))
fmt.Printf("%s_%s = %s\n", Prefix, strings.ToUpper(k), defaultValue)
}

fmt.Println()
Expand Down