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

renamed the legacy-hd-path flag to cosmos-ledger-app, to better refle… #326

Closed
wants to merge 2 commits into from
Closed
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
39 changes: 23 additions & 16 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import (
)

const (
flagInteractive = "interactive"
flagRecover = "recover"
flagNoBackup = "no-backup"
flagCoinType = "coin-type"
flagAccount = "account"
flagIndex = "index"
flagMultisig = "multisig"
flagNoSort = "nosort"
flagHDPath = "hd-path"
flagLegacyHdPath = "legacy-hd-path"
flagInteractive = "interactive"
flagRecover = "recover"
flagNoBackup = "no-backup"
flagCoinType = "coin-type"
flagAccount = "account"
flagIndex = "index"
flagMultisig = "multisig"
flagNoSort = "nosort"
flagHDPath = "hd-path"
flagCosmosLedgerApp = "cosmos-ledger-app"

// DefaultKeyPass contains the default key password for genesis transactions
DefaultKeyPass = "12345678"
Expand Down Expand Up @@ -70,10 +70,17 @@ Example:
f.StringSlice(flagMultisig, nil, "List of key names stored in keyring to construct a public legacy multisig key")
f.Int(flagMultiSigThreshold, 1, "K out of N required signatures. For use in conjunction with --multisig")
f.Bool(flagNoSort, false, "Keys passed to --multisig are taken in the order they're supplied")
f.String(FlagPublicKey, "", "Parse a public key in JSON format and saves key info to <name> file.")
f.String(FlagPublicKey, "", "Parse a public key in JSON format and saves key info to <name> file")
f.BoolP(flagInteractive, "i", false, "Interactively prompt user for BIP39 passphrase and mnemonic")
f.Bool(flags.FlagUseLedger, false, "Store a local reference to a private key on a Ledger device")
f.Bool(flagLegacyHdPath, false, "Flag to specify the command uses old HD path - use this for ledger compatibility")
f.Bool(flags.FlagUseLedger, false, fmt.Sprintf(
"Store a local reference to a private key on a Ledger device (ignores --%s and --%s)",
flagHDPath,
flagCoinType,
))
f.Bool(flagCosmosLedgerApp, false, fmt.Sprintf(
"If using --%s, use the old HD path, which is compatible with Cosmos app",
flags.FlagUseLedger,
))
f.Bool(flagRecover, false, "Provide seed phrase to recover existing key instead of creating")
f.Bool(flagNoBackup, false, "Don't print out seed phrase (if others are watching the terminal)")
f.Bool(flags.FlagDryRun, false, "Perform action, but don't add key to local keystore")
Expand Down Expand Up @@ -208,9 +215,9 @@ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf

// If we're using ledger, only thing we need is the path and the bech32 prefix.
if useLedger {
legacyHdPath, _ := cmd.Flags().GetBool(flagLegacyHdPath)
if legacyHdPath {
coinType = sdk.CoinType
isCosmosLedgerApp, _ := cmd.Flags().GetBool(flagCosmosLedgerApp)
if isCosmosLedgerApp {
coinType = sdk.CoinType // the HD path used on the old cosmos app is the same one as cosmos'
} else {
coinType = DefaultLedgerCoinType
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/ledger/ledger_secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (types.PubKey, error
func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (types.PubKey, string, error) {
publicKey, addr, err := device.GetAddressPubKeySECP256K1(path.DerivationPath(), hrp)
if err != nil {
return nil, "", fmt.Errorf("%w: address rejected for path %s", err, path.String())
return nil, "", fmt.Errorf("%w: address rejected for path %s. Use --cosmos-ledger-app if you're using the old ledger app.", err, path.String())
}

// re-serialize in the 33-byte compressed format
Expand Down