lbrycrd

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 18 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
	NullData    = "nulldata"
	P2WPKH_V0   = "witness_v0_keyhash"    //Segwit Pub Key Hash
	P2WSH_V0    = "witness_v0_scripthash" //Segwit Script Hash

)

Variables

View Source
var ErrNotClaimScript = errors.Base("Script is not a claim script!")

ErrNotClaimScript is a base error for when a script cannot be parsed as a claim script.

View Source
var LBRYcrdClient *upstream.Client

LBRYcrdClient is the client for communicating with LBRYcrd from Chainquery.

View Source
var LBRYcrdURL string

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

Functions

func ClaimName added in v1.5.0

func ClaimName(name string, hexValue string, amount float64) (string, error)

ClaimName creates a claim transaction for lbrycrd.

func GenerateBlocks added in v1.5.0

func GenerateBlocks(count int64) ([]string, error)

GenerateBlocks generates n blocks in regtest. Will error in mainnet or testnet.

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 GetChainParams added in v1.7.0

func GetChainParams() (*chaincfg.Params, error)

GetChainParams returns the currently set blockchain name as the chain parameters. Set in the config.

func GetGenesisBlock added in v1.9.0

func GetGenesisBlock() (*GetBlockVerboseResponse, *GetBlockResponse, error)

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

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"`
	Value           string    `json:"value"`
	Address         string    `json:"address"`
	ClaimID         string    `json:"claimId"`
	TxID            string    `json:"txId"`
	N               int32     `json:"n"`
	Height          int32     `json:"height"`
	ValidAtHeight   int32     `json:"validAtHeight"`
	Amount          uint64    `json:"amount"`
	EffectiveAmount uint64    `json:"effectiveAmount"`
	Supports        []Support `json:"supports,omitempty"`
	Bid             uint64    `json:"bid"`
	Sequence        int       `json:"sequence"`
}

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:"effectiveValue"`
}

ClaimResult models the static data of a claim in the claimtrie

type ClaimsForNameResult

type ClaimsForNameResult struct {
	NormalizedName       string    `json:"normalizedName"`
	Claims               []Claim   `json:"claims"`
	LastTakeOverHeight   int32     `json:"lastTakeoverHeight"`
	SupportsWithoutClaim []Support `json:"supportsWithoutClaim"`
}

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 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"`
	NameClaimRoot     string  `json:"nameclaimroot"`
	Time              int64   `json:"time"`
	MedianTime        int64   `json:"mediantime"`
	Nonce             uint64  `json:"nonce"`
	Bits              string  `json:"bits"`
	Difficulty        float64 `json:"difficulty"`
	ChainWork         string  `json:"chainwork"`
	NTx               int32   `json:"nTx"`
	PreviousBlockHash string  `json:"previousblockhash,omitempty"`
	NextBlockHash     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"`
	MedianTime        int64    `json:"mediantime"`
	Nonce             uint64   `json:"nonce"`
	Bits              string   `json:"bits"`
	Difficulty        float64  `json:"difficulty"`
	ChainWork         string   `json:"chainwork"`
	NTx               int32    `json:"nTx"`
	PreviousBlockHash string   `json:"previousblockhash"`
	NextBlockHash     string   `json:"nextblockhash,omitempty"`
}

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 GetBlockVerboseResponse added in v1.9.0

type GetBlockVerboseResponse struct {
	Hash              string        `json:"hash"`
	Confirmations     int64         `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                []TxRawResult `json:"tx,omitempty"`
	Time              int64         `json:"time"`
	MedianTime        int64         `json:"mediantime"`
	Nonce             uint64        `json:"nonce"`
	Bits              string        `json:"bits"`
	Difficulty        float64       `json:"difficulty"`
	ChainWork         string        `json:"chainwork"`
	NTx               int32         `json:"nTx"`
	PreviousBlockHash string        `json:"previousblockhash"`
	NextBlockHash     string        `json:"nextblockhash,omitempty"`
}

GetBlockVerboseResponse 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.

type GetRawMempoolVerboseResult added in v1.2.0

type GetRawMempoolVerboseResult struct {
	Fees struct {
		Base       float64 `json:"base"`
		Modified   float64 `json:"modified"`
		Ancestor   float64 `json:"ancestor"`
		Descendant float64 `json:"descendant"`
	} `json:"fees"`
	Size            int      `json:"size"`
	Fee             float64  `json:"fee"`
	ModifiedFee     float64  `json:"modifiedfee"`
	Time            int64    `json:"time"`
	Height          int32    `json:"height"`
	DescendantCount int32    `json:"descendantcount"`
	DescendantSize  int32    `json:"descendantsize"`
	DescendantFees  uint64   `json:"descendantfees"`
	AncestorCount   int32    `json:"ancestorcount"`
	AncestorSize    int32    `json:"ancestorsize"`
	AncestorFees    int32    `json:"ancestorfees"`
	WtxID           string   `json:"wtxid"`
	Depends         []string `json:"depends"`
	SpentBy         []string `json:"spentby"`
}

GetRawMempoolVerboseResult models the data returned from the getrawmempool command when the verbose flag is set. When the verbose flag is not set, getrawmempool returns an array of transaction hashes.

type RawMempoolVerboseResponse added in v1.2.0

type RawMempoolVerboseResponse map[string]GetRawMempoolVerboseResult

RawMempoolVerboseResponse models the object of mempool results

func GetRawMempool added in v1.2.0

func GetRawMempool() (RawMempoolVerboseResponse, error)

GetRawMempool gets all the transactions in the mempool

type Support

type Support struct {
	Address       string `json:"address"`
	TxID          string `json:"txId"`
	N             int32  `json:"n"`
	Height        int32  `json:"height"`
	ValidAtHeight int32  `json:"validAtHeight"`
	Amount        uint64 `json:"amount"`
}

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

type TxRawResult

type TxRawResult struct {
	Txid          string `json:"txid"`
	Hash          string `json:"hash,omitempty"`
	Version       int32  `json:"version"`
	Size          int32  `json:"size,omitempty"`
	Vsize         int32  `json:"vsize,omitempty"`
	Weight        int32  `json:"weight"`
	LockTime      uint64 `json:"locktime"`
	Vin           []Vin  `json:"vin"`
	Vout          []Vout `json:"vout"`
	Hex           string `json:"hex"`
	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. 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 Vin

type Vin struct {
	Coinbase  string             `json:"coinbase"`
	TxID      string             `json:"txid"`
	Vout      uint64             `json:"vout"`
	ScriptSig *btcjson.ScriptSig `json:"scriptSig"`
	Sequence  uint64             `json:"sequence"`
	Witness   []string           `json:"txinwitness"`
}

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 btcjson.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