cli: support account creation in existing wallet

This commit is contained in:
Evgenii Stratonikov 2020-02-20 16:39:15 +03:00
parent 20c98411fd
commit 3d67d52537

View file

@ -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",
@ -108,6 +116,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 {