From 3d67d525373cc513abc2b88aec929310532cf1c4 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 20 Feb 2020 16:39:15 +0300 Subject: [PATCH] cli: support account creation in existing wallet --- cli/wallet/wallet.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cli/wallet/wallet.go b/cli/wallet/wallet.go index c0bd070e0..01ba11014 100644 --- a/cli/wallet/wallet.go +++ b/cli/wallet/wallet.go @@ -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 {