-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Support adding offline pubkeys to gaiacli keys #3202
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2f420da
Support adding pubkeys to gaiacli keys for constructing publickeys or…
279120d
Revert chaing the bip 39 dependency and add the PENDING.MD entry
fa1924f
Update client/keys/add.go
alexanderbez 544c51c
Update client/keys/add.go
alexanderbez 1856c52
Address PR comments
jackzampolin 9e6804c
Address @alexanderbez comments
jackzampolin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ import ( | |
"net/http" | ||
"os" | ||
|
||
"github.com/cosmos/go-bip39" | ||
"github.com/gorilla/mux" | ||
"github.com/cosmos/go-bip39" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid formatting here. |
||
"github.com/gorilla/mux" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
@@ -18,9 +18,11 @@ import ( | |
ccrypto "github.com/cosmos/cosmos-sdk/crypto" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys/hd" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
const ( | ||
flagPublicKey = "pubkey" | ||
flagInteractive = "interactive" | ||
flagBIP44Path = "bip44-path" | ||
flagRecover = "recover" | ||
|
@@ -46,6 +48,7 @@ If run with --dry-run, a key would be generated (or recovered) but not stored to | |
Args: cobra.ExactArgs(1), | ||
RunE: runAddCmd, | ||
} | ||
cmd.Flags().String(FlagPublicKey, "cosmospub1....", "Store only a public key (useful for constructing multisigs)") | ||
cmd.Flags().BoolP(flagInteractive, "i", false, "Interactively prompt user for BIP39 passphrase and mnemonic") | ||
cmd.Flags().Bool(client.FlagUseLedger, false, "Store a local reference to a private key on a Ledger device") | ||
cmd.Flags().String(flagBIP44Path, "44'/118'/0'/0/0", "BIP44 path from which to derive a private key") | ||
|
@@ -73,6 +76,12 @@ func runAddCmd(cmd *cobra.Command, args []string) error { | |
|
||
buf := client.BufferStdin() | ||
name := args[0] | ||
|
||
interactive := viper.GetBool(flagInteractive) | ||
flags := cmd.Flags() | ||
|
||
pubKeyFlag := flags.Lookup(flagPublicKey) | ||
|
||
if viper.GetBool(flagDryRun) { | ||
// we throw this away, so don't enforce args, | ||
// we want to get a new random seed phrase quickly | ||
|
@@ -94,18 +103,28 @@ func runAddCmd(cmd *cobra.Command, args []string) error { | |
} | ||
|
||
// ask for a password when generating a local key | ||
if !viper.GetBool(client.FlagUseLedger) { | ||
encryptPassword, err = client.GetCheckPassword( | ||
"Enter a passphrase to encrypt your key to disk:", | ||
"Repeat the passphrase:", buf) | ||
if err != nil { | ||
return err | ||
|
||
if !pubKeyFlag.Changed { | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if !viper.GetBool(client.FlagUseLedger) { | ||
encryptPassword, err = client.GetCheckPassword( | ||
"Enter a passphrase to encrypt your key to disk:", | ||
"Repeat the passphrase:", buf) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
} | ||
|
||
interactive := viper.GetBool(flagInteractive) | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
flags := cmd.Flags() | ||
if pubKeyFlag.Changed { | ||
pk, err := sdk.GetAccPubKeyBech32(pubKeyFlag.Value.String()) | ||
if err != nil { | ||
return err | ||
} | ||
kb.CreateOffline(name, pk) | ||
return nil | ||
} | ||
|
||
bipFlag := flags.Lookup(flagBIP44Path) | ||
|
||
bip44Params, err := getBIP44ParamsAndPath(bipFlag.Value.String(), bipFlag.Changed || !interactive) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be reverted