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

feat: add coin-type and key-type when generate key #157

Merged
merged 5 commits into from
Mar 12, 2025
Merged
Changes from 1 commit
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
5 changes: 2 additions & 3 deletions cosmosutils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ func UnmarshalKeyInfo(rawJson string) (KeyInfo, error) {
// AddOrReplace adds or replaces a key using `initiad keys add <keyname> --keyring-backend test` with 'y' confirmation
func AddOrReplace(appName, keyname string) (string, error) {
// Command to add the key: echo 'y' | initiad keys add <keyname> --keyring-backend test
cmd := exec.Command(appName, "keys", "add", keyname, "--keyring-backend", "test", "--output", "json")

cmd := exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--keyring-backend", "test", "--output", "json")
// Simulate pressing 'y' for confirmation
cmd.Stdin = bytes.NewBufferString("y\n")

Expand Down Expand Up @@ -79,7 +78,7 @@ func RecoverKeyFromMnemonic(appName, keyname, mnemonic string) (string, error) {
inputBuffer.WriteString(mnemonic + "\n")

// Command to recover (or replace) the key: initiad keys add <keyname> --recover --keyring-backend test
cmd := exec.Command(appName, "keys", "add", keyname, "--recover", "--keyring-backend", "test", "--output", "json")
cmd := exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--keyring-backend", "test", "--output", "json")

// Pass the combined confirmation and mnemonic as input to the command
cmd.Stdin = &inputBuffer
Expand Down