Merge pull request #283 from meshplus/fix/key-gen-bug

fix(cmd): fix bitxhub key gen bug when target not set
This commit is contained in:
Alexader 2020-12-14 19:46:33 +08:00 committed by GitHub
commit 9c9078c8e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -398,6 +398,11 @@ func generatePrivKey(ctx *cli.Context, opt crypto.KeyType) error {
name := ctx.String("name")
target := ctx.String("target")
target, err := filepath.Abs(target)
if err != nil {
return fmt.Errorf("get absolute key path: %w", err)
}
privKey, err := asym.GenerateKeyPair(opt)
if err != nil {
return fmt.Errorf("generate key: %w", err)
@ -425,5 +430,6 @@ func generatePrivKey(ctx *cli.Context, opt crypto.KeyType) error {
return fmt.Errorf("pem encode: %w", err)
}
fmt.Printf("%s.priv key is generated under directory %s\n", name, target)
return nil
}

View File

@ -19,7 +19,7 @@ func keyCMD() cli.Command {
Subcommands: []cli.Command{
{
Name: "gen",
Usage: "Create new Secp256k1 private key",
Usage: "Create new Secp256k1 private key in specified directory",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",