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

Gaiacli generates the same address irrespective of the --account argument #3427

Closed
4 tasks
jleni opened this issue Jan 29, 2019 · 6 comments
Closed
4 tasks
Assignees

Comments

@jleni
Copy link
Member

jleni commented Jan 29, 2019

Summary of Bug

When recovering addresses, gaiacli seems to ignore the account argument.

This issue is related to #3345

Steps to Reproduce

Using the same mnemonic, run the following commands:

gaiacli keys add gaia0 --recover --account 0
gaiacli keys add gaia1 --recover --account 1
gaiacli keys add gaia152 --recover --account 152

In all cases, the same address and pubkey will be generated.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@jackzampolin
Copy link
Member

It looks like the --account flag isn't being respected in the gaiacli keys add implementation

@jleni
Copy link
Member Author

jleni commented Jan 29, 2019

yes, I would say that having both --account and --index is a bit confusing

cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation")
cmd.Flags().Uint32(flagIndex, 0, "Index number for HD derivation")

@jleni
Copy link
Member Author

jleni commented Jan 30, 2019

@gamarin2 @alessio FYI

Flags:
      --account uint32            Account number for HD derivation
      --bip44-path string         BIP44 path from which to derive a private key (default "44'/118'/0'/0/0")
      --index uint32              Index number for HD derivation

Now, the confusing part is that:

  • With Ledger:

    • USED: --account and --index ({44, 118, account, 0, index})
    • IGNORED: --bip44-path
  • Without Ledger:

    • IGNORED: --account and --index
    • USED: --bip44-path

This is very confusing and not clear in the docs or flag description.

Reference:

bipFlag := cmd.Flags().Lookup(flagBIP44Path)
bip44Params, err := getBIP44ParamsAndPath(bipFlag.Value.String(), bipFlag.Changed || !interactive)
if err != nil {
return err
}
// If we're using ledger, only thing we need is the path. So generate key and
// we're done.
if viper.GetBool(client.FlagUseLedger) {
account := uint32(viper.GetInt(flagAccount))
index := uint32(viper.GetInt(flagIndex))
path := ccrypto.DerivationPath{44, 118, account, 0, index}
info, err := kb.CreateLedger(name, path, keys.Secp256k1)
if err != nil {
return err
}
printCreate(info, "")
return nil
}

@cwgoes
Copy link
Contributor

cwgoes commented Jan 30, 2019

I think giving the option to specify the full BIP44 path may be a bit dangerous - changing the first two fields could result in conflicts with other coins. Is there any reason a user would need to do that? Unless there is, I would vote to standardize on --account and --index` - and document those better.

@alessio
Copy link
Contributor

alessio commented Jan 30, 2019

I think giving the option to specify the full BIP44 path may be a bit dangerous

I very much agree to that

@jackzampolin
Copy link
Member

Closed by #3461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants