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:
commit
9c9078c8e5
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue