Skip to content

Commit

Permalink
fix: get coin type from config from running command (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Woosang Son authored Apr 21, 2021
1 parent 6057618 commit a70834a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"errors"
"fmt"
"math"
"sort"

bip39 "github.com/cosmos/go-bip39"
Expand Down Expand Up @@ -32,8 +33,9 @@ const (
flagNoSort = "nosort"
flagHDPath = "hd-path"

// DefaultKeyPass contains the default key password for genesis transactions
DefaultKeyPass = "12345678"
// CoinTypeNotAssigned means a coin type not assigned
// lbm-sdk cannot support the coin type MaxUint32
CoinTypeNotAssigned = math.MaxUint32
)

// AddKeyCommand defines a keys command to add a generated or recovered private key to keybase.
Expand Down Expand Up @@ -72,7 +74,7 @@ the flag --nosort is set.
cmd.Flags().Bool(flagNoBackup, false, "Don't print out seed phrase (if others are watching the terminal)")
cmd.Flags().Bool(flags.FlagDryRun, false, "Perform action, but don't add key to local keystore")
cmd.Flags().String(flagHDPath, "", "Manual HD Path derivation (overrides BIP44 config)")
cmd.Flags().Uint32(flagCoinType, sdk.GetConfig().GetCoinType(), "coin type number for HD derivation")
cmd.Flags().Uint32(flagCoinType, CoinTypeNotAssigned, "coin type number for HD derivation")
cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation")
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation")
cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for")
Expand Down Expand Up @@ -199,6 +201,9 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keyring.Keyring, inBuf *buf
}

coinType, _ := cmd.Flags().GetUint32(flagCoinType)
if coinType == CoinTypeNotAssigned {
coinType = sdk.GetConfig().GetCoinType()
}
account, _ := cmd.Flags().GetUint32(flagAccount)
index, _ := cmd.Flags().GetUint32(flagIndex)
hdPath, _ := cmd.Flags().GetString(flagHDPath)
Expand Down

0 comments on commit a70834a

Please sign in to comment.