Add AccountCreate method

This commit is contained in:
Andrey Beletsky 2019-04-10 17:23:24 -04:00 committed by Niko Storni
parent 6f0d34f863
commit 5f847fb035
No known key found for this signature in database
GPG key ID: F37FE63398800368
3 changed files with 25 additions and 0 deletions

View file

@ -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{}{

View file

@ -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()
}
}

View file

@ -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"`