Skip to content

Commit

Permalink
cli: support account creation in existing wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
fyrchik committed Feb 21, 2020
1 parent 8a73c6c commit 946cbf6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cli/wallet/wallet.go
Expand Up @@ -53,6 +53,14 @@ func NewCommands() []cli.Command {
},
},
},
{
Name: "create-account",
Usage: "add an account to the existing wallet",
Action: addAccount,
Flags: []cli.Flag{
walletPathFlag,
},
},
{
Name: "dump",
Usage: "check and dump an existing NEO wallet",
Expand Down Expand Up @@ -109,6 +117,26 @@ func NewCommands() []cli.Command {
}}
}

func addAccount(ctx *cli.Context) error {
path := ctx.String("path")
if len(path) == 0 {
return cli.NewExitError(errNoPath, 1)
}

wall, err := wallet.NewWalletFromFile(path)
if err != nil {
return cli.NewExitError(err, 1)
}

defer wall.Close()

if err := createAccount(ctx, wall); err != nil {
return cli.NewExitError(err, 1)
}

return nil
}

func exportKeys(ctx *cli.Context) error {
path := ctx.String("path")
if len(path) == 0 {
Expand Down

0 comments on commit 946cbf6

Please sign in to comment.