cli: use AddressFlag for dump-keys
This commit is contained in:
parent
df24c51262
commit
4edc62148b
1 changed files with 7 additions and 10 deletions
|
@ -137,7 +137,7 @@ func NewCommands() []cli.Command {
|
||||||
Action: dumpKeys,
|
Action: dumpKeys,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
walletPathFlag,
|
walletPathFlag,
|
||||||
cli.StringFlag{
|
flags.AddressFlag{
|
||||||
Name: "address, a",
|
Name: "address, a",
|
||||||
Usage: "address to print public keys for",
|
Usage: "address to print public keys for",
|
||||||
},
|
},
|
||||||
|
@ -568,13 +568,10 @@ func dumpKeys(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
accounts := wall.Accounts
|
accounts := wall.Accounts
|
||||||
addr := ctx.String("address")
|
|
||||||
if addr != "" {
|
addrFlag := ctx.Generic("address").(*flags.Address)
|
||||||
u, err := flags.ParseAddress(addr)
|
if addrFlag.IsSet {
|
||||||
if err != nil {
|
acc := wall.GetAccount(addrFlag.Uint160())
|
||||||
return cli.NewExitError(fmt.Errorf("invalid address: %w", err), 1)
|
|
||||||
}
|
|
||||||
acc := wall.GetAccount(u)
|
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
return cli.NewExitError("account is missing", 1)
|
return cli.NewExitError("account is missing", 1)
|
||||||
}
|
}
|
||||||
|
@ -605,8 +602,8 @@ func dumpKeys(ctx *cli.Context) error {
|
||||||
hasPrinted = true
|
hasPrinted = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if addr != "" {
|
if addrFlag.IsSet {
|
||||||
return cli.NewExitError(fmt.Errorf("Unknown script type for address %s", addr), 1)
|
return cli.NewExitError(fmt.Errorf("Unknown script type for address %s", address.Uint160ToString(addrFlag.Uint160())), 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue