From 2a018fc7141c018b820ff5aab16bf3f8e3f4b63b Mon Sep 17 00:00:00 2001 From: benzbeeb Date: Tue, 11 Mar 2025 11:36:12 +0700 Subject: [PATCH 1/4] feat: add coin-type and key-type when generate key --- cosmosutils/keys.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cosmosutils/keys.go b/cosmosutils/keys.go index 28220eb..4d95a0a 100644 --- a/cosmosutils/keys.go +++ b/cosmosutils/keys.go @@ -36,8 +36,7 @@ func UnmarshalKeyInfo(rawJson string) (KeyInfo, error) { // AddOrReplace adds or replaces a key using `initiad keys add --keyring-backend test` with 'y' confirmation func AddOrReplace(appName, keyname string) (string, error) { // Command to add the key: echo 'y' | initiad keys add --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") @@ -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 --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 From 172b4adcb1fbaedc3ddde0412d8b2bb1d8b0091b Mon Sep 17 00:00:00 2001 From: benzbeeb Date: Tue, 11 Mar 2025 15:33:00 +0700 Subject: [PATCH 2/4] fix: recover celestia binary --- cosmosutils/keys.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cosmosutils/keys.go b/cosmosutils/keys.go index 4d95a0a..8bd8b88 100644 --- a/cosmosutils/keys.go +++ b/cosmosutils/keys.go @@ -35,8 +35,12 @@ func UnmarshalKeyInfo(rawJson string) (KeyInfo, error) { // AddOrReplace adds or replaces a key using `initiad keys add --keyring-backend test` with 'y' confirmation func AddOrReplace(appName, keyname string) (string, error) { - // Command to add the key: echo 'y' | initiad keys add --keyring-backend test - cmd := exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--keyring-backend", "test", "--output", "json") + var cmd *exec.Cmd + if strings.HasSuffix(appName, "celestiad") { + cmd = exec.Command(appName, "keys", "add", keyname, "--keyring-backend", "test", "--output", "json") + } else { + 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") @@ -77,8 +81,12 @@ func RecoverKeyFromMnemonic(appName, keyname, mnemonic string) (string, error) { // Add the mnemonic input after the confirmation (if any) inputBuffer.WriteString(mnemonic + "\n") - // Command to recover (or replace) the key: initiad keys add --recover --keyring-backend test - cmd := exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--keyring-backend", "test", "--output", "json") + var cmd *exec.Cmd + if strings.HasSuffix(appName, "celestiad") { + cmd = exec.Command(appName, "keys", "add", keyname, "--recover", "--keyring-backend", "test", "--output", "json") + } else { + 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 From 5a0d6362a7c9b28c689d746dd2cc6f612b90a6d9 Mon Sep 17 00:00:00 2001 From: benzbeeb Date: Tue, 11 Mar 2025 16:03:46 +0700 Subject: [PATCH 3/4] fix: app name --- cosmosutils/keys.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cosmosutils/keys.go b/cosmosutils/keys.go index 8bd8b88..71f20ad 100644 --- a/cosmosutils/keys.go +++ b/cosmosutils/keys.go @@ -36,7 +36,7 @@ func UnmarshalKeyInfo(rawJson string) (KeyInfo, error) { // AddOrReplace adds or replaces a key using `initiad keys add --keyring-backend test` with 'y' confirmation func AddOrReplace(appName, keyname string) (string, error) { var cmd *exec.Cmd - if strings.HasSuffix(appName, "celestiad") { + if strings.HasSuffix(appName, "celestia-appd") { cmd = exec.Command(appName, "keys", "add", keyname, "--keyring-backend", "test", "--output", "json") } else { cmd = exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--keyring-backend", "test", "--output", "json") @@ -82,7 +82,7 @@ func RecoverKeyFromMnemonic(appName, keyname, mnemonic string) (string, error) { inputBuffer.WriteString(mnemonic + "\n") var cmd *exec.Cmd - if strings.HasSuffix(appName, "celestiad") { + if strings.HasSuffix(appName, "celestia-appd") { cmd = exec.Command(appName, "keys", "add", keyname, "--recover", "--keyring-backend", "test", "--output", "json") } else { cmd = exec.Command(appName, "keys", "add", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--keyring-backend", "test", "--output", "json") From b36d41c850f3b10683b53c95a76d6d360eae4968 Mon Sep 17 00:00:00 2001 From: benzbeeb Date: Tue, 11 Mar 2025 20:13:05 +0700 Subject: [PATCH 4/4] feat: opinit-bots --- cosmosutils/keys.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cosmosutils/keys.go b/cosmosutils/keys.go index 71f20ad..9840db9 100644 --- a/cosmosutils/keys.go +++ b/cosmosutils/keys.go @@ -155,9 +155,9 @@ func OPInitRecoverKeyFromMnemonic(appName, keyname, mnemonic string, isCelestia // Add the mnemonic input after the confirmation (if any) inputBuffer.WriteString(mnemonic + "\n") if isCelestia { - cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--recover", "--bech32", "celestia", "--home", opInitHome) + cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--bech32", "celestia", "--home", opInitHome) } else { - cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--recover", "--home", opInitHome) + cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--recover", "--home", opInitHome) } // Pass the combined confirmation and mnemonic as input to the command cmd.Stdin = &inputBuffer @@ -248,9 +248,9 @@ func OPInitAddOrReplace(appName, keyname string, isCelestia bool, opInitHome str var cmd *exec.Cmd if isCelestia { - cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--bech32", "celestia", "--home", opInitHome) + cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--bech32", "celestia", "--home", opInitHome) } else { - cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--home", opInitHome) + cmd = exec.Command(appName, "keys", "add", "weave-dummy", keyname, "--coin-type", "118", "--key-type", "secp256k1", "--home", opInitHome) } // Simulate pressing 'y' for confirmation