From 36ed2ed0ad3b3bf01ef17b6719413a4fa8e49877 Mon Sep 17 00:00:00 2001 From: gguoss <1536310027@qq.com> Date: Mon, 28 Aug 2017 11:16:07 +0800 Subject: [PATCH] Added create-account call in client. --- cmd/bytomcli/main.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cmd/bytomcli/main.go b/cmd/bytomcli/main.go index 3ff9f2dc..6540a643 100644 --- a/cmd/bytomcli/main.go +++ b/cmd/bytomcli/main.go @@ -25,6 +25,7 @@ import ( "github.com/bytom/errors" // "github.com/bytom/generated/rev" "github.com/bytom/log" + "github.com/bytom/crypto/ed25519/chainkd" //"github.com/bytom/protocol/bc" ) @@ -62,6 +63,7 @@ var commands = map[string]*command{ "grant": {grant}, "revoke": {revoke}, "wait": {wait}, + "create-account": {createAccount}, } func main() { @@ -476,3 +478,32 @@ func wait(client *rpc.Client, args []string) { time.Sleep(500 * time.Millisecond) } } + +func createAccount(client *rpc.Client, args []string) { + if len(args) != 1 { + fatalln("error: createAccount takes no args") + } + xprv, err := chainkd.NewXPrv(nil) + if err != nil { + fatalln("NewXprv error.") + } + xpub := xprv.XPub() + fmt.Printf("xprv:%v", xprv) + fmt.Printf("xpub:%v", xpub) + type Ins struct { + RootXPubs []chainkd.XPub `json:"root_xpubs"` + Quorum int + Alias string + Tags map[string]interface{} + ClientToken string `json:"client_token"` + } + var ins Ins + ins.RootXPubs[0] = xpub + ins.Quorum = 1 + ins.Alias = "aa" + ins.ClientToken = args[0] + responses := make([]interface{}, 50) + client.Call(context.Background(), "/create-account", &ins, &responses) + //dieOnRPCError(err) + fmt.Printf("%v", responses) +} -- 2.11.0