Compare commits

...
10 Commits
Author SHA1 Message Date
Niko Storni 77f713b817 upgrade lbrynet to support 0.32.* 2019-02-22 15:54:52 +01:00
Niko Storni 39542e6673 add broadcast flag 2019-02-22 15:12:58 +01:00
Niko Storni d3f3544dc3 fix resolution 2019-02-22 15:12:58 +01:00
Niko Storni 634a392ea9 add type to claim signature 2019-02-22 15:12:58 +01:00
Niko Storni c39d436a92 removed useless pagination 2019-02-22 15:12:58 +01:00
Niko Storni 08615f1a6a ultimate needed SDK calls update 2019-02-22 15:12:58 +01:00
Niko Storni 9b756fe627 add more SDK calls 2019-02-22 15:12:58 +01:00
Niko Storni e11f238070 add channelNew and claimAbandon
simplified code
2019-02-22 15:12:58 +01:00
Niko Storni 5ef9a229b6 add more SDK calls
export jsonrpc.Decode
add dep as dependencies manager
2019-02-22 15:12:58 +01:00
Niko Storni 854329b98f add 3 new SDK calls 2019-02-22 15:12:58 +01:00
8 changed files with 1217 additions and 496 deletions

No files matched your search

Generated
+407
View File
@@ -0,0 +1,407 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "master"
digest = "1:56332df3c4eb6fe335d7ef19996fcffd71711aaf1749aaf8a39a0593fbbcfbd5"
name = "github.com/btcsuite/btcd"
packages = [
"btcec",
"btcjson",
"chaincfg",
"chaincfg/chainhash",
"rpcclient",
"wire",
]
pruneopts = "UT"
revision = "ed77733ec07dfc8a513741138419b8d9d3de9d2d"
[[projects]]
branch = "master"
digest = "1:30d4a548e09bca4a0c77317c58e7407e2a65c15325e944f9c08a7b7992f8a59e"
name = "github.com/btcsuite/btclog"
packages = ["."]
pruneopts = "UT"
revision = "84c8d2346e9fc8c7b947e243b9c24e6df9fd206a"
[[projects]]
branch = "master"
digest = "1:d0a31b77988b04afbfa2c5ee38567a7a35d5a95de2266a644a7bc8d5c898e68d"
name = "github.com/btcsuite/btcutil"
packages = [
".",
"base58",
"bech32",
]
pruneopts = "UT"
revision = "bf1e1be935893b7c8ac9f020195f6b0dfd1f14e0"
[[projects]]
branch = "master"
digest = "1:1e6b2f7aa98b082c30a1303c29a702c369b2ec6d86b74a599bc8bbe2333db299"
name = "github.com/btcsuite/go-socks"
packages = ["socks"]
pruneopts = "UT"
revision = "4720035b7bfd2a9bb130b1c184f8bbe41b6f0d0f"
[[projects]]
branch = "master"
digest = "1:0b2242fd2f4f51fb491e97e204464f75da680897a0db10ec7554c87b71b5afc3"
name = "github.com/btcsuite/websocket"
packages = ["."]
pruneopts = "UT"
revision = "31079b6807923eb23992c421b114992b95131b55"
[[projects]]
digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
name = "github.com/davecgh/go-spew"
packages = ["spew"]
pruneopts = "UT"
revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
version = "v1.1.1"
[[projects]]
digest = "1:af43bdaaf86655a2343f113e9b293bbc16b12099eaeb223982bbe4d4c22ba14d"
name = "github.com/fatih/structs"
packages = ["."]
pruneopts = "UT"
revision = "4966fc68f5b7593aafa6cbbba2d65ec6e1416047"
version = "v1.1.0"
[[projects]]
digest = "1:aacef5f5e45685f2aeda5534d0a750dee6859de7e9088cdd06192787bb01ae6d"
name = "github.com/go-errors/errors"
packages = ["."]
pruneopts = "UT"
revision = "a6af135bd4e28680facf08a3d206b454abc877a4"
version = "v1.0.1"
[[projects]]
digest = "1:8b4bb15de2e698d359eeec15c42453567c98972a70c8619946050360ec02ec32"
name = "github.com/go-ini/ini"
packages = ["."]
pruneopts = "UT"
revision = "6ed8d5f64cd79a498d1f3fab5880cc376ce41bbe"
version = "v1.41.0"
[[projects]]
digest = "1:9d6dc4d6de69b330d0de86494d6db90c09848c003d5db748f40c925f865c8534"
name = "github.com/golang/protobuf"
packages = [
"jsonpb",
"proto",
"ptypes",
"ptypes/any",
"ptypes/duration",
"ptypes/struct",
"ptypes/timestamp",
]
pruneopts = "UT"
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
version = "v1.2.0"
[[projects]]
digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1"
name = "github.com/gorilla/context"
packages = ["."]
pruneopts = "UT"
revision = "08b5f424b9271eedf6f9f0ce86cb9396ed337a42"
version = "v1.1.1"
[[projects]]
digest = "1:e73f5b0152105f18bc131fba127d9949305c8693f8a762588a82a48f61756f5f"
name = "github.com/gorilla/mux"
packages = ["."]
pruneopts = "UT"
revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf"
version = "v1.6.2"
[[projects]]
digest = "1:a66fce629a0e374ac46a776c32a536fdd01d05d56163bac4fab2e0f633d4d79b"
name = "github.com/gorilla/rpc"
packages = [
"v2",
"v2/json",
]
pruneopts = "UT"
revision = "22c016f3df3febe0c1f6727598b6389507e03a18"
version = "v1.1.0"
[[projects]]
digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
name = "github.com/konsorten/go-windows-terminal-sequences"
packages = ["."]
pruneopts = "UT"
revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242"
version = "v1.0.1"
[[projects]]
branch = "master"
digest = "1:65bb92382468ce7a1ee218b5f352cd0927d358569be7521dd7cb42e74589a308"
name = "github.com/lbryio/errors.go"
packages = ["."]
pruneopts = "UT"
revision = "ad03d3cc6a5c27c94bbe3412cf7de0eae1a9bd7c"
[[projects]]
digest = "1:13289e2a34c842227d5891f1df2dcd7e42d5620d8b13ae0135a9d74e43711bee"
name = "github.com/lbryio/ozzo-validation"
packages = ["."]
pruneopts = "UT"
revision = "d1008ad1fd04ceb5faedaf34881df0c504382706"
version = "v3.1"
[[projects]]
branch = "master"
digest = "1:44168348d9531e608ec7a06e5a2ad32c7b0cbef0d44b974361085f6e7ef962c6"
name = "github.com/lbryio/types"
packages = ["go"]
pruneopts = "UT"
revision = "594241d24e0025d769d2cb58168536b6963d51cf"
[[projects]]
branch = "master"
digest = "1:0d8aaa52efbc9771152ba515e54937341206a96cebe82db29ba45906db43d231"
name = "github.com/lyoshenka/bencode"
packages = ["."]
pruneopts = "UT"
revision = "b7abd7672df533e627eddbf3a5a529786e8bda7f"
[[projects]]
digest = "1:53bc4cd4914cd7cd52139990d5170d6dc99067ae31c56530621b18b35fc30318"
name = "github.com/mitchellh/mapstructure"
packages = ["."]
pruneopts = "UT"
revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe"
version = "v1.1.2"
[[projects]]
digest = "1:1c9958664ac11d29b4af0334fc9cc1a7f0a5bc7d500e735db6517bb8592a5722"
name = "github.com/nlopes/slack"
packages = ["."]
pruneopts = "UT"
revision = "f243c7602fdf906248fc1f165284daa4e4d2d09e"
[[projects]]
branch = "master"
digest = "1:b450e7e26884b4aea569d00db31e6309a236ebbcec07e8ad1d869a37be66ee37"
name = "github.com/sebdah/goldie"
packages = ["."]
pruneopts = "UT"
revision = "8784dd1ab561dcf43d141f6678e9e41f3d0dff55"
[[projects]]
digest = "1:d917313f309bda80d27274d53985bc65651f81a5b66b820749ac7f8ef061fd04"
name = "github.com/sergi/go-diff"
packages = ["diffmatchpatch"]
pruneopts = "UT"
revision = "1744e2970ca51c86172c8190fadad617561ed6e7"
version = "v1.0.0"
[[projects]]
digest = "1:81e02c4edb639c80559c0650f9401d3e2dcc3256d1fa215382bb7c83c1db9126"
name = "github.com/shopspring/decimal"
packages = ["."]
pruneopts = "UT"
revision = "cd690d0c9e2447b1ef2a129a6b7b49077da89b8e"
version = "1.1.0"
[[projects]]
digest = "1:87c2e02fb01c27060ccc5ba7c5a407cc91147726f8f40b70cceeedbc52b1f3a8"
name = "github.com/sirupsen/logrus"
packages = ["."]
pruneopts = "UT"
revision = "e1e72e9de974bd926e5c56f83753fba2df402ce5"
version = "v1.3.0"
[[projects]]
digest = "1:08d65904057412fc0270fc4812a1c90c594186819243160dc779a402d4b6d0bc"
name = "github.com/spf13/cast"
packages = ["."]
pruneopts = "UT"
revision = "8c9545af88b134710ab1cd196795e7f2388358d7"
version = "v1.3.0"
[[projects]]
digest = "1:3c1a69cdae3501bf75e76d0d86dc6f2b0a7421bc205c0cb7b96b19eed464a34d"
name = "github.com/uber-go/atomic"
packages = ["."]
pruneopts = "UT"
revision = "1ea20fb1cbb1cc08cbd0d913a96dead89aa18289"
version = "v1.3.2"
[[projects]]
digest = "1:564b31f09a21367ada5b019d8413afe99cf770775606f94c7bef42b2ef79dfdf"
name = "github.com/ybbus/jsonrpc"
packages = ["."]
pruneopts = "UT"
revision = "dd866631e904a5df2067d934985c5def68f391ac"
version = "v2.1.2"
[[projects]]
branch = "master"
digest = "1:d061ca5246742c0da8f1672d06efb1737b8f427f3a2585ff9df0a29edcbe7be0"
name = "golang.org/x/crypto"
packages = [
"ripemd160",
"sha3",
"ssh/terminal",
]
pruneopts = "UT"
revision = "ff983b9c42bc9fbf91556e191cc8efb585c16908"
[[projects]]
branch = "master"
digest = "1:4d6864e17d6867318cdaaa7790d655a7c9a1571429d2ce1f58a114bf7aba8d2b"
name = "golang.org/x/net"
packages = [
"context",
"http/httpguts",
"http2",
"http2/hpack",
"idna",
"internal/timeseries",
"trace",
"websocket",
]
pruneopts = "UT"
revision = "915654e7eabcea33ae277abbecf52f0d8b7a9fdc"
[[projects]]
branch = "master"
digest = "1:43cde116ff48f299eddb7e6515677e6d0a2c915854bb05a333877f07c3bb3033"
name = "golang.org/x/sys"
packages = [
"unix",
"windows",
]
pruneopts = "UT"
revision = "11f53e03133963fb11ae0588e08b5e0b85be8be5"
[[projects]]
digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18"
name = "golang.org/x/text"
packages = [
"collate",
"collate/build",
"internal/colltab",
"internal/gen",
"internal/tag",
"internal/triegen",
"internal/ucd",
"language",
"secure/bidirule",
"transform",
"unicode/bidi",
"unicode/cldr",
"unicode/norm",
"unicode/rangetable",
]
pruneopts = "UT"
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
branch = "master"
digest = "1:9fdc2b55e8e0fafe4b41884091e51e77344f7dc511c5acedcfd98200003bff90"
name = "golang.org/x/time"
packages = ["rate"]
pruneopts = "UT"
revision = "85acf8d2951cb2a3bde7632f9ff273ef0379bcbd"
[[projects]]
branch = "master"
digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c"
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
pruneopts = "UT"
revision = "db91494dd46c1fdcbbde05e5ff5eb56df8f7d79a"
[[projects]]
digest = "1:9ab5a33d8cb5c120602a34d2e985ce17956a4e8c2edce7e6961568f95e40c09a"
name = "google.golang.org/grpc"
packages = [
".",
"balancer",
"balancer/base",
"balancer/roundrobin",
"binarylog/grpc_binarylog_v1",
"codes",
"connectivity",
"credentials",
"credentials/internal",
"encoding",
"encoding/proto",
"grpclog",
"internal",
"internal/backoff",
"internal/binarylog",
"internal/channelz",
"internal/envconfig",
"internal/grpcrand",
"internal/grpcsync",
"internal/syscall",
"internal/transport",
"keepalive",
"metadata",
"naming",
"peer",
"resolver",
"resolver/dns",
"resolver/passthrough",
"stats",
"status",
"tap",
]
pruneopts = "UT"
revision = "a02b0774206b209466313a0b525d2c738fe407eb"
version = "v1.18.0"
[[projects]]
digest = "1:dd20e35bfb19aa3392cd17867fc1f95ffda2b0b6e6d9a330cd08c0892193d63f"
name = "gopkg.in/nullbio/null.v6"
packages = ["convert"]
pruneopts = "UT"
revision = "40264a2e6b7972d183906cf17663983c23231c82"
version = "v6.3"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
input-imports = [
"github.com/btcsuite/btcd/chaincfg",
"github.com/btcsuite/btcd/chaincfg/chainhash",
"github.com/btcsuite/btcd/rpcclient",
"github.com/btcsuite/btcutil",
"github.com/btcsuite/btcutil/base58",
"github.com/davecgh/go-spew/spew",
"github.com/fatih/structs",
"github.com/go-errors/errors",
"github.com/go-ini/ini",
"github.com/golang/protobuf/jsonpb",
"github.com/golang/protobuf/proto",
"github.com/gorilla/mux",
"github.com/gorilla/rpc/v2",
"github.com/gorilla/rpc/v2/json",
"github.com/lbryio/errors.go",
"github.com/lbryio/ozzo-validation",
"github.com/lbryio/types/go",
"github.com/lyoshenka/bencode",
"github.com/mitchellh/mapstructure",
"github.com/nlopes/slack",
"github.com/sebdah/goldie",
"github.com/sergi/go-diff/diffmatchpatch",
"github.com/shopspring/decimal",
"github.com/sirupsen/logrus",
"github.com/spf13/cast",
"github.com/uber-go/atomic",
"github.com/ybbus/jsonrpc",
"golang.org/x/crypto/ripemd160",
"golang.org/x/crypto/sha3",
"golang.org/x/net/context",
"golang.org/x/time/rate",
"google.golang.org/grpc",
"gopkg.in/nullbio/null.v6/convert",
]
solver-name = "gps-cdcl"
solver-version = 1
+138
View File
@@ -0,0 +1,138 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
branch = "master"
name = "github.com/btcsuite/btcd"
[[constraint]]
branch = "master"
name = "github.com/btcsuite/btcutil"
[[constraint]]
name = "github.com/davecgh/go-spew"
version = "1.1.1"
[[constraint]]
name = "github.com/fatih/structs"
version = "1.1.0"
[[constraint]]
name = "github.com/go-errors/errors"
version = "1.0.1"
[[constraint]]
name = "github.com/go-ini/ini"
version = "1.41.0"
[[constraint]]
name = "github.com/golang/protobuf"
version = "1.2.0"
[[constraint]]
name = "github.com/gorilla/mux"
version = "1.6.2"
[[constraint]]
name = "github.com/gorilla/rpc"
version = "1.1.0"
[[constraint]]
branch = "master"
name = "github.com/lbryio/errors.go"
[[constraint]]
name = "github.com/lbryio/ozzo-validation"
version = "3.1.0"
[[constraint]]
branch = "master"
name = "github.com/lbryio/types"
[[constraint]]
branch = "master"
name = "github.com/lyoshenka/bencode"
[[constraint]]
name = "github.com/mitchellh/mapstructure"
version = "1.1.2"
[[constraint]]
name = "github.com/nlopes/slack"
revision = "f243c7602fdf906248fc1f165284daa4e4d2d09e"
[[constraint]]
branch = "master"
name = "github.com/sebdah/goldie"
[[constraint]]
name = "github.com/sergi/go-diff"
version = "1.0.0"
[[constraint]]
name = "github.com/shopspring/decimal"
version = "1.1.0"
[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.3.0"
[[constraint]]
name = "github.com/spf13/cast"
version = "1.3.0"
[[constraint]]
name = "github.com/uber-go/atomic"
version = "1.3.2"
[[constraint]]
name = "github.com/ybbus/jsonrpc"
version = "2.1.2"
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
[[constraint]]
branch = "master"
name = "golang.org/x/net"
[[constraint]]
branch = "master"
name = "golang.org/x/time"
[[constraint]]
name = "google.golang.org/grpc"
version = "1.18.0"
[[constraint]]
name = "gopkg.in/nullbio/null.v6"
version = "6.3.0"
[prune]
go-tests = true
unused-packages = true
+174 -324
View File
@@ -12,6 +12,7 @@ import (
"github.com/lbryio/lbry.go/extras/errors"
"github.com/fatih/structs"
"github.com/mitchellh/mapstructure"
"github.com/shopspring/decimal"
log "github.com/sirupsen/logrus"
@@ -41,7 +42,7 @@ func NewClient(address string) *Client {
func NewClientAndWait(address string) *Client {
d := NewClient(address)
for {
_, err := d.WalletBalance()
_, err := d.AccountBalance(nil)
if err == nil {
return d
}
@@ -49,7 +50,7 @@ func NewClientAndWait(address string) *Client {
}
}
func decode(data interface{}, targetStruct interface{}) error {
func Decode(data interface{}, targetStruct interface{}) error {
config := &mapstructure.DecoderConfig{
Metadata: nil,
Result: targetStruct,
@@ -125,7 +126,7 @@ func (d *Client) call(response interface{}, command string, params map[string]in
if err != nil {
return err
}
return decode(result, response)
return Decode(result, response)
}
func (d *Client) SetRPCTimeout(timeout time.Duration) {
@@ -134,52 +135,119 @@ func (d *Client) SetRPCTimeout(timeout time.Duration) {
})
}
func (d *Client) Commands() (*CommandsResponse, error) {
response := new(CommandsResponse)
return response, d.call(response, "commands", map[string]interface{}{})
//============================================
// NEW SDK
//============================================
func (d *Client) AccountList() (*AccountListResponse, error) {
response := new(AccountListResponse)
return response, d.call(response, "account_list", map[string]interface{}{})
}
func (d *Client) Status() (*StatusResponse, error) {
response := new(StatusResponse)
return response, d.call(response, "status", map[string]interface{}{})
func (d *Client) AccountBalance(account *string) (*AccountBalanceResponse, error) {
response := new(AccountBalanceResponse)
return response, d.call(response, "account_balance", map[string]interface{}{
"account_id": account,
})
}
func (d *Client) WalletBalance() (*WalletBalanceResponse, error) {
rawResponse, err := d.callNoDecode("wallet_balance", map[string]interface{}{})
func (d *Client) AccountFund(fromAccount string, toAccount string, amount string, outputs uint64) (*AccountFundResponse, error) {
response := new(AccountFundResponse)
return response, d.call(response, "account_fund", map[string]interface{}{
"from_account": fromAccount,
"to_account": toAccount,
"amount": amount,
"outputs": outputs,
"broadcast": true,
})
}
func (d *Client) AddressUnused(account *string) (*AddressUnusedResponse, error) {
response := new(AddressUnusedResponse)
return response, d.call(response, "address_unused", map[string]interface{}{
"account_id": account,
})
}
func (d *Client) ChannelList(account *string, page uint64, pageSize uint64) (*ChannelListResponse, error) {
if page == 0 {
return nil, errors.Err("pages start from 1")
}
response := new(ChannelListResponse)
return response, d.call(response, "channel_list", map[string]interface{}{
"account_id": account,
"page": page,
"page_size": pageSize,
})
}
type Metadata struct {
Fee *Fee `json:"fee,omitempty"`
Title string `json:"title"`
Description string `json:"description"`
Author string `json:"author"`
Language string `json:"language"`
License string `json:"license"`
LicenseURL *string `json:"license_url,omitempty"`
Thumbnail *string `json:"thumbnail,omitempty"`
Preview *string `json:"preview,omitempty"`
NSFW bool `json:"nsfw"`
}
type PublishOptions struct {
*Metadata `json:"metadata"`
ChannelName *string `json:"channel_name,omitempty"`
ChannelID *string `json:"channel_id,omitempty"`
ChannelAccountID *string `json:"channel_account_id,omitempty"`
AccountID *string `json:"account_id,omitempty"`
ClaimAddress *string `json:"claim_address,omitempty"`
ChangeAddress *string `json:"change_address,omitempty"`
}
func (d *Client) Publish(name, filePath string, bid float64, options PublishOptions) (*PublishResponse, error) {
response := new(PublishResponse)
args := struct {
Name string `json:"name"`
FilePath string `json:"file_path,omitempty"`
Bid string `json:"bid"`
*PublishOptions `json:",flatten"`
}{
Name: name,
FilePath: filePath,
Bid: fmt.Sprintf("%.6f", bid),
PublishOptions: &options,
}
structs.DefaultTagName = "json"
return response, d.call(response, "publish", structs.Map(args))
}
func (d *Client) ChannelNew(name string, amount float64, accountID *string) (*ChannelNewResponse, error) {
response := new(ChannelNewResponse)
return response, d.call(response, "channel_new", map[string]interface{}{
"channel_name": name,
"amount": fmt.Sprintf("%.6f", amount),
"account_id": accountID,
})
}
func (d *Client) ClaimAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) {
response := new(ClaimAbandonResponse)
err := d.call(response, "claim_abandon", map[string]interface{}{
"txid": txID,
"nout": nOut,
"account_id": accountID,
})
if err != nil {
return nil, err
} else if response == nil {
return nil, errors.Err("no response")
}
dec, err := decodeNumber(rawResponse)
if err != nil {
return nil, err
}
response := WalletBalanceResponse(dec)
return &response, nil
return response, nil
}
func (d *Client) WalletList() (*WalletListResponse, error) {
response := new(WalletListResponse)
return response, d.call(response, "wallet_list", map[string]interface{}{})
}
func (d *Client) UTXOList() (*UTXOListResponse, error) {
response := new(UTXOListResponse)
return response, d.call(response, "utxo_list", map[string]interface{}{})
}
func (d *Client) Version() (*VersionResponse, error) {
response := new(VersionResponse)
return response, d.call(response, "version", map[string]interface{}{})
}
func (d *Client) Get(url string, filename *string, timeout *uint) (*GetResponse, error) {
response := new(GetResponse)
return response, d.call(response, "get", map[string]interface{}{
"uri": url,
"file_name": filename,
"timeout": timeout,
func (d *Client) AddressList(account *string) (*AddressListResponse, error) {
response := new(AddressListResponse)
return response, d.call(response, "address_list", map[string]interface{}{
"account_id": account,
})
}
@@ -190,6 +258,73 @@ func (d *Client) ClaimList(name string) (*ClaimListResponse, error) {
})
}
func (d *Client) ClaimListMine(account *string, page uint64, pageSize uint64) (*ClaimListMineResponse, error) {
if page == 0 {
return nil, errors.Err("pages start from 1")
}
response := new(ClaimListMineResponse)
err := d.call(response, "claim_list_mine", map[string]interface{}{
"account_id": account,
"page": page,
"page_size": pageSize,
})
if err != nil {
return nil, err
} else if response == nil {
return nil, errors.Err("no response")
}
return response, nil
}
func (d *Client) Status() (*StatusResponse, error) {
response := new(StatusResponse)
return response, d.call(response, "status", map[string]interface{}{})
}
func (d *Client) UTXOList(account *string) (*UTXOListResponse, error) {
response := new(UTXOListResponse)
return response, d.call(response, "utxo_list", map[string]interface{}{
"account_id": account,
})
}
func (d *Client) Version() (*VersionResponse, error) {
response := new(VersionResponse)
return response, d.call(response, "version", map[string]interface{}{})
}
func (d *Client) Resolve(uri string) (*ResolveResponse, error) {
response := new(ResolveResponse)
return response, d.call(response, "resolve", map[string]interface{}{
"urls": uri,
})
}
func (d *Client) NumClaimsInChannel(uri string) (uint64, error) {
response := new(NumClaimsInChannelResponse)
err := d.call(response, "claim_list_by_channel", map[string]interface{}{
"uri": uri,
})
if err != nil {
return 0, err
} else if response == nil {
return 0, errors.Err("no response")
}
channel, ok := (*response)[uri]
if !ok {
return 0, errors.Err("url not in response")
}
if channel.Error != nil {
if strings.Contains(*channel.Error, "cannot be resolved") {
return 0, nil
}
return 0, errors.Err(*channel.Error)
}
return *channel.ClaimsInChannel, nil
}
func (d *Client) ClaimShow(claimID *string, txid *string, nout *uint) (*ClaimShowResponse, error) {
response := new(ClaimShowResponse)
return response, d.call(response, "claim_show", map[string]interface{}{
@@ -198,288 +333,3 @@ func (d *Client) ClaimShow(claimID *string, txid *string, nout *uint) (*ClaimSho
"nout": nout,
})
}
func (d *Client) PeerList(blobHash string, timeout *uint) (*PeerListResponse, error) {
rawResponse, err := d.callNoDecode("peer_list", map[string]interface{}{
"blob_hash": blobHash,
"timeout": timeout,
})
if err != nil {
return nil, err
}
castResponse, ok := rawResponse.([]interface{})
if !ok {
return nil, errors.Err("invalid peer_list response")
}
peers := []PeerListResponsePeer{}
for _, peer := range castResponse {
t, ok := peer.(map[string]interface{})
if !ok {
return nil, errors.Err("invalid peer_list response")
}
if len(t) != 3 {
return nil, errors.Err("invalid triplet in peer_list response")
}
ip, ok := t["host"].(string)
if !ok {
return nil, errors.Err("invalid ip in peer_list response")
}
port, ok := t["port"].(json.Number)
if !ok {
return nil, errors.Err("invalid port in peer_list response")
}
nodeid, ok := t["node_id"].(string)
if !ok {
return nil, errors.Err("invalid nodeid in peer_list response")
}
portNum, err := port.Int64()
if err != nil {
return nil, errors.Wrap(err, 0)
} else if portNum < 0 {
return nil, errors.Err("invalid port in peer_list response")
}
peers = append(peers, PeerListResponsePeer{
IP: ip,
Port: uint(portNum),
NodeId: nodeid,
})
}
response := PeerListResponse(peers)
return &response, nil
}
func (d *Client) BlobGet(blobHash string, encoding *string, timeout *uint) (*BlobGetResponse, error) {
rawResponse, err := d.callNoDecode("blob_get", map[string]interface{}{
"blob_hash": blobHash,
"timeout": timeout,
"encoding": encoding,
})
if err != nil {
return nil, err
}
if _, ok := rawResponse.(string); ok {
return nil, nil // blob was downloaded, nothing to return
}
response := new(BlobGetResponse)
return response, decode(rawResponse, response)
}
func (d *Client) StreamAvailability(url string, search_timeout *uint64, blob_timeout *uint64) (*StreamAvailabilityResponse, error) {
response := new(StreamAvailabilityResponse)
return response, d.call(response, "stream_availability", map[string]interface{}{
"uri": url,
"search_timeout": search_timeout,
"blob_timeout": blob_timeout,
})
}
func (d *Client) StreamCostEstimate(url string, size *uint64) (*StreamCostEstimateResponse, error) {
rawResponse, err := d.callNoDecode("stream_cost_estimate", map[string]interface{}{
"uri": url,
"size": size,
})
if err != nil {
return nil, err
}
dec, err := decodeNumber(rawResponse)
if err != nil {
return nil, err
}
response := StreamCostEstimateResponse(dec)
return &response, nil
}
type FileListOptions struct {
SDHash *string
StreamHash *string
FileName *string
ClaimID *string
Outpoint *string
RowID *string
Name *string
}
func (d *Client) FileList(options FileListOptions) (*FileListResponse, error) {
response := new(FileListResponse)
return response, d.call(response, "file_list", map[string]interface{}{
"sd_hash": options.SDHash,
"stream_hash": options.StreamHash,
"file_name": options.FileName,
"claim_id": options.ClaimID,
"outpoint": options.Outpoint,
"rowid": options.RowID,
"name": options.Name,
})
}
func (d *Client) Resolve(url string) (*ResolveResponse, error) {
response := new(ResolveResponse)
return response, d.call(response, "resolve", map[string]interface{}{
"uri": url,
})
}
func (d *Client) ChannelNew(name string, amount float64) (*ChannelNewResponse, error) {
response := new(ChannelNewResponse)
return response, d.call(response, "channel_new", map[string]interface{}{
"channel_name": name,
"amount": amount,
})
}
func (d *Client) ChannelList() (*ChannelListResponse, error) {
response := new(ChannelListResponse)
return response, d.call(response, "channel_list", map[string]interface{}{})
}
type PublishOptions struct {
Fee *Fee
Title *string
Description *string
Author *string
Language *string
License *string
LicenseURL *string
Thumbnail *string
Preview *string
NSFW *bool
ChannelName *string
ChannelID *string
ClaimAddress *string
ChangeAddress *string
}
func (d *Client) Publish(name, filePath string, bid float64, options PublishOptions) (*PublishResponse, error) {
response := new(PublishResponse)
return response, d.call(response, "publish", map[string]interface{}{
"name": name,
"file_path": filePath,
"bid": bid,
"fee": options.Fee,
"title": options.Title,
"description": options.Description,
"author": options.Author,
"language": options.Language,
"license": options.License,
"license_url": options.LicenseURL,
"thumbnail": options.Thumbnail,
"preview": options.Preview,
"nsfw": options.NSFW,
"channel_name": options.ChannelName,
"channel_id": options.ChannelID,
"claim_address": options.ClaimAddress,
"change_address": options.ChangeAddress,
})
}
func (d *Client) BlobAnnounce(blobHash, sdHash, streamHash *string) (*BlobAnnounceResponse, error) {
response := new(BlobAnnounceResponse)
return response, d.call(response, "blob_announce", map[string]interface{}{
"blob_hash": blobHash,
"stream_hash": streamHash,
"sd_hash": sdHash,
})
}
func (d *Client) WalletPrefillAddresses(numAddresses int, amount decimal.Decimal, broadcast bool) (*WalletPrefillAddressesResponse, error) {
if numAddresses < 1 {
return nil, errors.Err("must create at least 1 address")
}
response := new(WalletPrefillAddressesResponse)
return response, d.call(response, "wallet_prefill_addresses", map[string]interface{}{
"num_addresses": numAddresses,
"amount": amount,
"no_broadcast": !broadcast,
})
}
func (d *Client) WalletNewAddress() (*WalletNewAddressResponse, error) {
rawResponse, err := d.callNoDecode("wallet_new_address", map[string]interface{}{})
if err != nil {
return nil, err
}
address, ok := rawResponse.(string)
if !ok {
return nil, errors.Err("unexpected response")
}
response := WalletNewAddressResponse(address)
return &response, nil
}
func (d *Client) WalletUnusedAddress() (*WalletUnusedAddressResponse, error) {
rawResponse, err := d.callNoDecode("wallet_unused_address", map[string]interface{}{})
if err != nil {
return nil, err
}
address, ok := rawResponse.(string)
if !ok {
return nil, errors.Err("unexpected response")
}
response := WalletUnusedAddressResponse(address)
return &response, nil
}
func (d *Client) NumClaimsInChannel(url string) (uint64, error) {
response := new(NumClaimsInChannelResponse)
err := d.call(response, "claim_list_by_channel", map[string]interface{}{
"uri": url,
})
if err != nil {
return 0, err
} else if response == nil {
return 0, errors.Err("no response")
}
channel, ok := (*response)[url]
if !ok {
return 0, errors.Err("url not in response")
}
if channel.Error != "" {
if strings.Contains(channel.Error, "cannot be resolved") {
return 0, nil
}
return 0, errors.Err(channel.Error)
}
return channel.ClaimsInChannel, nil
}
func (d *Client) ClaimListMine() (*ClaimListMineResponse, error) {
response := new(ClaimListMineResponse)
err := d.call(response, "claim_list_mine", map[string]interface{}{})
if err != nil {
return nil, err
} else if response == nil {
return nil, errors.Err("no response")
}
return response, nil
}
func (d *Client) ClaimAbandon(txID string, nOut int) (*ClaimAbandonResponse, error) {
response := new(ClaimAbandonResponse)
err := d.call(response, "claim_abandon", map[string]interface{}{
"txid": txID,
"nout": nOut,
})
if err != nil {
return nil, err
} else if response == nil {
return nil, errors.Err("no response")
}
return response, nil
}
+211 -1
View File
@@ -1,8 +1,218 @@
package jsonrpc
import (
"encoding/json"
"fmt"
"strconv"
"testing"
"time"
"github.com/lbryio/lbry.go/extras/util"
"github.com/shopspring/decimal"
log "github.com/sirupsen/logrus"
)
func TestStatus(t *testing.T) {
func TestClient_AccountList(t *testing.T) {
d := NewClient("")
got, err := d.AccountList()
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_AccountBalance(t *testing.T) {
d := NewClient("")
got, err := d.AccountBalance(nil)
if err != nil {
t.Error(err)
}
log.Infof("%s", *got)
}
func TestClient_AddressUnused(t *testing.T) {
d := NewClient("")
got, err := d.AddressUnused(nil)
if err != nil {
t.Error(err)
}
log.Infof("%s", *got)
}
func TestClient_ChannelList(t *testing.T) {
d := NewClient("")
got, err := d.ChannelList(nil, 1, 50)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_Publish(t *testing.T) {
d := NewClient("")
addressResponse, err := d.AddressUnused(nil)
if err != nil {
t.Error(err)
}
address := string(*addressResponse)
got, err := d.Publish("test", "/home/niko/work/allClaims.txt", 14.37, PublishOptions{
Metadata: &Metadata{
Fee: &Fee{
Currency: "LBC",
Amount: decimal.NewFromFloat(1.0),
Address: &address,
},
Title: "This is a Test Title",
Description: "My Special Description",
Author: "Niko",
Language: "en",
License: "FREEEEE",
LicenseURL: nil,
Thumbnail: util.PtrToString("https://scrn.storni.info/2019-01-18_16-37-39-098537783.png"),
Preview: nil,
NSFW: false,
},
ChannelName: nil,
ChannelID: util.PtrToString("bda0520bff61e4a70c966d7298e6b89107cf8bed"),
ChannelAccountID: nil,
AccountID: nil,
ClaimAddress: &address,
ChangeAddress: &address,
})
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_ChannelNew(t *testing.T) {
d := NewClient("")
got, err := d.ChannelNew("@Test", 13.37, nil)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_ClaimAbandon(t *testing.T) {
d := NewClient("")
channelResponse, err := d.ChannelNew("@TestToDelete", 13.37, nil)
if err != nil {
t.Error(err)
}
txID := channelResponse.Output.Txid
nout := channelResponse.Output.Nout
time.Sleep(10 * time.Second)
got, err := d.ClaimAbandon(txID, nout, nil, false)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_AddressList(t *testing.T) {
d := NewClient("")
got, err := d.AddressList(nil)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_ClaimList(t *testing.T) {
d := NewClient("")
got, err := d.ClaimList("test")
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_ClaimListMine(t *testing.T) {
d := NewClient("")
got, err := d.ClaimListMine(nil, 1, 50)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_Status(t *testing.T) {
d := NewClient("")
got, err := d.Status()
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_UTXOList(t *testing.T) {
d := NewClient("")
got, err := d.UTXOList(nil)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_Version(t *testing.T) {
d := NewClient("")
got, err := d.Version()
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_Resolve(t *testing.T) {
d := NewClient("")
got, err := d.Resolve("test")
if err != nil {
t.Error(err)
}
b, err := json.Marshal(*got)
if err != nil {
t.Error(err)
}
log.Infof("%s", b)
}
func TestClient_NumClaimsInChannel(t *testing.T) {
d := NewClient("")
got, err := d.NumClaimsInChannel("@Test#bda0520bff61e4a70c966d7298e6b89107cf8bed")
if err != nil {
t.Error(err)
}
log.Infof("%d", got)
}
func TestClient_ClaimShow(t *testing.T) {
d := NewClient("")
got, err := d.ClaimShow(util.PtrToString("4742f25e6d51b4b0483d5b8cd82e3ea121dacde9"), nil, nil)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *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)
}
+228 -169
View File
@@ -24,41 +24,6 @@ type Fee struct {
Address *string `json:"address"`
}
type Support struct {
Amount decimal.Decimal `json:"amount"`
Nout int `json:"nout"`
Txid string `json:"txid"`
}
type Claim struct {
Address string `json:"address"`
Amount decimal.Decimal `json:"amount"`
BlocksToExpiration int `json:"blocks_to_expiration"`
Category string `json:"category"`
ClaimID string `json:"claim_id"`
ClaimSequence int `json:"claim_sequence"`
Confirmations int `json:"confirmations"`
DecodedClaim bool `json:"decoded_claim"`
Depth int `json:"depth"`
EffectiveAmount decimal.Decimal `json:"effective_amount"`
ExpirationHeight int `json:"expiration_height"`
Expired bool `json:"expired"`
Height int `json:"height"`
Hex string `json:"hex"`
IsSpent bool `json:"is_spent"`
Name string `json:"name"`
Nout int `json:"nout"`
PermanentUrl string `json:"permanent_url"`
Supports []Support `json:"supports"`
Txid string `json:"txid"`
ValidAtHeight int `json:"valid_at_height"`
Value lbryschema.Claim `json:"value"`
Error *string `json:"error,omitempty"`
ChannelName *string `json:"channel_name,omitempty"`
HasSignature *bool `json:"has_signature,omitempty"`
SignatureIsValid *bool `json:"signature_is_valid,omitempty"`
}
type File struct {
ClaimID string `json:"claim_id"`
Completed bool `json:"completed"`
@@ -176,78 +141,8 @@ func fixDecodeProto(src, dest reflect.Type, data interface{}) (interface{}, erro
return data, nil
}
type CommandsResponse []string
type WalletBalanceResponse decimal.Decimal
type VersionResponse struct {
Build string `json:"build"`
LbrynetVersion string `json:"lbrynet_version"`
LbryschemaVersion string `json:"lbryschema_version"`
LbryumVersion string `json:"lbryum_version"`
OsRelease string `json:"os_release"`
OsSystem string `json:"os_system"`
Platform string `json:"platform"`
Processor string `json:"processor"`
PythonVersion string `json:"python_version"`
}
type StatusResponse struct {
BlobManager struct {
FinishedBlobs int `json:"finished_blobs"`
} `json:"blob_manager"`
ConnectionStatus struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"connection_status"`
Dht struct {
NodeID string `json:"node_id"`
PeersInRoutingTable int `json:"peers_in_routing_table"`
} `json:"dht"`
FileManager struct {
ManagedFiles int `json:"managed_files"`
} `json:"file_manager"`
HashAnnouncer struct {
AnnounceQueueSize int `json:"announce_queue_size"`
} `json:"hash_announcer"`
InstallationID string `json:"installation_id"`
IsFirstRun bool `json:"is_first_run"`
IsRunning bool `json:"is_running"`
SkippedComponents []string `json:"skipped_components"`
StartupStatus struct {
BlobManager bool `json:"blob_manager"`
BlockchainHeaders bool `json:"blockchain_headers"`
Database bool `json:"database"`
Dht bool `json:"dht"`
ExchangeRateManager bool `json:"exchange_rate_manager"`
FileManager bool `json:"file_manager"`
HashAnnouncer bool `json:"hash_announcer"`
PaymentRateManager bool `json:"payment_rate_manager"`
PeerProtocolServer bool `json:"peer_protocol_server"`
RateLimiter bool `json:"rate_limiter"`
StreamIdentifier bool `json:"stream_identifier"`
Upnp bool `json:"upnp"`
Wallet bool `json:"wallet"`
} `json:"startup_status"`
Wallet struct {
BestBlockchain string `json:"best_blockchain"`
Blocks int `json:"blocks"`
BlocksBehind int `json:"blocks_behind"`
IsEncrypted bool `json:"is_encrypted"`
} `json:"wallet"`
}
type ClaimListResponse struct {
Claims []Claim `json:"claims"`
LastTakeoverHeight int `json:"last_takeover_height"`
SupportsWithoutClaims []Support `json:"supports_without_claims"`
}
type ClaimListMineResponse []Claim
type ClaimShowResponse Claim
type ClaimAbandonResponse struct {
Txid string `json:"txid"`
Fee float64 `json:"fee"`
}
type PeerListResponsePeer struct {
IP string `json:"host"`
Port uint `json:"port"`
@@ -295,57 +190,8 @@ type StreamAvailabilityResponse struct {
type GetResponse File
type FileListResponse []File
type ResolveResponse map[string]ResolveResponseItem
type ResolveResponseItem struct {
Certificate *Claim `json:"certificate,omitempty"`
Claim *Claim `json:"claim,omitempty"`
ClaimsInChannel *uint64 `json:"claims_in_channel,omitempty"`
Error *string `json:"error,omitempty"`
}
type ChannelNewResponse struct {
ClaimID string `json:"claim_id"`
Fee decimal.Decimal `json:"fee"`
Nout int `json:"nout"`
Success bool `json:"success"`
Tx string `json:"tx"`
Txid string `json:"txid"`
}
type ChannelListSingleResponse struct {
Address string `json:"address"`
Amount decimal.Decimal `json:"amount"`
BlocksToExpiration int `json:"blocks_to_expiration"`
CanSign bool `json:"can_sign"`
Category string `json:"category"`
ClaimID string `json:"claim_id"`
Confirmations int `json:"confirmations"`
DecodedClaim bool `json:"decoded_claim"`
ExpirationHeight int `json:"expiration_height"`
Expired bool `json:"expired"`
HasSignature bool `json:"has_signature"`
Height int `json:"height"`
Hex string `json:"hex"`
IsPending bool `json:"is_pending"`
IsSpent bool `json:"is_spent"`
Name string `json:"name"`
Nout int `json:"nout"`
Txid string `json:"txid"`
Value *lbryschema.Claim `json:"value"`
}
type ChannelListResponse []ChannelListSingleResponse
type WalletListResponse []string
type PublishResponse struct {
ClaimID string `json:"claim_id"`
Fee decimal.Decimal `json:"fee"`
Nout int `json:"nout"`
Tx string `json:"tx"`
Txid string `json:"txid"`
}
type BlobAnnounceResponse bool
type WalletPrefillAddressesResponse struct {
@@ -354,23 +200,236 @@ type WalletPrefillAddressesResponse struct {
Hex string `json:"hex"`
}
type UTXOListResponse []struct {
Address string `json:"address"`
Amount decimal.Decimal `json:"amount"`
Height int `json:"height"`
IsClaim bool `json:"is_claim"`
IsCoinbase bool `json:"is_coinbase"`
IsSupport bool `json:"is_support"`
IsUpdate bool `json:"is_update"`
Nout int `json:"nout"`
Txid string `json:"txid"`
}
type WalletNewAddressResponse string
type WalletUnusedAddressResponse string
type NumClaimsInChannelResponse map[string]struct {
ClaimsInChannel uint64 `json:"claims_in_channel,omitempty"`
Error string `json:"error,omitempty"`
//============================================
// NEW SDK
//============================================
type Account struct {
AddressGenerator struct {
Change struct {
Gap uint64 `json:"gap"`
MaximumUsesPerAddress uint64 `json:"maximum_uses_per_address"`
} `json:"change"`
Name string `json:"name"`
Receiving struct {
Gap uint64 `json:"gap"`
MaximumUsesPerAddress uint64 `json:"maximum_uses_per_address"`
} `json:"receiving"`
} `json:"address_generator"`
Certificates uint64 `json:"certificates"`
Coins float64 `json:"coins"`
Encrypted bool `json:"encrypted"`
ID string `json:"id"`
IsDefaultAccount bool `json:"is_default_account"`
Name string `json:"name"`
PublicKey string `json:"public_key"`
Satoshis uint64 `json:"satoshis"`
}
type AccountListResponse struct {
LBCMainnet []Account `json:"lbc_mainnet"`
LBCTestnet []Account `json:"lbc_testnet"`
LBCRegtest []Account `json:"lbc_regtest"`
}
type AccountBalanceResponse string
type Transaction struct {
Address string `json:"address"`
Amount string `json:"amount"`
ClaimID string `json:"claim_id"`
Confirmations int `json:"confirmations"`
Height int `json:"height"`
IsChange bool `json:"is_change"`
IsMine bool `json:"is_mine"`
Name string `json:"name"`
Nout uint64 `json:"nout"`
PermanentUrl string `json:"permanent_url"`
Txid string `json:"txid"`
Type string `json:"type"`
Value *lbryschema.Claim `json:"value"`
}
type TransactionSummary struct {
Height int `json:"height"`
Hex string `json:"hex"`
Inputs []Transaction `json:"inputs"`
Outputs []Transaction `json:"outputs"`
TotalFee string `json:"total_fee"`
TotalOutput string `json:"total_output"`
Txid string `json:"txid"`
}
type AccountFundResponse TransactionSummary
type Address string
type AddressUnusedResponse Address
type AddressListResponse []Address
type PublishResponse struct {
ClaimAddress string `json:"claim_address"`
ClaimID string `json:"claim_id"`
Output Transaction `json:"output"`
Success bool `json:"success"`
Tx TransactionSummary `json:"tx"`
}
type ChannelNewResponse PublishResponse
type ChannelListResponse struct {
Items []Transaction `json:"items"`
Page uint64 `json:"page"`
PageSize uint64 `json:"page_size"`
TotalPages uint64 `json:"total_pages"`
}
type ClaimAbandonResponse struct {
Success bool `json:"success"`
Tx TransactionSummary `json:"tx"`
}
type Support struct {
Amount string `json:"amount"`
Nout uint64 `json:"nout"`
Txid string `json:"txid"`
}
type Claim struct {
Address string `json:"address"`
Amount string `json:"amount"`
ChannelName *string `json:"channel_name,omitempty"`
ClaimID string `json:"claim_id"`
ClaimSequence uint64 `json:"claim_sequence"`
DecodedClaim bool `json:"decoded_claim"`
Depth int64 `json:"depth"`
EffectiveAmount string `json:"effective_amount"`
HasSignature *bool `json:"has_signature,omitempty"`
Height int `json:"height"`
Hex string `json:"hex"`
Name string `json:"name"`
Nout uint64 `json:"nout"`
PermanentUrl string `json:"permanent_url"`
SignatureIsValid *bool `json:"signature_is_valid,omitempty"`
Supports []Support `json:"supports"`
Txid string `json:"txid"`
Type string `json:"type"`
ValidAtHeight int `json:"valid_at_height"`
Value lbryschema.Claim `json:"value"`
}
type ClaimListResponse struct {
Claims []Claim `json:"claims"`
LastTakeoverHeight int `json:"last_takeover_height"`
SupportsWithoutClaims []Support `json:"supports_without_claims"`
}
type ClaimListMineResponse struct {
Claims []Claim `json:"items"`
Page uint64 `json:"page"`
PageSize uint64 `json:"page_size"`
TotalPages uint64 `json:"total_pages"`
}
type StatusResponse struct {
BlobManager struct {
FinishedBlobs uint64 `json:"finished_blobs"`
} `json:"blob_manager"`
ConnectionStatus struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"connection_status"`
Dht struct {
NodeID string `json:"node_id"`
PeersInRoutingTable uint64 `json:"peers_in_routing_table"`
} `json:"dht"`
FileManager struct {
ManagedFiles uint64 `json:"managed_files"`
} `json:"file_manager"`
HashAnnouncer struct {
AnnounceQueueSize uint64 `json:"announce_queue_size"`
} `json:"hash_announcer"`
InstallationID string `json:"installation_id"`
IsFirstRun bool `json:"is_first_run"`
IsRunning bool `json:"is_running"`
SkippedComponents []string `json:"skipped_components"`
StartupStatus struct {
BlobManager bool `json:"blob_manager"`
BlockchainHeaders bool `json:"blockchain_headers"`
Database bool `json:"database"`
Dht bool `json:"dht"`
ExchangeRateManager bool `json:"exchange_rate_manager"`
FileManager bool `json:"file_manager"`
HashAnnouncer bool `json:"hash_announcer"`
PaymentRateManager bool `json:"payment_rate_manager"`
PeerProtocolServer bool `json:"peer_protocol_server"`
RateLimiter bool `json:"rate_limiter"`
Upnp bool `json:"upnp"`
Wallet bool `json:"wallet"`
} `json:"startup_status"`
Upnp struct {
AioupnpVersion string `json:"aioupnp_version"`
DhtRedirectSet bool `json:"dht_redirect_set"`
ExternalIp string `json:"external_ip"`
Gateway string `json:"gateway"`
PeerRedirectSet bool `json:"peer_redirect_set"`
Redirects struct{} `json:"redirects"`
}
Wallet struct {
BestBlockchain string `json:"best_blockchain"`
Blocks int `json:"blocks"`
BlocksBehind int `json:"blocks_behind"`
IsEncrypted bool `json:"is_encrypted"`
IsLocked bool `json:"is_locked"`
} `json:"wallet"`
}
type UTXOListResponse []struct {
Address string `json:"address"`
Amount string `json:"amount"`
Height int `json:"height"`
IsClaim bool `json:"is_claim"`
IsCoinbase bool `json:"is_coinbase"`
IsSupport bool `json:"is_support"`
IsUpdate bool `json:"is_update"`
Nout int `json:"nout"`
Txid string `json:"txid"`
}
type VersionResponse struct {
Build string `json:"build"`
Desktop string `json:"desktop"`
Distro struct {
Codename string `json:"codename"`
ID string `json:"id"`
Like string `json:"like"`
Version string `json:"version"`
VersionParts struct {
BuildNumber string `json:"build_number"`
Major string `json:"major"`
Minor string `json:"minor"`
} `json:"version_parts"`
} `json:"distro"`
LbrynetVersion string `json:"lbrynet_version"`
LbryschemaVersion string `json:"lbryschema_version"`
OsRelease string `json:"os_release"`
OsSystem string `json:"os_system"`
Platform string `json:"platform"`
Processor string `json:"processor"`
PythonVersion string `json:"python_version"`
}
type ResolveResponse map[string]ResolveResponseItem
type ResolveResponseItem struct {
Certificate *Claim `json:"certificate,omitempty"`
Claim *Claim `json:"claim,omitempty"`
ClaimsInChannel *uint64 `json:"claims_in_channel,omitempty"`
Error *string `json:"error,omitempty"`
}
type NumClaimsInChannelResponse map[string]struct {
ClaimsInChannel *uint64 `json:"claims_in_channel,omitempty"`
Error *string `json:"error,omitempty"`
}
type ClaimShowResponse *Claim
+56
View File
@@ -0,0 +1,56 @@
// mostly copied from github.com/AlekSi/pointer
// Provides helpers to get pointers to values of build-in types.
package util
import (
"time"
"github.com/lbryio/lbry.go/extras/null"
)
func PtrToBool(b bool) *bool { return &b }
func PtrToByte(b byte) *byte { return &b }
func PtrToComplex128(c complex128) *complex128 { return &c }
func PtrToComplex64(c complex64) *complex64 { return &c }
func PtrToError(e error) *error { return &e }
func PtrToFloat32(f float32) *float32 { return &f }
func PtrToFloat64(f float64) *float64 { return &f }
func PtrToInt(i int) *int { return &i }
func PtrToInt16(i int16) *int16 { return &i }
func PtrToInt32(i int32) *int32 { return &i }
func PtrToInt64(i int64) *int64 { return &i }
func PtrToInt8(i int8) *int8 { return &i }
func PtrToRune(r rune) *rune { return &r }
func PtrToString(s string) *string { return &s }
func PtrToTime(t time.Time) *time.Time { return &t }
func PtrToUint(u uint) *uint { return &u }
func PtrToUint16(u uint16) *uint16 { return &u }
func PtrToUint32(u uint32) *uint32 { return &u }
func PtrToUint64(u uint64) *uint64 { return &u }
func PtrToUint8(u uint8) *uint8 { return &u }
func PtrToUintptr(u uintptr) *uintptr { return &u }
func PtrToNullString(s string) *null.String { n := null.StringFrom(s); return &n }
func PtrToNullUint64(u uint64) *null.Uint64 { n := null.Uint64From(u); return &n }
func StrFromPtr(ptr *string) string {
if ptr == nil {
return ""
}
return *ptr
}
func StrFromNull(str null.String) string {
if !str.Valid {
return ""
}
return str.String
}
func NullStringFrom(s string) null.String {
if s == "" {
return null.String{}
}
return null.StringFrom(s)
}
+1
View File
@@ -8,6 +8,7 @@ require (
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/davecgh/go-spew v1.1.0
github.com/fatih/structs v1.1.0
github.com/go-errors/errors v1.0.1
github.com/go-ini/ini v1.38.2
github.com/go-ozzo/ozzo-validation v3.5.0+incompatible // indirect
+2 -2
View File
@@ -14,6 +14,8 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
@@ -56,8 +58,6 @@ github.com/lyoshenka/bencode v0.0.0-20180323155644-b7abd7672df5 h1:mG83tLXWSRdcX
github.com/lyoshenka/bencode v0.0.0-20180323155644-b7abd7672df5/go.mod h1:H0aPCWffGOaDcjkw1iB7W9DVLp6GXmfcJY/7YZCWPA4=
github.com/mitchellh/mapstructure v0.0.0-20180511142126-bb74f1db0675 h1:/rdJjIiKG5rRdwG5yxHmSE/7ZREjpyC0kL7GxGT/qJw=
github.com/mitchellh/mapstructure v0.0.0-20180511142126-bb74f1db0675/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/nlopes/slack v0.2.0 h1:ygNVH3HWrOPFbzFoAmRKPcMcmYMmsLf+vPV9DhJdqJI=
github.com/nlopes/slack v0.2.0/go.mod h1:jVI4BBK3lSktibKahxBF74txcK2vyvkza1z/+rRnVAM=
github.com/nlopes/slack v0.5.0 h1:NbIae8Kd0NpqaEI3iUrsuS0KbcEDhzhc939jLW5fNm0=
github.com/nlopes/slack v0.5.0/go.mod h1:jVI4BBK3lSktibKahxBF74txcK2vyvkza1z/+rRnVAM=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=