Added support for 0.36.0 of lbrynet.
upgraded to latest types/schema repo fix several bugs (this only works on mainnet)
This commit is contained in:
parent
f827da4c61
commit
52702e2226
5 changed files with 164 additions and 102 deletions
|
@ -197,9 +197,10 @@ func (d *Client) ChannelList(account *string, page uint64, pageSize uint64) (*Ch
|
||||||
}
|
}
|
||||||
response := new(ChannelListResponse)
|
response := new(ChannelListResponse)
|
||||||
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,
|
||||||
"page_size": pageSize,
|
"page_size": pageSize,
|
||||||
|
"include_protobuf": true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +234,8 @@ type ClaimCreateOptions struct {
|
||||||
|
|
||||||
type ChannelCreateOptions struct {
|
type ChannelCreateOptions struct {
|
||||||
ClaimCreateOptions `json:",flatten"`
|
ClaimCreateOptions `json:",flatten"`
|
||||||
ContactEmail *string `json:"contact_email,omitempty"`
|
Email *string `json:"email,omitempty"`
|
||||||
HomepageURL *string `json:"homepage_url,omitempty"`
|
WebsiteURL *string `json:"website_url,omitempty"`
|
||||||
CoverURL *string `json:"cover_url,omitempty"`
|
CoverURL *string `json:"cover_url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,10 +245,12 @@ func (d *Client) ChannelCreate(name string, bid float64, options ChannelCreateOp
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Bid string `json:"bid"`
|
Bid string `json:"bid"`
|
||||||
FilePath string `json:"file_path,omitempty"`
|
FilePath string `json:"file_path,omitempty"`
|
||||||
|
IncludeProtoBuf bool `json:"include_protobuf"`
|
||||||
ChannelCreateOptions `json:",flatten"`
|
ChannelCreateOptions `json:",flatten"`
|
||||||
}{
|
}{
|
||||||
Name: name,
|
Name: name,
|
||||||
Bid: fmt.Sprintf("%.6f", bid),
|
Bid: fmt.Sprintf("%.6f", bid),
|
||||||
|
IncludeProtoBuf: true,
|
||||||
ChannelCreateOptions: options,
|
ChannelCreateOptions: options,
|
||||||
}
|
}
|
||||||
structs.DefaultTagName = "json"
|
structs.DefaultTagName = "json"
|
||||||
|
@ -256,23 +259,19 @@ func (d *Client) ChannelCreate(name string, bid float64, options ChannelCreateOp
|
||||||
|
|
||||||
type StreamCreateOptions struct {
|
type StreamCreateOptions struct {
|
||||||
ClaimCreateOptions `json:",flatten"`
|
ClaimCreateOptions `json:",flatten"`
|
||||||
Fee *Fee `json:",omitempty,flatten"`
|
Fee *Fee `json:",omitempty,flatten"`
|
||||||
Author *string `json:"author,omitempty"`
|
Author *string `json:"author,omitempty"`
|
||||||
License *string `json:"license,omitempty"`
|
License *string `json:"license,omitempty"`
|
||||||
LicenseURL *string `json:"license_url,omitempty"`
|
LicenseURL *string `json:"license_url,omitempty"`
|
||||||
StreamType *streamType `json:"stream_type,omitempty"`
|
ReleaseTime *int64 `json:"release_time,omitempty"`
|
||||||
ReleaseTime *int64 `json:"release_time,omitempty"`
|
Duration *uint64 `json:"duration,omitempty"`
|
||||||
Duration *uint64 `json:"duration,omitempty"`
|
Width *uint `json:"width,omitempty"`
|
||||||
VideoDuration *uint64 `json:"video_duration,omitempty"` //TODO: this shouldn't exist
|
Height *uint `json:"height,omitempty"`
|
||||||
ImageWidth *uint `json:"image_width,omitempty"`
|
Preview *string `json:"preview,omitempty"`
|
||||||
ImageHeight *uint `json:"image_height,omitempty"`
|
AllowDuplicateName *bool `json:"allow_duplicate_name,omitempty"`
|
||||||
VideoWidth *uint `json:"video_width,omitempty"`
|
ChannelName *string `json:"channel_name,omitempty"`
|
||||||
VideoHeight *uint `json:"video_height,omitempty"`
|
ChannelID *string `json:"channel_id,omitempty"`
|
||||||
Preview *string `json:"preview,omitempty"`
|
ChannelAccountID *string `json:"channel_account_id,omitempty"`
|
||||||
AllowDuplicateName *bool `json:"allow_duplicate_name,omitempty"`
|
|
||||||
ChannelName *string `json:"channel_name,omitempty"`
|
|
||||||
ChannelID *string `json:"channel_id,omitempty"`
|
|
||||||
ChannelAccountID *string `json:"channel_account_id,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Client) StreamCreate(name, filePath string, bid float64, options StreamCreateOptions) (*TransactionSummary, error) {
|
func (d *Client) StreamCreate(name, filePath string, bid float64, options StreamCreateOptions) (*TransactionSummary, error) {
|
||||||
|
@ -281,11 +280,13 @@ func (d *Client) StreamCreate(name, filePath string, bid float64, options Stream
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Bid string `json:"bid"`
|
Bid string `json:"bid"`
|
||||||
FilePath string `json:"file_path,omitempty"`
|
FilePath string `json:"file_path,omitempty"`
|
||||||
|
IncludeProtobuf bool `json:"include_protobuf"`
|
||||||
*StreamCreateOptions `json:",flatten"`
|
*StreamCreateOptions `json:",flatten"`
|
||||||
}{
|
}{
|
||||||
Name: name,
|
Name: name,
|
||||||
FilePath: filePath,
|
FilePath: filePath,
|
||||||
Bid: fmt.Sprintf("%.6f", bid),
|
Bid: fmt.Sprintf("%.6f", bid),
|
||||||
|
IncludeProtobuf: true,
|
||||||
StreamCreateOptions: &options,
|
StreamCreateOptions: &options,
|
||||||
}
|
}
|
||||||
structs.DefaultTagName = "json"
|
structs.DefaultTagName = "json"
|
||||||
|
@ -295,9 +296,10 @@ func (d *Client) StreamCreate(name, filePath string, bid float64, options Stream
|
||||||
func (d *Client) StreamAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) {
|
func (d *Client) StreamAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) {
|
||||||
response := new(ClaimAbandonResponse)
|
response := new(ClaimAbandonResponse)
|
||||||
err := d.call(response, "claim_abandon", map[string]interface{}{
|
err := d.call(response, "claim_abandon", map[string]interface{}{
|
||||||
"txid": txID,
|
"txid": txID,
|
||||||
"nout": nOut,
|
"nout": nOut,
|
||||||
"account_id": accountID,
|
"account_id": accountID,
|
||||||
|
"include_protobuf": true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -322,9 +324,11 @@ func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*Pub
|
||||||
ClaimID string `json:"claim_id"`
|
ClaimID string `json:"claim_id"`
|
||||||
FilePath string `json:"file_path,omitempty"`
|
FilePath string `json:"file_path,omitempty"`
|
||||||
Bid string `json:"bid"`
|
Bid string `json:"bid"`
|
||||||
|
IncludeProtoBuf bool `json:"include_protobuf"`
|
||||||
*StreamUpdateOptions `json:",flatten"`
|
*StreamUpdateOptions `json:",flatten"`
|
||||||
}{
|
}{
|
||||||
ClaimID: claimID,
|
ClaimID: claimID,
|
||||||
|
IncludeProtoBuf: true,
|
||||||
StreamUpdateOptions: &options,
|
StreamUpdateOptions: &options,
|
||||||
}
|
}
|
||||||
structs.DefaultTagName = "json"
|
structs.DefaultTagName = "json"
|
||||||
|
@ -333,10 +337,11 @@ func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*Pub
|
||||||
|
|
||||||
func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) {
|
func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) {
|
||||||
response := new(ClaimAbandonResponse)
|
response := new(ClaimAbandonResponse)
|
||||||
err := d.call(response, "claim_abandon", map[string]interface{}{
|
err := d.call(response, "channel_abandon", map[string]interface{}{
|
||||||
"txid": txID,
|
"txid": txID,
|
||||||
"nout": nOut,
|
"nout": nOut,
|
||||||
"account_id": accountID,
|
"account_id": accountID,
|
||||||
|
"include_protobuf": true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -379,6 +384,21 @@ func (d *Client) UTXOList(account *string) (*UTXOListResponse, error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Client) Get(uri string) (*GetResponse, error) {
|
||||||
|
response := new(GetResponse)
|
||||||
|
return response, d.call(response, "get", map[string]interface{}{
|
||||||
|
"uri": uri,
|
||||||
|
"include_protobuf": true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Client) FileList() (*FileListResponse, error) {
|
||||||
|
response := new(FileListResponse)
|
||||||
|
return response, d.call(response, "file_list", map[string]interface{}{
|
||||||
|
"include_protobuf": true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Client) Version() (*VersionResponse, error) {
|
func (d *Client) Version() (*VersionResponse, error) {
|
||||||
response := new(VersionResponse)
|
response := new(VersionResponse)
|
||||||
return response, d.call(response, "version", map[string]interface{}{})
|
return response, d.call(response, "version", map[string]interface{}{})
|
||||||
|
@ -387,7 +407,8 @@ func (d *Client) Version() (*VersionResponse, error) {
|
||||||
func (d *Client) Resolve(urls string) (*ResolveResponse, error) {
|
func (d *Client) Resolve(urls string) (*ResolveResponse, error) {
|
||||||
response := new(ResolveResponse)
|
response := new(ResolveResponse)
|
||||||
return response, d.call(response, "resolve", map[string]interface{}{
|
return response, d.call(response, "resolve", map[string]interface{}{
|
||||||
"urls": urls,
|
"urls": urls,
|
||||||
|
"include_protobuf": true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,42 @@ import (
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
|
|
||||||
"github.com/lbryio/lbry.go/extras/util"
|
"github.com/lbryio/lbry.go/extras/util"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func prettyPrint(i interface{}) {
|
||||||
|
s, _ := json.MarshalIndent(i, "", "\t")
|
||||||
|
fmt.Println(string(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_AccountFund(t *testing.T) {
|
||||||
|
d := NewClient("")
|
||||||
|
accounts, err := d.AccountList()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
account := (accounts.LBCRegtest)[0].ID
|
||||||
|
balanceString, err := d.AccountBalance(&account)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
balance, err := strconv.ParseFloat(string(*balanceString), 64)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
got, err := d.AccountFund(account, account, fmt.Sprintf("%f", balance/2.0), 40)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
prettyPrint(*got)
|
||||||
|
}
|
||||||
|
|
||||||
func TestClient_AccountList(t *testing.T) {
|
func TestClient_AccountList(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
got, err := d.AccountList()
|
got, err := d.AccountList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_AccountBalance(t *testing.T) {
|
func TestClient_AccountBalance(t *testing.T) {
|
||||||
|
@ -28,7 +54,7 @@ func TestClient_AccountBalance(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%s", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_AddressUnused(t *testing.T) {
|
func TestClient_AddressUnused(t *testing.T) {
|
||||||
|
@ -37,7 +63,7 @@ func TestClient_AddressUnused(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%s", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_ChannelList(t *testing.T) {
|
func TestClient_ChannelList(t *testing.T) {
|
||||||
|
@ -46,10 +72,10 @@ func TestClient_ChannelList(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_Publish(t *testing.T) {
|
func TestClient_StreamCreate(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
addressResponse, err := d.AddressUnused(nil)
|
addressResponse, err := d.AddressUnused(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -84,7 +110,6 @@ func TestClient_Publish(t *testing.T) {
|
||||||
Author: util.PtrToString("Niko"),
|
Author: util.PtrToString("Niko"),
|
||||||
License: util.PtrToString("FREE"),
|
License: util.PtrToString("FREE"),
|
||||||
LicenseURL: nil,
|
LicenseURL: nil,
|
||||||
StreamType: &StreamTypeImage,
|
|
||||||
ReleaseTime: nil,
|
ReleaseTime: nil,
|
||||||
Duration: nil,
|
Duration: nil,
|
||||||
ImageWidth: nil,
|
ImageWidth: nil,
|
||||||
|
@ -94,18 +119,18 @@ func TestClient_Publish(t *testing.T) {
|
||||||
Preview: nil,
|
Preview: nil,
|
||||||
AllowDuplicateName: nil,
|
AllowDuplicateName: nil,
|
||||||
ChannelName: nil,
|
ChannelName: nil,
|
||||||
ChannelID: util.PtrToString("5205b93465014f9f8ae3e7b1e5a7ad46f925163d"),
|
ChannelID: util.PtrToString("2e28aa6dbd41f959893907841f4e40d0ecb0ede9"),
|
||||||
ChannelAccountID: nil,
|
ChannelAccountID: nil,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_ChannelCreate(t *testing.T) {
|
func TestClient_ChannelCreate(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
got, err := d.ChannelCreate("@Test", 13.37, ChannelCreateOptions{
|
got, err := d.ChannelCreate("@Test"+fmt.Sprintf("%d", time.Now().Unix()), 13.37, ChannelCreateOptions{
|
||||||
ClaimCreateOptions: ClaimCreateOptions{
|
ClaimCreateOptions: ClaimCreateOptions{
|
||||||
Title: "Mess with the channels",
|
Title: "Mess with the channels",
|
||||||
Description: "And you'll get what you deserve",
|
Description: "And you'll get what you deserve",
|
||||||
|
@ -118,19 +143,20 @@ func TestClient_ChannelCreate(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
||||||
},
|
},
|
||||||
ContactEmail: util.PtrToString("niko@lbry.com"),
|
Email: util.PtrToString("niko@lbry.com"),
|
||||||
HomepageURL: util.PtrToString("https://lbry.com"),
|
WebsiteURL: util.PtrToString("https://lbry.com"),
|
||||||
CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_ChannelAbandon(t *testing.T) {
|
func TestClient_ChannelAbandon(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
channelResponse, err := d.ChannelCreate("@TestToDelete", 13.37, ChannelCreateOptions{
|
channelName := "@TestToDelete" + fmt.Sprintf("%d", time.Now().Unix())
|
||||||
|
channelResponse, err := d.ChannelCreate(channelName, 13.37, ChannelCreateOptions{
|
||||||
ClaimCreateOptions: ClaimCreateOptions{
|
ClaimCreateOptions: ClaimCreateOptions{
|
||||||
Title: "Mess with the channels",
|
Title: "Mess with the channels",
|
||||||
Description: "And you'll get what you deserve",
|
Description: "And you'll get what you deserve",
|
||||||
|
@ -143,9 +169,9 @@ func TestClient_ChannelAbandon(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
||||||
},
|
},
|
||||||
ContactEmail: util.PtrToString("niko@lbry.com"),
|
Email: util.PtrToString("niko@lbry.com"),
|
||||||
HomepageURL: util.PtrToString("https://lbry.com"),
|
WebsiteURL: util.PtrToString("https://lbry.com"),
|
||||||
CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -157,7 +183,7 @@ func TestClient_ChannelAbandon(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_AddressList(t *testing.T) {
|
func TestClient_AddressList(t *testing.T) {
|
||||||
|
@ -166,7 +192,7 @@ func TestClient_AddressList(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_ClaimList(t *testing.T) {
|
func TestClient_ClaimList(t *testing.T) {
|
||||||
|
@ -175,16 +201,16 @@ func TestClient_ClaimList(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_ClaimSearch(t *testing.T) {
|
func TestClient_ClaimSearch(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
got, err := d.ClaimSearch(nil, util.PtrToString("d3d84b191b05b1915db3f78150c5d42d172f4c5f"), nil, nil)
|
got, err := d.ClaimSearch(nil, util.PtrToString("1b2b530dfcef9885354f8f41190c8f678da5414e"), nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_Status(t *testing.T) {
|
func TestClient_Status(t *testing.T) {
|
||||||
|
@ -193,7 +219,7 @@ func TestClient_Status(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_UTXOList(t *testing.T) {
|
func TestClient_UTXOList(t *testing.T) {
|
||||||
|
@ -202,7 +228,7 @@ func TestClient_UTXOList(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_Version(t *testing.T) {
|
func TestClient_Version(t *testing.T) {
|
||||||
|
@ -211,42 +237,37 @@ func TestClient_Version(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_GetFile(t *testing.T) {
|
||||||
|
d := NewClient("")
|
||||||
|
got, err := d.Get("lbry://test1555965264")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
prettyPrint(*got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_FileList(t *testing.T) {
|
||||||
|
d := NewClient("")
|
||||||
|
got, err := d.FileList()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_Resolve(t *testing.T) {
|
func TestClient_Resolve(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
got, err := d.Resolve("crashtest")
|
got, err := d.Resolve("test1555965264")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(*got)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%s", b)
|
prettyPrint(*got)
|
||||||
}
|
|
||||||
|
|
||||||
func TestClient_AccountFund(t *testing.T) {
|
|
||||||
d := NewClient("")
|
|
||||||
accounts, err := d.AccountList()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
account := (accounts.LBCRegtest)[0].ID
|
|
||||||
balanceString, err := d.AccountBalance(&account)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
balance, err := strconv.ParseFloat(string(*balanceString), 64)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
got, err := d.AccountFund(account, account, fmt.Sprintf("%f", balance-0.1), 40)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
log.Infof("%+v", *got)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_AccountSet(t *testing.T) {
|
func TestClient_AccountSet(t *testing.T) {
|
||||||
|
@ -261,15 +282,13 @@ func TestClient_AccountSet(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
log.Infof("%+v", *got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
func TestClient_AccountCreate(t *testing.T) {
|
func TestClient_AccountCreate(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
account, err := d.AccountCreate("test@lbry.com", false)
|
account, err := d.AccountCreate("test"+fmt.Sprintf("%d", time.Now().Unix())+"@lbry.com", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if account.Status != "created" {
|
prettyPrint(*account)
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/lbryio/lbry.go/extras/errors"
|
"github.com/lbryio/lbry.go/extras/errors"
|
||||||
|
schema "github.com/lbryio/lbryschema.go/claim"
|
||||||
lbryschema "github.com/lbryio/types/v2/go"
|
lbryschema "github.com/lbryio/types/v2/go"
|
||||||
|
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
|
@ -32,7 +33,7 @@ type File struct {
|
||||||
FileName string `json:"file_name"`
|
FileName string `json:"file_name"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Metadata *lbryschema.Claim `json:"metadata"`
|
Metadata *lbryschema.Claim `json:"protobuf"`
|
||||||
MimeType string `json:"mime_type"`
|
MimeType string `json:"mime_type"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Outpoint string `json:"outpoint"`
|
Outpoint string `json:"outpoint"`
|
||||||
|
@ -96,6 +97,12 @@ func fixDecodeProto(src, dest reflect.Type, data interface{}) (interface{}, erro
|
||||||
case reflect.TypeOf(lbryschema.Fee_Currency(0)):
|
case reflect.TypeOf(lbryschema.Fee_Currency(0)):
|
||||||
val, err := getEnumVal(lbryschema.Fee_Currency_value, data)
|
val, err := getEnumVal(lbryschema.Fee_Currency_value, data)
|
||||||
return lbryschema.Fee_Currency(val), err
|
return lbryschema.Fee_Currency(val), err
|
||||||
|
case reflect.TypeOf(lbryschema.Claim{}):
|
||||||
|
claim, err := schema.DecodeClaimHex(data.(string), "lbrycrd_main")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return claim.Claim, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
|
@ -179,14 +186,14 @@ type Account struct {
|
||||||
MaximumUsesPerAddress uint64 `json:"maximum_uses_per_address"`
|
MaximumUsesPerAddress uint64 `json:"maximum_uses_per_address"`
|
||||||
} `json:"receiving"`
|
} `json:"receiving"`
|
||||||
} `json:"address_generator"`
|
} `json:"address_generator"`
|
||||||
Certificates uint64 `json:"certificates"`
|
Certificates uint64 `json:"certificates"`
|
||||||
Coins float64 `json:"coins"`
|
Coins float64 `json:"coins"`
|
||||||
Encrypted bool `json:"encrypted"`
|
Encrypted bool `json:"encrypted"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
IsDefaultAccount bool `json:"is_default_account"`
|
IsDefault bool `json:"is_default"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
PublicKey string `json:"public_key"`
|
PublicKey string `json:"public_key"`
|
||||||
Satoshis uint64 `json:"satoshis"`
|
Satoshis uint64 `json:"satoshis"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountListResponse struct {
|
type AccountListResponse struct {
|
||||||
|
@ -198,8 +205,11 @@ type AccountBalanceResponse string
|
||||||
|
|
||||||
type AccountCreateResponse struct {
|
type AccountCreateResponse struct {
|
||||||
Account
|
Account
|
||||||
Seed string `json:"seed"`
|
PrivateKey string `json:"private_key,omitempty"`
|
||||||
Status string `json:"status"`
|
PublicKey string `json:"public_key"`
|
||||||
|
Seed string `json:"seed"`
|
||||||
|
Ledger string `json:"ledger"`
|
||||||
|
ModifiedOn float64 `json:"modified_on"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Transaction struct {
|
type Transaction struct {
|
||||||
|
@ -213,9 +223,10 @@ type Transaction struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Nout uint64 `json:"nout"`
|
Nout uint64 `json:"nout"`
|
||||||
PermanentUrl string `json:"permanent_url"`
|
PermanentUrl string `json:"permanent_url"`
|
||||||
|
Protobuf string `json:"protobuf,omitempty"`
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Value *lbryschema.Claim `json:"value"`
|
Value *lbryschema.Claim `json:"protobuf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransactionSummary struct {
|
type TransactionSummary struct {
|
||||||
|
@ -282,7 +293,7 @@ type Claim struct {
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ValidAtHeight int `json:"valid_at_height"`
|
ValidAtHeight int `json:"valid_at_height"`
|
||||||
Value lbryschema.Claim `json:"value"`
|
Value lbryschema.Claim `json:"protobuf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClaimListResponse []Claim
|
type ClaimListResponse []Claim
|
||||||
|
|
5
go.mod
5
go.mod
|
@ -13,6 +13,7 @@ require (
|
||||||
github.com/go-ini/ini v1.38.2
|
github.com/go-ini/ini v1.38.2
|
||||||
github.com/go-ozzo/ozzo-validation v3.5.0+incompatible // indirect
|
github.com/go-ozzo/ozzo-validation v3.5.0+incompatible // indirect
|
||||||
github.com/golang/protobuf v1.3.0
|
github.com/golang/protobuf v1.3.0
|
||||||
|
github.com/google/go-cmp v0.2.0 // indirect
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
|
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
|
||||||
github.com/gorilla/context v1.1.1 // indirect
|
github.com/gorilla/context v1.1.1 // indirect
|
||||||
github.com/gorilla/mux v1.6.2
|
github.com/gorilla/mux v1.6.2
|
||||||
|
@ -20,8 +21,9 @@ require (
|
||||||
github.com/gorilla/websocket v1.2.0 // indirect
|
github.com/gorilla/websocket v1.2.0 // indirect
|
||||||
github.com/jtolds/gls v4.2.1+incompatible // indirect
|
github.com/jtolds/gls v4.2.1+incompatible // indirect
|
||||||
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c
|
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c
|
||||||
|
github.com/lbryio/lbryschema.go v0.0.0-20190422030648-322c658307e0
|
||||||
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04
|
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04
|
||||||
github.com/lbryio/types v0.0.0-20190405005919-54c3c28f676a
|
github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c
|
||||||
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 // indirect
|
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 // indirect
|
||||||
github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6 // indirect
|
github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6 // indirect
|
||||||
github.com/lyoshenka/bencode v0.0.0-20180323155644-b7abd7672df5
|
github.com/lyoshenka/bencode v0.0.0-20180323155644-b7abd7672df5
|
||||||
|
@ -49,4 +51,5 @@ require (
|
||||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
|
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
|
||||||
gopkg.in/ini.v1 v1.41.0 // indirect
|
gopkg.in/ini.v1 v1.41.0 // indirect
|
||||||
gopkg.in/nullbio/null.v6 v6.0.0-20161116030900-40264a2e6b79
|
gopkg.in/nullbio/null.v6 v6.0.0-20161116030900-40264a2e6b79
|
||||||
|
gotest.tools v2.2.0+incompatible // indirect
|
||||||
)
|
)
|
||||||
|
|
12
go.sum
12
go.sum
|
@ -31,6 +31,8 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk=
|
github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk=
|
||||||
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
|
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
|
||||||
|
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
|
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||||
|
@ -48,10 +50,14 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c h1:BhdcWGsuKif/XoSZnqVGNqJ1iEmH0czWR5upj+AuR8M=
|
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c h1:BhdcWGsuKif/XoSZnqVGNqJ1iEmH0czWR5upj+AuR8M=
|
||||||
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8=
|
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8=
|
||||||
|
github.com/lbryio/lbryschema.go v0.0.0-20190422030648-322c658307e0 h1:/YWLlbbDefRGLs/ozyuRpvpwpFISYehwR4AAVlPthA8=
|
||||||
|
github.com/lbryio/lbryschema.go v0.0.0-20190422030648-322c658307e0/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo=
|
||||||
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04 h1:Nze+C2HbeKvhjI/kVn+9Poj/UuEW5sOQxcsxqO7L3GI=
|
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04 h1:Nze+C2HbeKvhjI/kVn+9Poj/UuEW5sOQxcsxqO7L3GI=
|
||||||
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04/go.mod h1:fbG/dzobG8r95KzMwckXiLMHfFjZaBRQqC9hPs2XAQ4=
|
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04/go.mod h1:fbG/dzobG8r95KzMwckXiLMHfFjZaBRQqC9hPs2XAQ4=
|
||||||
github.com/lbryio/types v0.0.0-20190405005919-54c3c28f676a h1:twWvrsBDvSb+qnmpSq3nvFrodgC5PpXUipyo4T/W790=
|
github.com/lbryio/types v0.0.0-20190420150432-3af925981a5f h1:N8ErMlrpP87wK+NfDhkV1A84Ect8xYWdO+ozAdi1z7k=
|
||||||
github.com/lbryio/types v0.0.0-20190405005919-54c3c28f676a/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE=
|
github.com/lbryio/types v0.0.0-20190420150432-3af925981a5f/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE=
|
||||||
|
github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c h1:m3O7561xBQ00lfUVayW4c6SnpVbUDQtPUwGcGYSUYQA=
|
||||||
|
github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE=
|
||||||
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU=
|
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU=
|
||||||
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
|
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
|
||||||
github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6 h1:iOAVXzZyXtW408TMYejlUPo6BIn92HmOacWtIfNyYns=
|
github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6 h1:iOAVXzZyXtW408TMYejlUPo6BIn92HmOacWtIfNyYns=
|
||||||
|
@ -135,4 +141,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
|
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||||
|
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|
Loading…
Reference in a new issue