OSDN Git Service

bytomcli add validate-address and list-addresses (#455)
authoroysheng <33340252+oysheng@users.noreply.github.com>
Thu, 22 Mar 2018 02:58:38 +0000 (10:58 +0800)
committerPaladz <yzhu101@uottawa.ca>
Thu, 22 Mar 2018 02:58:38 +0000 (10:58 +0800)
* fix json name for submit transaction

* bytomcli add validate-address and list-addresses

cmd/bytomcli/commands/account.go
cmd/bytomcli/commands/bytomcli.go

index b8e1933..5fe3a91 100755 (executable)
@@ -157,6 +157,38 @@ var createAccountReceiverCmd = &cobra.Command{
        },
 }
 
+var listAddressesCmd = &cobra.Command{
+       Use:   "list-addresses",
+       Short: "List the account addresses",
+       Args:  cobra.NoArgs,
+       Run: func(cmd *cobra.Command, args []string) {
+               data, exitCode := util.ClientCall("/list-addresses")
+               if exitCode != util.Success {
+                       os.Exit(exitCode)
+               }
+
+               printJSONList(data)
+       },
+}
+
+var validateAddressCmd = &cobra.Command{
+       Use:   "validate-address",
+       Short: "validate the account addresses",
+       Args:  cobra.ExactArgs(1),
+       Run: func(cmd *cobra.Command, args []string) {
+               var ins = struct {
+                       Address string `json:"address"`
+               }{Address: args[0]}
+
+               data, exitCode := util.ClientCall("/validate-address", &ins)
+               if exitCode != util.Success {
+                       os.Exit(exitCode)
+               }
+
+               printJSON(data)
+       },
+}
+
 var listBalancesCmd = &cobra.Command{
        Use:   "list-balances",
        Short: "List the accounts balances",
index d2f2deb..4d71042 100644 (file)
@@ -83,6 +83,8 @@ func AddCommands() {
        BytomcliCmd.AddCommand(listAccountsCmd)
        BytomcliCmd.AddCommand(updateAccountTagsCmd)
        BytomcliCmd.AddCommand(createAccountReceiverCmd)
+       BytomcliCmd.AddCommand(listAddressesCmd)
+       BytomcliCmd.AddCommand(validateAddressCmd)
 
        BytomcliCmd.AddCommand(createAssetCmd)
        BytomcliCmd.AddCommand(listAssetsCmd)