fix all bits broken by viper API changes (#5982)
github.com/spf13/viper's recent releases introduced a semantic
change in some public API such as viper.IsSet(), which have
broken some of our flags checks. Instead of checking whether
users have changed a flag's default value we should rely on such
defaults and adjust runtime behaviour accordingly. In order to do
so, it's important that we pick sane defaults for all our flags.
The --pruning flag and configuration option now allow for a
fake custom strategy. When users elect custom, then the
pruning-{keep,snapshot}-every options are interpreted and
parsed; else they're ignored.
Zero is pruning-{keep,snapshot}-every default value. When
users choose to set a custom pruning strategy they are
signalling that they want more fine-grainted control, therefore
it's legitimate to expect them to know what they are doing and
enter valid values for both options.
Ref #5964
This commit is contained in:
+4
-11
@@ -190,23 +190,16 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keyring.Keyring, inBuf *buf
|
||||
coinType := uint32(viper.GetInt(flagCoinType))
|
||||
account := uint32(viper.GetInt(flagAccount))
|
||||
index := uint32(viper.GetInt(flagIndex))
|
||||
hdPath := viper.GetString(flagHDPath)
|
||||
|
||||
useBIP44 := !viper.IsSet(flagHDPath)
|
||||
var hdPath string
|
||||
|
||||
if useBIP44 {
|
||||
if len(hdPath) == 0 {
|
||||
hdPath = hd.CreateHDPath(coinType, account, index).String()
|
||||
} else {
|
||||
hdPath = viper.GetString(flagHDPath)
|
||||
} else if viper.GetBool(flags.FlagUseLedger) {
|
||||
return errors.New("cannot set custom bip32 path with ledger")
|
||||
}
|
||||
|
||||
// If we're using ledger, only thing we need is the path and the bech32 prefix.
|
||||
if viper.GetBool(flags.FlagUseLedger) {
|
||||
|
||||
if !useBIP44 {
|
||||
return errors.New("cannot set custom bip32 path with ledger")
|
||||
}
|
||||
|
||||
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()
|
||||
info, err := kb.SaveLedgerKey(name, hd.Secp256k1, bech32PrefixAccAddr, coinType, account, index)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user