Documentation ¶
Index ¶
- type Block
- type BlockHeader
- type BlockNormal
- type Blockchain
- func (b *Blockchain) GetBlockHashes(heights []int) ([]string, error)
- func (b *Blockchain) GetBlockchainInfo() (*BlockchainInfo, error)
- func (b *Blockchain) GetBlocks(val interface{}) ([]*Block, error)
- func (b *Blockchain) GetBlocksNormal(hashes []string) ([]*BlockNormal, error)
- func (b *Blockchain) GetBlocksVerbose(hashes []string) ([]*Block, error)
- func (b *Blockchain) GetBlocksVerboseDoge(hashes []string) ([]*Block, error)
- func (b *Blockchain) GetChainInfo() (*ChainInfo, error)
- func (b *Blockchain) GetChainTips() ([]*ChainTip, error)
- func (b *Blockchain) GetMempool() ([]string, error)
- func (b *Blockchain) GetNetworkInfo() (*NetworkInfo, error)
- func (b *Blockchain) GetRawTransactions(hashes []string) ([]*Tx, error)
- func (b *Blockchain) SendRawTransaction(rawtx string) (string, error)
- type BlockchainInfo
- type ChainInfo
- type ChainTip
- type MempoolTx
- type NetworkInfo
- type Tx
- type Vin
- type Vout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { BlockHeader Txs []Tx `json:"tx,omitempty"` }
Block contains the BlockHeader and array of verbose transactions
type BlockHeader ¶
type BlockHeader struct { Hash string `json:"hash"` Height int `json:"height"` Time int `json:"time"` MedianTime int `json:"mediantime"` Nonce int `json:"nonce"` PrevHash string `json:"previousblockhash"` NextHash string `json:"nextblockhash"` Bits string `json:"bits"` Difficulty json.Number `json:"difficulty"` Chainwork string `json:"chainwork"` Version int `json:"version"` VersionHex string `json:"versionHex"` MerkleRoot string `json:"merkleroot"` Size int `json:"size"` StrippedSize int `json:"strippedsize"` Weight int `json:"weight"` TxCount int `json:"nTx"` IsOrphan bool `json:"isOrphan"` }
BlockHeader contains block data minus the transactions
type BlockNormal ¶
type BlockNormal struct { BlockHeader Txs []string `json:"tx"` }
BlockNormal contains the BlockHeader and array of transaction ids
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain for indexing bitcoin blockchain node
func New ¶
func New(r *config.RPC, c string) *Blockchain
New creates a new JSONRPC client used to interact with the node
func (*Blockchain) GetBlockHashes ¶
func (b *Blockchain) GetBlockHashes(heights []int) ([]string, error)
GetBlockHashes returns the block hashes of blocks at the specified heights
func (*Blockchain) GetBlockchainInfo ¶
func (b *Blockchain) GetBlockchainInfo() (*BlockchainInfo, error)
GetBlockchainInfo returns information about the connected blockchain node
func (*Blockchain) GetBlocks ¶
func (b *Blockchain) GetBlocks(val interface{}) ([]*Block, error)
GetBlocks returns an array of verbose blocks using the array of heights
func (*Blockchain) GetBlocksNormal ¶
func (b *Blockchain) GetBlocksNormal(hashes []string) ([]*BlockNormal, error)
GetBlocksNormal returns blocks with provided hashes as an array of BlockInfo
func (*Blockchain) GetBlocksVerbose ¶
func (b *Blockchain) GetBlocksVerbose(hashes []string) ([]*Block, error)
GetBlocksVerbose returns blocks with provided hashes as an array of Block
func (*Blockchain) GetBlocksVerboseDoge ¶
func (b *Blockchain) GetBlocksVerboseDoge(hashes []string) ([]*Block, error)
GetBlocksVerboseDoge handles constructing verbose blocks for doge due to lack of verbose txs in block
func (*Blockchain) GetChainInfo ¶
func (b *Blockchain) GetChainInfo() (*ChainInfo, error)
GetChainInfo returns information about the blockchain and network
func (*Blockchain) GetChainTips ¶
func (b *Blockchain) GetChainTips() ([]*ChainTip, error)
GetChainTips returns information about all known tips in the block tree, including the main chain as well as orphaned branches
func (*Blockchain) GetMempool ¶
func (b *Blockchain) GetMempool() ([]string, error)
GetMempool returns an array of transaction hashes in the current mempool
func (*Blockchain) GetNetworkInfo ¶
func (b *Blockchain) GetNetworkInfo() (*NetworkInfo, error)
GetNetworkInfo returns information about the connected blockchain network
func (*Blockchain) GetRawTransactions ¶
func (b *Blockchain) GetRawTransactions(hashes []string) ([]*Tx, error)
GetRawTransactions returns the verbose transaction data for each hash
func (*Blockchain) SendRawTransaction ¶
func (b *Blockchain) SendRawTransaction(rawtx string) (string, error)
SendRawTransaction broadcasts raw tx on the network
type BlockchainInfo ¶
type BlockchainInfo struct { Chain string `json:"chain"` Blocks int `json:"blocks"` Headers int `json:"headers"` BestBlockHash string `json:"bestblockhash"` Difficulty json.Number `json:"difficulty"` SizeOnDisk int `json:"size_on_disk"` Warnings string `json:"warnings"` }
BlockchainInfo contains data returned from getblockchaininfo
type ChainInfo ¶
type ChainInfo struct { Chain string `json:"chain"` Blocks int `json:"blocks"` Headers int `json:"headers"` BestBlockHash string `json:"bestblockhash"` Difficulty string `json:"difficulty"` SizeOnDisk int `json:"size_on_disk"` Version string `json:"version"` Subversion string `json:"subversion"` ProtocolVersion string `json:"protocolversion"` Timeoffset int `json:"timeoffset"` Warnings string `json:"warnings"` }
ChainInfo has some higher level information about the underlying node
type ChainTip ¶
type ChainTip struct { Height int `json:"height"` Hash string `json:"hash"` Branchlen json.Number `json:"branchlen"` Status string `json:"status"` }
ChainTip contains details about blockchain branchs
type MempoolTx ¶
type MempoolTx struct { Hash string Fails int // number of times getting tx from blockchain failed }
MempoolTx contains the tx hash and fail count for mempool processing
type NetworkInfo ¶
type NetworkInfo struct { Version json.Number `json:"version"` Subversion string `json:"subversion"` ProtocolVersion json.Number `json:"protocolversion"` Timeoffset int `json:"timeoffset"` Warnings string `json:"warnings"` }
NetworkInfo contains data returned from getnetworkinfo
type Tx ¶
type Tx struct { TxID string `json:"txid"` Hash string `json:"hash"` Version int `json:"version"` Size int `json:"size"` VSize int `json:"vsize"` Weight int `json:"weight"` Locktime json.Number `json:"locktime"` Vins []Vin `json:"vin"` Vouts []Vout `json:"vout"` Hex string `json:"hex"` }
Tx is a struct of a utxo transaction
type Vin ¶
type Vin struct { TxID string `json:"txid"` Vout int `json:"vout"` ScriptSig struct { Asm string `json:"asm"` Hex string `json:"hex"` } `json:"scriptSig"` TxInWitness []string `json:"txinwitness"` Sequence int `json:"sequence"` Coinbase string `json:"coinbase"` }
Vin is struct of tx input