-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: no command to show current pubkey in e2ee (#1513)
* Problem: no command to show current pubkey in e2ee * test e2ee pubkey * Update CHANGELOG.md Signed-off-by: yihuang <huang@crypto.com> --------- Signed-off-by: yihuang <huang@crypto.com>
- Loading branch information
Showing
5 changed files
with
69 additions
and
10 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"filippo.io/age" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/crypto-org-chain/cronos/v2/x/e2ee/keyring" | ||
"github.com/crypto-org-chain/cronos/v2/x/e2ee/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func PubKeyCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "pubkey", | ||
Short: "Show the recipient of current identity stored in keyring", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
krName, err := cmd.Flags().GetString(FlagKeyringName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
kr, err := keyring.New("cronosd", clientCtx.Keyring.Backend(), clientCtx.HomeDir, os.Stdin) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
bz, err := kr.Get(krName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
k, err := age.ParseX25519Identity(string(bz)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println(k.Recipient()) | ||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().String(FlagKeyringName, types.DefaultKeyringName, "The keyring name to use") | ||
|
||
return cmd | ||
} |