Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get coin type from config from running command #138

Merged
merged 1 commit into from
Apr 21, 2021
Merged
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
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