From 5f847fb03534672808ebe22939a6eaea811bd516 Mon Sep 17 00:00:00 2001 From: Andrey Beletsky Date: Wed, 10 Apr 2019 17:23:24 -0400 Subject: [PATCH] Add AccountCreate method --- extras/jsonrpc/daemon.go | 8 ++++++++ extras/jsonrpc/daemon_test.go | 11 +++++++++++ extras/jsonrpc/daemon_types.go | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/extras/jsonrpc/daemon.go b/extras/jsonrpc/daemon.go index a6c3d5f..7f403fe 100644 --- a/extras/jsonrpc/daemon.go +++ b/extras/jsonrpc/daemon.go @@ -162,6 +162,14 @@ func (d *Client) AccountFund(fromAccount string, toAccount string, amount string }) } +func (d *Client) AccountCreate(accountName string, singleKey bool) (*AccountCreateResponse, error) { + response := new(AccountCreateResponse) + return response, d.call(response, "account_create", map[string]interface{}{ + "account_name": accountName, + "single_key": singleKey, + }) +} + func (d *Client) AddressUnused(account *string) (*AddressUnusedResponse, error) { response := new(AddressUnusedResponse) return response, d.call(response, "address_unused", map[string]interface{}{ diff --git a/extras/jsonrpc/daemon_test.go b/extras/jsonrpc/daemon_test.go index e0bd60d..96b5533 100644 --- a/extras/jsonrpc/daemon_test.go +++ b/extras/jsonrpc/daemon_test.go @@ -216,3 +216,14 @@ func TestClient_AccountFund(t *testing.T) { } log.Infof("%+v", *got) } + +func TestClient_AccountCreate(t *testing.T) { + d := NewClient("") + account, err := d.AccountCreate("test@lbry.com", false) + if err != nil { + t.Error(err) + } + if account.Status != "created" { + t.Fail() + } +} diff --git a/extras/jsonrpc/daemon_types.go b/extras/jsonrpc/daemon_types.go index c4ba2d0..26c4e01 100644 --- a/extras/jsonrpc/daemon_types.go +++ b/extras/jsonrpc/daemon_types.go @@ -200,6 +200,12 @@ type AccountListResponse struct { } type AccountBalanceResponse string +type AccountCreateResponse struct { + Account + Seed string `json:"seed"` + Status string `json:"status"` +} + type Transaction struct { Address string `json:"address"` Amount string `json:"amount"`