lbrycrd

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2018 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// NonStandard is a transaction type, usually used for a claim.
	NonStandard = "nonstandard" // Non Standard - Used for Claims in LBRY

)

Variables

View Source
var LBRYcrdURL string

LBRYcrdURL is the connection string for lbrycrd and is set from the configuration

Functions

func GetAddressFromPublicKeyScript

func GetAddressFromPublicKeyScript(script []byte) (address string)

GetAddressFromPublicKeyScript returns the address associated with a public key script.

func GetBalance

func GetBalance() (*float64, error)

GetBalance returns the balance of a wallet address.

func GetBlockCount

func GetBlockCount() (*uint64, error)

GetBlockCount returns the highest block LBRYcrd is aware of.

func GetBlockHash

func GetBlockHash(i uint64) (*string, error)

GetBlockHash performs a jsonrpc that returns the hash of the block as a string.

func GetPubKeyScriptFromClaimPKS

func GetPubKeyScriptFromClaimPKS(script []byte) (pubkeyscript []byte, err error)

GetPubKeyScriptFromClaimPKS gets the public key script at the end of a claim script.

func Init

func Init() *upstream.Client

Init initializes a client with settings from the configuration of chainquery

func IsClaimNameScript

func IsClaimNameScript(script []byte) bool

IsClaimNameScript returns true if the script for the vout contains the OP_CLAIM_NAME code.

func IsClaimScript

func IsClaimScript(script []byte) bool

IsClaimScript return true if the script for the vout contains the right opt codes pertaining to a claim.

func IsClaimSupportScript

func IsClaimSupportScript(script []byte) bool

IsClaimSupportScript returns true if the script for the vout contains the OP_CLAIM_SUPPORT code.

func IsClaimUpdateScript

func IsClaimUpdateScript(script []byte) bool

IsClaimUpdateScript returns true if the script for the vout contains the OP_CLAIM_UPDATE code.

func ParseClaimNameScript

func ParseClaimNameScript(script []byte) (name string, value []byte, pubkeyscript []byte, err error)

ParseClaimNameScript parses a script for the claim of a name.

func ParseClaimSupportScript

func ParseClaimSupportScript(script []byte) (name string, claimid string, pubkeyscript []byte, err error)

ParseClaimSupportScript parses a script for a support of a claim.

func ParseClaimUpdateScript

func ParseClaimUpdateScript(script []byte) (name string, claimid string, value []byte, pubkeyscript []byte, err error)

ParseClaimUpdateScript parses a script for an update of a claim.

Types

type Claim

type Claim struct {
	Name            string    `json:"name,omitempty"`
	ClaimID         string    `json:"claimId"`
	TxID            string    `json:"txid"`
	N               int32     `json:"n"`
	Height          int32     `json:"nHeight"`
	ValidAtHeight   int32     `json:"nValidAtHeight"`
	Amount          float64   `json:"nAmount"`
	EffectiveAmount uint64    `json:"nEffectiveAmount"`
	Supports        []Support `json:"supports,omitempty"`
}

Claim models the data of a claim both static and dynamic. Used for claimtrie sync.

type ClaimNameResult

type ClaimNameResult struct {
	Name   string        `json:"name"`
	Claims []ClaimResult `json:"claims,omitempty"`
}

ClaimNameResult models the data from the claimtrie of lbrycrd.

func GetClaimsInTrie

func GetClaimsInTrie() ([]ClaimNameResult, error)

GetClaimsInTrie gets all the claims current active in the claim trie

type ClaimResult

type ClaimResult struct {
	ClaimID  string  `json:"claimId"`
	TxID     string  `json:"txid"`
	Sequence uint64  `json:"n"`
	Amount   float64 `json:"amount"`
	Height   uint64  `json:"height"`
	Value    string  `json:"value"`
}

ClaimResult models the static data of a claim in the claimtrie

type ClaimsForNameResult

type ClaimsForNameResult struct {
	LastTakeOverHeight int32     `json:"nLastTakeoverheight"`
	Claims             []Claim   `json:"claims"`
	UnmatchedSupports  []Support `json:"unmatched supports"`
}

ClaimsForNameResult models the claim list for a name in the claimtrie of lbrycrd.

func GetClaimsForName

func GetClaimsForName(name string) (ClaimsForNameResult, error)

GetClaimsForName gets all the claims for a name in the claimtrie.

type Fee

type Fee struct {
	LBC *FeeInfo `json:"LBC,omitempty"`
	BTC *FeeInfo `json:"BTC,omitempty"`
	USD *FeeInfo `json:"USD,omitempty"`
}

Fee is the structure used for different currencies allowed for claims.

type FeeInfo

type FeeInfo struct {
	Amount  float32 `json:"amount"`  //Required
	Address string  `json:"address"` //Required
}

FeeInfo is the structure of fee information used by lbry.

type GetBlockHeaderResponse

type GetBlockHeaderResponse struct {
	Hash          string  `json:"hash"`
	Confirmations uint64  `json:"confirmations"`
	Height        int32   `json:"height"`
	Version       int32   `json:"version"`
	VersionHex    string  `json:"versionHex"`
	MerkleRoot    string  `json:"merkleroot"`
	Time          int64   `json:"time"`
	Nonce         uint64  `json:"nonce"`
	Bits          string  `json:"bits"`
	Difficulty    float64 `json:"difficulty"`
	PreviousHash  string  `json:"previousblockhash,omitempty"`
	NextHash      string  `json:"nextblockhash,omitempty"`
}

GetBlockHeaderResponse models the data from the getblockheader command when the verbose flag is set. When the verbose flag is not set, getblockheader returns a hex-encoded string.

type GetBlockResponse

type GetBlockResponse struct {
	Hash          string   `json:"hash"`
	Confirmations uint64   `json:"confirmations"`
	StrippedSize  int32    `json:"strippedsize"`
	Size          int32    `json:"size"`
	Weight        int32    `json:"weight"`
	Height        int64    `json:"height"`
	Version       int32    `json:"version"`
	VersionHex    string   `json:"versionHex"`
	MerkleRoot    string   `json:"merkleroot"`
	NameClaimRoot string   `json:"nameclaimroot"`
	Tx            []string `json:"tx"`
	Time          int64    `json:"time"`
	Nonce         uint64   `json:"nonce"`
	Bits          string   `json:"bits"`
	Difficulty    float64  `json:"difficulty"`
	PreviousHash  string   `json:"previousblockhash"`
	NextHash      string   `json:"nextblockhash,omitempty"`
	ChainWork     string   `json:"chainwork"`
}

GetBlockResponse models the data from the getblock command when the verbose flag is set. When the verbose flag is not set, getblock returns a hex-encoded string.

func GetBlock

func GetBlock(blockHash string) (*GetBlockResponse, error)

GetBlock performs a jsonrpc that returns the structured data as a GetBlockResponse. If LBRYcrd contains this block it will be returned.

type ScriptPubKeyResult

type ScriptPubKeyResult struct {
	Asm       string   `json:"asm"`
	Hex       string   `json:"hex,omitempty"`
	ReqSigs   int32    `json:"reqSigs,omitempty"`
	Type      string   `json:"type"`
	Addresses []string `json:"addresses,omitempty"`
}

ScriptPubKeyResult models the scriptPubKey data of a tx script. It is defined separately since it is used by multiple commands.

type ScriptSig

type ScriptSig struct {
	Asm string `json:"asm"`
	Hex string `json:"hex"`
}

ScriptSig models a signature script. It is defined separately since it only applies to non-coinbase. Therefore the field in the Vin structure needs to be a pointer.

type Sources

type Sources struct {
	LbrySDHash string `json:"lbry_sd_hash"` //Required
	BTIH       string `json:"btih"`         //Required
	URL        string `json:"url"`          //Required
}

Sources is the structure of Sources that can be used for a claim. Sources mainly include lbrysdhash but could be from elsewhere in the future.

type Support

type Support struct {
	TxID          string  `json:"txid"`
	N             int32   `json:"n"`
	Height        int32   `json:"nHeight"`
	ValidAtHeight int32   `json:"nValidAtHeight"`
	Amount        float64 `json:"nAmount"`
}

Support models the support information for a claim in the claimtrie of lbrycrd.

type TxRawResult

type TxRawResult struct {
	Hex           string `json:"hex"`
	Txid          string `json:"txid"`
	Hash          string `json:"hash,omitempty"`
	Size          int32  `json:"size,omitempty"`
	Vsize         int32  `json:"vsize,omitempty"`
	Version       int32  `json:"version"`
	LockTime      uint64 `json:"locktime"`
	Vin           []Vin  `json:"vin"`
	Vout          []Vout `json:"vout"`
	BlockHash     string `json:"blockhash,omitempty"`
	Confirmations uint64 `json:"confirmations,omitempty"`
	Time          int64  `json:"time,omitempty"`
	Blocktime     int64  `json:"blocktime,omitempty"`
}

TxRawResult models the data from the getrawtransaction command.

func GetRawTransactionResponse

func GetRawTransactionResponse(hash string) (*TxRawResult, error)

GetRawTransactionResponse returns the raw transactions structured data. This will not always work. LBRYcrd must have -txindex turned on otherwise only transactions in the memory pool can be returned.

type V1Claim

type V1Claim struct {
	Version     string  `json:"ver,omitempty"`
	Title       string  `json:"title"`        //Required
	Description string  `json:"description"`  //Required
	Author      string  `json:"author"`       //Required
	Language    string  `json:"language"`     //Required
	License     string  `json:"license"`      //Required
	Sources     Sources `json:"sources"`      //Required
	ContentType string  `json:"content-type"` //Required
	Thumbnail   *string `json:"thumbnail,omitempty"`
	Fee         *Fee    `json:"fee,omitempty"`
	Contact     *int    `json:"contact,omitempty"`
	PubKey      *string `json:"pubkey,omitempty"`
}

V1Claim is the first version of claim metadata used by lbry.

func (*V1Claim) Unmarshal

func (c *V1Claim) Unmarshal(value []byte) error

Unmarshal is an implementation to unmarshal the V1 claim from json. Main addition is to check the version.

type V2Claim

type V2Claim struct {
	Version     string  `json:"ver"`          //Required
	Title       string  `json:"title"`        //Required
	Description string  `json:"description"`  //Required
	Author      string  `json:"author"`       //Required
	Language    string  `json:"language"`     //Required
	License     string  `json:"license"`      //Required
	Sources     Sources `json:"sources"`      //Required
	ContentType string  `json:"content-type"` //Required
	Thumbnail   *string `json:"thumbnail,omitempty"`
	Fee         *Fee    `json:"fee,omitempty"`
	Contact     *int    `json:"contact,omitempty"`
	PubKey      *string `json:"pubkey,omitempty"`
	LicenseURL  *string `json:"license_url,omitempty"`
	NSFW        bool    `json:"nsfw"` //Required

}

V2Claim is the second version of claim metadata used by lbry.

func (*V2Claim) Unmarshal

func (c *V2Claim) Unmarshal(value []byte) error

Unmarshal is an implementation to unmarshal the V2 claim from json. Main addition is to check the version.

type V3Claim

type V3Claim struct {
	Version     string  `json:"ver"`          //Required
	Title       string  `json:"title"`        //Required
	Description string  `json:"description"`  //Required
	Author      string  `json:"author"`       //Required
	Language    string  `json:"language"`     //Required
	License     string  `json:"license"`      //Required
	Sources     Sources `json:"sources"`      //Required
	ContentType string  `json:"content_type"` //Required
	Thumbnail   *string `json:"thumbnail,omitempty"`
	Fee         *Fee    `json:"fee,omitempty"`
	Contact     *int    `json:"contact,omitempty"`
	PubKey      *string `json:"pubkey,omitempty"`
	LicenseURL  *string `json:"license_url,omitempty"`
	NSFW        bool    `json:"nsfw"` //Required
	Sig         *string `json:"sig"`
}

V3Claim is the third version of claim metadata used by lbry.

func (*V3Claim) Unmarshal

func (c *V3Claim) Unmarshal(value []byte) error

Unmarshal is an implementation to unmarshal the V3 claim from json. Main addition is to check the version.

type Vin

type Vin struct {
	Coinbase  string     `json:"coinbase"`
	TxID      string     `json:"txid"`
	Vout      uint64     `json:"vout"`
	ScriptSig *ScriptSig `json:"scriptSig"`
	Sequence  uint64     `json:"sequence"`
}

Vin models parts of the tx data. It is defined separately since getrawtransaction, decoderawtransaction, and searchrawtransaction use the same structure.

type Vout

type Vout struct {
	Value        float64            `json:"value"`
	N            uint64             `json:"n"`
	ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"`
}

Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL