cli: support account creation in existing wallet
This commit is contained in:
parent
20c98411fd
commit
3d67d52537
1 changed files with 28 additions and 0 deletions
|
@ -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",
|
Name: "dump",
|
||||||
Usage: "check and dump an existing NEO wallet",
|
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 {
|
func exportKeys(ctx *cli.Context) error {
|
||||||
path := ctx.String("path")
|
path := ctx.String("path")
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
|
|
Loading…
Reference in a new issue