Skip to content

Commit 172b4ad

Browse files
committed
fix: recover celestia binary
1 parent 2a018fc commit 172b4ad

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cosmosutils/keys.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ func UnmarshalKeyInfo(rawJson string) (KeyInfo, error) {
3535

3636
// AddOrReplace adds or replaces a key using `initiad keys add <keyname> --keyring-backend test` with 'y' confirmation
3737
func AddOrReplace(appName, keyname string) (string, error) {
38-
// Command to add the key: echo 'y' | initiad keys add <keyname> --keyring-backend test
39-
cmd := exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--keyring-backend", "test", "--output", "json")
38+
var cmd *exec.Cmd
39+
if strings.HasSuffix(appName, "celestiad") {
40+
cmd = exec.Command(appName, "keys", "add", keyname, "--keyring-backend", "test", "--output", "json")
41+
} else {
42+
cmd = exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--keyring-backend", "test", "--output", "json")
43+
}
4044
// Simulate pressing 'y' for confirmation
4145
cmd.Stdin = bytes.NewBufferString("y\n")
4246

@@ -77,8 +81,12 @@ func RecoverKeyFromMnemonic(appName, keyname, mnemonic string) (string, error) {
7781
// Add the mnemonic input after the confirmation (if any)
7882
inputBuffer.WriteString(mnemonic + "\n")
7983

80-
// Command to recover (or replace) the key: initiad keys add <keyname> --recover --keyring-backend test
81-
cmd := exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--keyring-backend", "test", "--output", "json")
84+
var cmd *exec.Cmd
85+
if strings.HasSuffix(appName, "celestiad") {
86+
cmd = exec.Command(appName, "keys", "add", keyname, "--recover", "--keyring-backend", "test", "--output", "json")
87+
} else {
88+
cmd = exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--keyring-backend", "test", "--output", "json")
89+
}
8290

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

0 commit comments

Comments
 (0)