model

package
v0.0.0-...-3a7d5fb Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPort

func DefaultPort(u *url.URL) int

DefaultPort returns the default port for the given connection scheme unless otherwise indicated in the url.URL provided

func HasImpliedURLSecurity

func HasImpliedURLSecurity(u *url.URL) bool

HasImpliedURLSecurity returns true if the scheme is https

func ToFloat

func ToFloat(i interface{}) (float64, error)

ToFloat ensures that any value returned by an insight or blockbook response is case to a float64 or errors

Types

type APIClient

type APIClient interface {

	// Start up the API service
	Start() error

	// Get info about the server
	GetInfo() (*Info, error)

	// For a given txid get back the transaction metadata
	GetTransaction(txid string) (*Transaction, error)

	// For a given txid get back the full transaction bytes
	GetRawTransaction(txid string) ([]byte, error)

	// Get back all the transactions for the given list of addresses
	GetTransactions(addrs []btcutil.Address) ([]Transaction, error)

	// Get back all spendable UTXOs for the given list of addresses
	GetUtxos(addrs []btcutil.Address) ([]Utxo, error)

	// Returns a chan which fires on each new block
	BlockNotify() <-chan Block

	// Returns a chan which fires whenever a new transaction is received or
	// when an existing transaction confirms for all addresses the API is listening on.
	TransactionNotify() <-chan Transaction

	// Listen for events on these addresses. Results are returned to TransactionNotify()
	ListenAddresses(addrs ...btcutil.Address)

	// Broadcast a transaction to the network
	Broadcast(tx []byte) (string, error)

	// Get info on the current chain tip
	GetBestBlock() (*Block, error)

	// Estimate the fee required for a transaction
	EstimateFee(nBlocks int) (int, error)

	// Close all connections and shutdown
	Close()
}

type AddressTxid

type AddressTxid struct {
	Address string `json:"address"`
	Txid    string `json:"txid"`
}

type Block

type Block struct {
	Hash              string    `json:"hash"`
	Size              int       `json:"size"`
	Height            int       `json:"height"`
	Version           int       `json:"version"`
	MerkleRoot        string    `json:"merkleroot"`
	Tx                []string  `json:"tx"`
	Time              int64     `json:"time"`
	Nonce             string    `json:"nonce"`
	Solution          string    `json:"solution"`
	Bits              string    `json:"bits"`
	Difficulty        float64   `json:"difficulty"`
	Chainwork         string    `json:"chainwork"`
	Confirmations     int       `json:"confirmations"`
	PreviousBlockhash string    `json:"previousblockhash"`
	NextBlockhash     string    `json:"nextblockhash"`
	Reward            float64   `json:"reward"`
	IsMainChain       bool      `json:"isMainChain"`
	PoolInfo          *PoolInfo `json:"poolinfo"`
}

type BlockList

type BlockList struct {
	Blocks     []Block    `json:"blocks"`
	Length     int        `json:"length"`
	Pagination Pagination `json:"pagination"`
}

type Info

type Info struct {
	Version         int         `json:"version"`
	ProtocolVersion int         `json:"protocolversion"`
	Blocks          int         `json:"blocks"`
	TimeOffset      int         `json:"timeoffset"`
	Connections     int         `json:"connections"`
	DifficultyIface interface{} `json:"difficulty"`
	Difficulty      float64     `json:"-"`
	Testnet         bool        `json:"testnet"`
	RelayFeeIface   interface{} `json:"relayfee"`
	RelayFee        float64     `json:"-"`
	Errors          string      `json:"errors"`
	Network         string      `json:"network"`
}

func (Info) IsEqual

func (i Info) IsEqual(other Info) bool

type Input

type Input struct {
	Txid            string      `json:"txid"`
	Vout            int         `json:"vout"`
	Sequence        uint32      `json:"sequence"`
	N               int         `json:"n"`
	ScriptSig       Script      `json:"scriptSig"`
	Addr            string      `json:"addr"`
	Satoshis        int64       `json:"valueSat"`
	ValueIface      interface{} `json:"value"`
	Value           float64
	DoubleSpentTxid string `json:"doubleSpentTxID"`
}

type OutScript

type OutScript struct {
	Script
	Addresses []string `json:"addresses"`
	Type      string   `json:"type"`
}

type Output

type Output struct {
	ValueIface   interface{} `json:"value"`
	Value        float64
	N            int       `json:"n"`
	ScriptPubKey OutScript `json:"scriptPubKey"`
	SpentTxid    string    `json:"spentTxId"`
	SpentIndex   int       `json:"spentIndex"`
	SpentHeight  int       `json:"spentHeight"`
}

type Pagination

type Pagination struct {
	Next      string `json:"next"`
	Prev      string `json:"prev"`
	CurrentTs int    `json:"currentTs"`
	Current   string `json:"current"`
	IsToday   bool   `json:"isToday"`
	More      bool   `json:"more"`
	MoreTs    int    `json:"moreTs"`
}

type PoolInfo

type PoolInfo struct {
	PoolName string `json:"poolName"`
	URL      string `json:"url"`
}

type RawTxResponse

type RawTxResponse struct {
	RawTx string `json:"rawtx"`
}

type Script

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

type SocketClient

type SocketClient interface {

	// Set callback for method
	On(method string, callback interface{}) error

	// Listen on method
	Emit(method string, args []interface{}) error

	// Close the socket connection
	Close()
}

type Status

type Status struct {
	Info Info `json:"info"`
}

type Transaction

type Transaction struct {
	Txid          string   `json:"txid"`
	Version       int      `json:"version"`
	Locktime      int      `json:"locktime"`
	Inputs        []Input  `json:"vin"`
	Outputs       []Output `json:"vout"`
	BlockHash     string   `json:"blockhash"`
	BlockHeight   int      `json:"blockheight"`
	Confirmations int      `json:"confirmations"`
	Time          int64    `json:"time"`
	BlockTime     int64    `json:"blocktime"`
	RawBytes      []byte   `json:"rawbytes"`
}

type TransactionList

type TransactionList struct {
	TotalItems int           `json:"totalItems"`
	From       int           `json:"from"`
	To         int           `json:"to"`
	Items      []Transaction `json:"items"`
}

type Utxo

type Utxo struct {
	Address       string      `json:"address"`
	Txid          string      `json:"txid"`
	Vout          int         `json:"vout"`
	ScriptPubKey  string      `json:"scriptPubKey"`
	AmountIface   interface{} `json:"amount"`
	Amount        float64
	Satoshis      int64 `json:"satoshis"`
	Confirmations int   `json:"confirmations"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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