align to new SDK v0.42.0

This commit is contained in:
Niko Storni 2019-09-24 18:31:01 +02:00
parent af728f12d9
commit 025c715ab4
3 changed files with 60 additions and 45 deletions

View file

@ -408,11 +408,18 @@ func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blo
return response, nil return response, nil
} }
func (d *Client) AddressList(account *string) (*AddressListResponse, error) { func (d *Client) AddressList(account *string, address *string) (*AddressListResponse, error) {
response := new(AddressListResponse) response := new(AddressListResponse)
return response, d.call(response, "address_list", map[string]interface{}{
"account_id": account, args := struct {
}) AccountID *string `json:"account_id,omitempty"`
Address *string `json:"address,omitempty"`
}{
AccountID: account,
Address: address,
}
structs.DefaultTagName = "json"
return response, d.call(response, "address_list", structs.Map(args))
} }
func (d *Client) ClaimList(account *string, page uint64, pageSize uint64) (*ClaimListResponse, error) { func (d *Client) ClaimList(account *string, page uint64, pageSize uint64) (*ClaimListResponse, error) {

View file

@ -250,7 +250,7 @@ func TestClient_ChannelAbandon(t *testing.T) {
func TestClient_AddressList(t *testing.T) { func TestClient_AddressList(t *testing.T) {
d := NewClient("") d := NewClient("")
got, err := d.AddressList(nil) got, err := d.AddressList(nil, nil)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
@ -269,6 +269,17 @@ func TestClient_ClaimList(t *testing.T) {
prettyPrint(*got) prettyPrint(*got)
} }
func TestClient_TransactionList(t *testing.T) {
_ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest")
d := NewClient("")
got, err := d.TransactionList(nil)
if err != nil {
t.Error(err)
return
}
prettyPrint(*got)
}
func TestClient_SupportTest(t *testing.T) { func TestClient_SupportTest(t *testing.T) {
_ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest") _ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest")
d := NewClient("") d := NewClient("")

View file

@ -270,7 +270,12 @@ type AccountFundResponse TransactionSummary
type Address string type Address string
type AddressUnusedResponse Address type AddressUnusedResponse Address
type AddressListResponse []Address type AddressListResponse []struct {
Account string `json:"account"`
Address Address `json:"address"`
Pubkey string `json:"pubkey"`
UsedTimes uint64 `json:"used_times"`
}
type ChannelExportResponse string type ChannelExportResponse string
type ChannelListResponse struct { type ChannelListResponse struct {
@ -473,45 +478,37 @@ type UTXOListResponse []struct {
type UTXOReleaseResponse *string type UTXOReleaseResponse *string
type transactionListBlob struct {
Address string `json:"address"`
Amount string `json:"amount"`
BalanceDelta string `json:"balance_delta"`
ClaimId string `json:"claim_id"`
ClaimName string `json:"claim_name"`
Nout int `json:"nout"`
}
//TODO: this repeats all the fields from transactionListBlob which doesn't make sense
// but if i extend the type with transactionListBlob it doesn't fill the fields. does our unmarshaller crap out on these?
type supportBlob struct {
Address string `json:"address"`
Amount string `json:"amount"`
BalanceDelta string `json:"balance_delta"`
ClaimId string `json:"claim_id"`
ClaimName string `json:"claim_name"`
Nout int `json:"nout"`
IsTip bool `json:"is_tip"`
}
type TransactionListResponse []struct { type TransactionListResponse []struct {
AbandonInfo struct { AbandonInfo []transactionListBlob `json:"abandon_info"`
Address string `json:"address"` ClaimInfo []transactionListBlob `json:"claim_info"`
Amount string `json:"amount"`
BalanceDelta string `json:"balance_delta"`
ClaimId string `json:"claim_id"`
ClaimName string `json:"claim_name"`
Nout int `json:"nout"`
} `json:"abandon_info"`
ClaimInfo struct {
Address string `json:"address"`
Amount string `json:"amount"`
BalanceDelta string `json:"balance_delta"`
ClaimId string `json:"claim_id"`
ClaimName string `json:"claim_name"`
Nout int `json:"nout"`
} `json:"claim_info"`
Confirmations int64 `json:"confirmations"` Confirmations int64 `json:"confirmations"`
Date string `json:"date"` Date string `json:"date"`
Fee string `json:"fee"` Fee string `json:"fee"`
SupportInfo struct { SupportInfo []supportBlob `json:"support_info"`
Address string `json:"address"`
Amount string `json:"amount"`
BalanceDelta string `json:"balance_delta"`
ClaimId string `json:"claim_id"`
ClaimName string `json:"claim_name"`
IsTip bool `json:"is_tip"`
Nout int `json:"nout"`
} `json:"support_info"`
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
Txid string `json:"txid"` Txid string `json:"txid"`
UpdateInfo struct { UpdateInfo []transactionListBlob `json:"update_info"`
Address string `json:"address"`
Amount string `json:"amount"`
BalanceDelta string `json:"balance_delta"`
ClaimId string `json:"claim_id"`
ClaimName string `json:"claim_name"`
Nout int `json:"nout"`
} `json:"update_info"`
Value string `json:"value"` Value string `json:"value"`
} }