Accounts V2: Allow user to override password-dir set in the wallet config (#6817)

* Accounts V2: Log a warning when a user specifies --password-dir when it has already been set.
* Override wallet config, as user intended
* gofmt
* Merge refs/heads/master into av2-flag-improvement
This commit is contained in:
Preston Van Loon 2020-07-31 14:20:56 -07:00 committed by GitHub
parent dbd2d9a0bb
commit 821f2ec029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,6 +175,16 @@ func OpenWallet(cliCtx *cli.Context) (*Wallet, error) {
return nil, err
}
w.passwordsDir = directCfg.AccountPasswordsDirectory
// If the user provided a flag and for the password directory, and that value does not match
// the wallet's configuration then log a warning to the user.
// See https://github.com/prysmaticlabs/prysm/issues/6794.
if cliCtx.IsSet(flags.WalletPasswordsDirFlag.Name) && cliCtx.String(flags.WalletPasswordsDirFlag.Name) != w.passwordsDir {
log.Warnf("The provided value for --%s does not match the wallet configuration. "+
"Please edit your wallet password directory using wallet-v2 edit-config.",
flags.WalletPasswordsDirFlag.Name,
)
w.passwordsDir = cliCtx.String(flags.WalletPasswordsDirFlag.Name) // Override config value.
}
au := aurora.NewAurora(true)
log.Infof("%s %s", au.BrightMagenta("(account passwords path)"), w.passwordsDir)
}