From 025c715ab4500551ec9e537c25dc862bd6efaeeb Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 24 Sep 2019 18:31:01 +0200 Subject: [PATCH] align to new SDK v0.42.0 --- extras/jsonrpc/daemon.go | 15 +++++-- extras/jsonrpc/daemon_test.go | 13 +++++- extras/jsonrpc/daemon_types.go | 77 ++++++++++++++++------------------ 3 files changed, 60 insertions(+), 45 deletions(-) diff --git a/extras/jsonrpc/daemon.go b/extras/jsonrpc/daemon.go index b194393..7e8ed52 100644 --- a/extras/jsonrpc/daemon.go +++ b/extras/jsonrpc/daemon.go @@ -408,11 +408,18 @@ func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blo return response, nil } -func (d *Client) AddressList(account *string) (*AddressListResponse, error) { +func (d *Client) AddressList(account *string, address *string) (*AddressListResponse, error) { 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) { diff --git a/extras/jsonrpc/daemon_test.go b/extras/jsonrpc/daemon_test.go index 8736fbb..b66aba2 100644 --- a/extras/jsonrpc/daemon_test.go +++ b/extras/jsonrpc/daemon_test.go @@ -250,7 +250,7 @@ func TestClient_ChannelAbandon(t *testing.T) { func TestClient_AddressList(t *testing.T) { d := NewClient("") - got, err := d.AddressList(nil) + got, err := d.AddressList(nil, nil) if err != nil { t.Error(err) return @@ -269,6 +269,17 @@ func TestClient_ClaimList(t *testing.T) { 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) { _ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest") d := NewClient("") diff --git a/extras/jsonrpc/daemon_types.go b/extras/jsonrpc/daemon_types.go index e83ed9e..39be1d9 100644 --- a/extras/jsonrpc/daemon_types.go +++ b/extras/jsonrpc/daemon_types.go @@ -270,7 +270,12 @@ type AccountFundResponse TransactionSummary type Address string 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 ChannelListResponse struct { @@ -473,46 +478,38 @@ type UTXOListResponse []struct { 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 { - AbandonInfo 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:"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"` - Date string `json:"date"` - Fee string `json:"fee"` - SupportInfo struct { - 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"` - Txid string `json:"txid"` - UpdateInfo 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:"update_info"` - Value string `json:"value"` + AbandonInfo []transactionListBlob `json:"abandon_info"` + ClaimInfo []transactionListBlob `json:"claim_info"` + Confirmations int64 `json:"confirmations"` + Date string `json:"date"` + Fee string `json:"fee"` + SupportInfo []supportBlob `json:"support_info"` + Timestamp int64 `json:"timestamp"` + Txid string `json:"txid"` + UpdateInfo []transactionListBlob `json:"update_info"` + Value string `json:"value"` } type VersionResponse struct {