improve claim listing

This commit is contained in:
Niko Storni 2021-03-12 02:06:52 +01:00
parent 3c99b84721
commit 4c3372992c
3 changed files with 9 additions and 6 deletions

View file

@ -220,7 +220,7 @@ func (d *Client) AddressUnused(account *string) (*AddressUnusedResponse, error)
}) })
} }
func (d *Client) ChannelList(account *string, page uint64, pageSize uint64, wid *string) (*ChannelListResponse, error) { func (d *Client) ChannelList(account *string, page uint64, pageSize uint64, wid *string, isSpent bool) (*ChannelListResponse, error) {
if page == 0 { if page == 0 {
return nil, errors.Err("pages start from 1") return nil, errors.Err("pages start from 1")
} }
@ -228,6 +228,7 @@ func (d *Client) ChannelList(account *string, page uint64, pageSize uint64, wid
return response, d.call(response, "channel_list", map[string]interface{}{ return response, d.call(response, "channel_list", map[string]interface{}{
"account_id": account, "account_id": account,
"page": page, "page": page,
"is_spent": isSpent,
"page_size": pageSize, "page_size": pageSize,
"include_protobuf": true, "include_protobuf": true,
"wallet_id": wid, "wallet_id": wid,
@ -437,11 +438,12 @@ func (d *Client) AddressList(account *string, address *string, page uint64, page
return response, d.call(response, "address_list", structs.Map(args)) return response, d.call(response, "address_list", structs.Map(args))
} }
func (d *Client) StreamList(account *string, page uint64, pageSize uint64) (*StreamListResponse, error) { func (d *Client) StreamList(account *string, page uint64, pageSize uint64, isSpent bool) (*StreamListResponse, error) {
response := new(StreamListResponse) response := new(StreamListResponse)
err := d.call(response, "stream_list", map[string]interface{}{ err := d.call(response, "stream_list", map[string]interface{}{
"account_id": account, "account_id": account,
"include_protobuf": true, "include_protobuf": true,
"is_spent": isSpent,
"page": page, "page": page,
"page_size": pageSize, "page_size": pageSize,
}) })

View file

@ -107,7 +107,7 @@ func TestClient_AddressUnused(t *testing.T) {
func TestClient_ChannelList(t *testing.T) { func TestClient_ChannelList(t *testing.T) {
d := NewClient("") d := NewClient("")
got, err := d.ChannelList(nil, 1, 50, nil) got, err := d.ChannelList(nil, 1, 50, nil, false)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
@ -293,7 +293,7 @@ func TestClient_ClaimList(t *testing.T) {
func TestClient_StreamList(t *testing.T) { func TestClient_StreamList(t *testing.T) {
_ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest") _ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest")
d := NewClient("") d := NewClient("")
got, err := d.StreamList(nil, 1, 20) got, err := d.StreamList(nil, 1, 20, false)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
@ -648,7 +648,7 @@ func TestClient_ChannelImport(t *testing.T) {
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
channels, err := d.ChannelList(nil, 1, 50, nil) channels, err := d.ChannelList(nil, 1, 50, nil, false)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
@ -690,7 +690,7 @@ func TestClient_ChannelImportWithWalletID(t *testing.T) {
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
channels, err := d.ChannelList(nil, 1, 50, &wallet.ID) channels, err := d.ChannelList(nil, 1, 50, &wallet.ID, false)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }

View file

@ -320,6 +320,7 @@ type Claim struct {
Address string `json:"address"` Address string `json:"address"`
Amount string `json:"amount"` Amount string `json:"amount"`
CanonicalURL string `json:"canonical_url"` CanonicalURL string `json:"canonical_url"`
ChannelID string `json:"channel_id"`
ClaimID string `json:"claim_id"` ClaimID string `json:"claim_id"`
ClaimOp string `json:"claim_op,omitempty"` ClaimOp string `json:"claim_op,omitempty"`
Confirmations int `json:"confirmations"` Confirmations int `json:"confirmations"`