Skip to content

Commit c36c679

Browse files
committed
Merge branch 'accountid-and-missing'
2 parents d032c84 + 025c715 commit c36c679

File tree

3 files changed

+80
-6
lines changed

3 files changed

+80
-6
lines changed

extras/jsonrpc/daemon.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ type ChannelCreateOptions struct {
259259
WebsiteURL *string `json:"website_url,omitempty"`
260260
CoverURL *string `json:"cover_url,omitempty"`
261261
Featured []string `json:"featured,omitempty"`
262+
AccountID *string `json:"account_id,omitempty"`
262263
}
263264

264265
func (d *Client) ChannelCreate(name string, bid float64, options ChannelCreateOptions) (*TransactionSummary, error) {
@@ -407,11 +408,18 @@ func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blo
407408
return response, nil
408409
}
409410

410-
func (d *Client) AddressList(account *string) (*AddressListResponse, error) {
411+
func (d *Client) AddressList(account *string, address *string) (*AddressListResponse, error) {
411412
response := new(AddressListResponse)
412-
return response, d.call(response, "address_list", map[string]interface{}{
413-
"account_id": account,
414-
})
413+
414+
args := struct {
415+
AccountID *string `json:"account_id,omitempty"`
416+
Address *string `json:"address,omitempty"`
417+
}{
418+
AccountID: account,
419+
Address: address,
420+
}
421+
structs.DefaultTagName = "json"
422+
return response, d.call(response, "address_list", structs.Map(args))
415423
}
416424

417425
func (d *Client) ClaimList(account *string, page uint64, pageSize uint64) (*ClaimListResponse, error) {
@@ -436,13 +444,27 @@ func (d *Client) Status() (*StatusResponse, error) {
436444
return response, d.call(response, "status", map[string]interface{}{})
437445
}
438446

447+
func (d *Client) TransactionList(account *string) (*TransactionListResponse, error) {
448+
response := new(TransactionListResponse)
449+
return response, d.call(response, "transaction_list", map[string]interface{}{
450+
"account_id": account,
451+
})
452+
}
453+
439454
func (d *Client) UTXOList(account *string) (*UTXOListResponse, error) {
440455
response := new(UTXOListResponse)
441456
return response, d.call(response, "utxo_list", map[string]interface{}{
442457
"account_id": account,
443458
})
444459
}
445460

461+
func (d *Client) UTXORelease(account *string) (*UTXOReleaseResponse, error) {
462+
response := new(UTXOReleaseResponse)
463+
return response, d.call(response, "utxo_release", map[string]interface{}{
464+
"account_id": account,
465+
})
466+
}
467+
446468
func (d *Client) Get(uri string) (*GetResponse, error) {
447469
response := new(GetResponse)
448470
return response, d.call(response, "get", map[string]interface{}{

extras/jsonrpc/daemon_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func TestClient_ChannelAbandon(t *testing.T) {
250250

251251
func TestClient_AddressList(t *testing.T) {
252252
d := NewClient("")
253-
got, err := d.AddressList(nil)
253+
got, err := d.AddressList(nil, nil)
254254
if err != nil {
255255
t.Error(err)
256256
return
@@ -269,6 +269,17 @@ func TestClient_ClaimList(t *testing.T) {
269269
prettyPrint(*got)
270270
}
271271

272+
func TestClient_TransactionList(t *testing.T) {
273+
_ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest")
274+
d := NewClient("")
275+
got, err := d.TransactionList(nil)
276+
if err != nil {
277+
t.Error(err)
278+
return
279+
}
280+
prettyPrint(*got)
281+
}
282+
272283
func TestClient_SupportTest(t *testing.T) {
273284
_ = os.Setenv("BLOCKCHAIN_NAME", "lbrycrd_regtest")
274285
d := NewClient("")

extras/jsonrpc/daemon_types.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,12 @@ type AccountFundResponse TransactionSummary
270270

271271
type Address string
272272
type AddressUnusedResponse Address
273-
type AddressListResponse []Address
273+
type AddressListResponse []struct {
274+
Account string `json:"account"`
275+
Address Address `json:"address"`
276+
Pubkey string `json:"pubkey"`
277+
UsedTimes uint64 `json:"used_times"`
278+
}
274279
type ChannelExportResponse string
275280

276281
type ChannelListResponse struct {
@@ -471,6 +476,42 @@ type UTXOListResponse []struct {
471476
Type string `json:"type"`
472477
}
473478

479+
type UTXOReleaseResponse *string
480+
481+
type transactionListBlob struct {
482+
Address string `json:"address"`
483+
Amount string `json:"amount"`
484+
BalanceDelta string `json:"balance_delta"`
485+
ClaimId string `json:"claim_id"`
486+
ClaimName string `json:"claim_name"`
487+
Nout int `json:"nout"`
488+
}
489+
490+
//TODO: this repeats all the fields from transactionListBlob which doesn't make sense
491+
// but if i extend the type with transactionListBlob it doesn't fill the fields. does our unmarshaller crap out on these?
492+
type supportBlob struct {
493+
Address string `json:"address"`
494+
Amount string `json:"amount"`
495+
BalanceDelta string `json:"balance_delta"`
496+
ClaimId string `json:"claim_id"`
497+
ClaimName string `json:"claim_name"`
498+
Nout int `json:"nout"`
499+
IsTip bool `json:"is_tip"`
500+
}
501+
502+
type TransactionListResponse []struct {
503+
AbandonInfo []transactionListBlob `json:"abandon_info"`
504+
ClaimInfo []transactionListBlob `json:"claim_info"`
505+
Confirmations int64 `json:"confirmations"`
506+
Date string `json:"date"`
507+
Fee string `json:"fee"`
508+
SupportInfo []supportBlob `json:"support_info"`
509+
Timestamp int64 `json:"timestamp"`
510+
Txid string `json:"txid"`
511+
UpdateInfo []transactionListBlob `json:"update_info"`
512+
Value string `json:"value"`
513+
}
514+
474515
type VersionResponse struct {
475516
Build string `json:"build"`
476517
Desktop string `json:"desktop"`

0 commit comments

Comments
 (0)