From 1f1848a4080e54464c22d5c7daa94352ece669db Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 5 Sep 2019 18:16:49 -0400 Subject: [PATCH 1/3] Adds account_id to channel create (and update), missing functions --- extras/jsonrpc/daemon.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/extras/jsonrpc/daemon.go b/extras/jsonrpc/daemon.go index 4717ab9..b194393 100644 --- a/extras/jsonrpc/daemon.go +++ b/extras/jsonrpc/daemon.go @@ -259,6 +259,7 @@ type ChannelCreateOptions struct { WebsiteURL *string `json:"website_url,omitempty"` CoverURL *string `json:"cover_url,omitempty"` Featured []string `json:"featured,omitempty"` + AccountID *string `json:"account_id,omitempty"` } func (d *Client) ChannelCreate(name string, bid float64, options ChannelCreateOptions) (*TransactionSummary, error) { @@ -436,6 +437,13 @@ func (d *Client) Status() (*StatusResponse, error) { return response, d.call(response, "status", map[string]interface{}{}) } +func (d *Client) TransactionList(account *string) (*TransactionListResponse, error) { + response := new(TransactionListResponse) + return response, d.call(response, "transaction_list", map[string]interface{}{ + "account_id": account, + }) +} + func (d *Client) UTXOList(account *string) (*UTXOListResponse, error) { response := new(UTXOListResponse) return response, d.call(response, "utxo_list", map[string]interface{}{ @@ -443,6 +451,13 @@ func (d *Client) UTXOList(account *string) (*UTXOListResponse, error) { }) } +func (d *Client) UTXORelease(account *string) (*UTXOReleaseResponse, error) { + response := new(UTXOReleaseResponse) + return response, d.call(response, "utxo_release", map[string]interface{}{ + "account_id": account, + }) +} + func (d *Client) Get(uri string) (*GetResponse, error) { response := new(GetResponse) return response, d.call(response, "get", map[string]interface{}{ From af728f12d99d1b2144f1c8360c38aa68f4b4107c Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 5 Sep 2019 19:02:10 -0400 Subject: [PATCH 2/3] add new types Wasn't sure about type `UTXOReleaseResponse *string` This is the response: ``` { "jsonrpc": "2.0", "result": null } ``` --- extras/jsonrpc/daemon_types.go | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/extras/jsonrpc/daemon_types.go b/extras/jsonrpc/daemon_types.go index 2dfe373..e83ed9e 100644 --- a/extras/jsonrpc/daemon_types.go +++ b/extras/jsonrpc/daemon_types.go @@ -471,6 +471,50 @@ type UTXOListResponse []struct { Type string `json:"type"` } +type UTXOReleaseResponse *string + +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"` +} + type VersionResponse struct { Build string `json:"build"` Desktop string `json:"desktop"` From 025c715ab4500551ec9e537c25dc862bd6efaeeb Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 24 Sep 2019 18:31:01 +0200 Subject: [PATCH 3/3] 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 {