Documentation ¶
Index ¶
- Constants
- Variables
- func GetUniqueTxids(txids []string) []string
- func NewAPIError(s string, public bool) error
- type APIError
- type Address
- type AddressFilter
- type AddressUtxo
- type AddressUtxoV1
- type AddressV1
- type Amount
- type Block
- type BlockV1
- type BlockbookInfo
- type Blocks
- type EthereumSpecific
- type GetAddressOption
- type Paging
- type ScriptPubKeyV1
- type ScriptSigV1
- type SystemInfo
- type Token
- type TokenTransfer
- type TokenType
- type Tx
- type TxV1
- type Vin
- type VinV1
- type Vout
- type VoutV1
- type Worker
- func (w *Worker) AddressToV1(a *Address) *AddressV1
- func (w *Worker) AddressUtxoToV1(au []AddressUtxo) []AddressUtxoV1
- func (w *Worker) BlockToV1(b *Block) *BlockV1
- func (w *Worker) GetAddress(address string, page int, txsOnPage int, option GetAddressOption, ...) (*Address, error)
- func (w *Worker) GetAddressUtxo(address string, onlyConfirmed bool) ([]AddressUtxo, error)
- func (w *Worker) GetBlock(bid string, page int, txsOnPage int) (*Block, error)
- func (w *Worker) GetBlocks(page int, blocksOnPage int) (*Blocks, error)
- func (w *Worker) GetSpendingTxid(txid string, n int) (string, error)
- func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error)
- func (w *Worker) GetTransaction(txid string, spendingTxs bool, specificJSON bool) (*Tx, error)
- func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32, spendingTxs bool, specificJSON bool) (*Tx, error)
- func (w *Worker) TxToV1(tx *Tx) *TxV1
Constants ¶
const ( // AddressFilterVoutOff disables filtering of transactions by vout AddressFilterVoutOff = -1 // AddressFilterVoutInputs specifies that only txs where the address is as input are returned AddressFilterVoutInputs = -2 // AddressFilterVoutOutputs specifies that only txs where the address is as output are returned AddressFilterVoutOutputs = -3 )
Variables ¶
var Text struct { BlockbookAbout, TOSLink string }
Text contains static overridable texts used in explorer
Functions ¶
func GetUniqueTxids ¶ added in v0.2.0
GetUniqueTxids removes duplicate transactions
func NewAPIError ¶ added in v0.1.1
NewAPIError creates ApiError
Types ¶
type APIError ¶ added in v0.1.1
APIError extends error by information if the error details should be returned to the end user
type Address ¶
type Address struct { Paging AddrStr string `json:"address"` BalanceSat *Amount `json:"balance"` TotalReceivedSat *Amount `json:"totalReceived,omitempty"` TotalSentSat *Amount `json:"totalSent,omitempty"` UnconfirmedBalanceSat *Amount `json:"unconfirmedBalance"` UnconfirmedTxs int `json:"unconfirmedTxs"` Txs int `json:"txs"` NonTokenTxs int `json:"nontokenTxs,omitempty"` Transactions []*Tx `json:"transactions,omitempty"` Txids []string `json:"txids,omitempty"` Nonce string `json:"nonce,omitempty"` Tokens []Token `json:"tokens,omitempty"` Erc20Contract *bchain.Erc20Contract `json:"erc20contract,omitempty"` Filter string `json:"-"` }
Address holds information about address and its transactions
type AddressFilter ¶ added in v0.2.0
AddressFilter is used to filter data returned from GetAddress api method
type AddressUtxo ¶ added in v0.1.1
type AddressUtxo struct { Txid string `json:"txid"` Vout int32 `json:"vout"` AmountSat *Amount `json:"value"` Height int `json:"height,omitempty"` Confirmations int `json:"confirmations"` }
AddressUtxo holds information about address and its transactions
type AddressUtxoV1 ¶ added in v0.2.0
type AddressUtxoV1 struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` Amount string `json:"amount"` AmountSat big.Int `json:"satoshis"` Height int `json:"height,omitempty"` Confirmations int `json:"confirmations"` }
AddressUtxoV1 is used for legacy api v1
type AddressV1 ¶ added in v0.2.0
type AddressV1 struct { Paging AddrStr string `json:"addrStr"` Balance string `json:"balance"` TotalReceived string `json:"totalReceived"` TotalSent string `json:"totalSent"` UnconfirmedBalance string `json:"unconfirmedBalance"` UnconfirmedTxApperances int `json:"unconfirmedTxApperances"` TxApperances int `json:"txApperances"` Transactions []*TxV1 `json:"txs,omitempty"` Txids []string `json:"transactions,omitempty"` }
AddressV1 is used for legacy api v1
type Amount ¶ added in v0.2.0
Amount is datatype holding amounts
func (*Amount) AsBigInt ¶ added in v0.2.0
AsBigInt returns big.Int type for the Amount (empty if Amount is nil)
func (*Amount) AsInt64 ¶ added in v0.2.0
AsInt64 returns Amount as int64 (0 if Amount is nil). It is used only for legacy interfaces (socket.io) and generally not recommended to use for possible loss of precision.
func (*Amount) DecimalString ¶ added in v0.2.0
DecimalString returns amount with decimal point placed according to parameter d
func (*Amount) MarshalJSON ¶ added in v0.2.0
MarshalJSON Amount serialization
type Block ¶ added in v0.1.0
type Block struct { Paging bchain.BlockInfo TxCount int `json:"TxCount"` Transactions []*Tx `json:"txs,omitempty"` }
Block contains information about block
type BlockV1 ¶ added in v0.2.0
type BlockV1 struct { Paging bchain.BlockInfo TxCount int `json:"TxCount"` Transactions []*TxV1 `json:"txs,omitempty"` }
BlockV1 contains information about block
type BlockbookInfo ¶ added in v0.1.0
type BlockbookInfo struct { Coin string `json:"coin"` Host string `json:"host"` Version string `json:"version"` GitCommit string `json:"gitcommit"` BuildTime string `json:"buildtime"` SyncMode bool `json:"syncMode"` InitialSync bool `json:"initialsync"` InSync bool `json:"inSync"` BestHeight uint32 `json:"bestHeight"` LastBlockTime time.Time `json:"lastBlockTime"` InSyncMempool bool `json:"inSyncMempool"` LastMempoolTime time.Time `json:"lastMempoolTime"` MempoolSize int `json:"mempoolSize"` Decimals int `json:"decimals"` DbSize int64 `json:"dbSize"` DbSizeFromColumns int64 `json:"dbSizeFromColumns,omitempty"` DbColumns []common.InternalStateColumn `json:"dbColumns,omitempty"` About string `json:"about"` }
BlockbookInfo contains information about the running blockbook instance
type EthereumSpecific ¶ added in v0.2.0
type EthereumSpecific struct { Status int `json:"status"` // 1 OK, 0 Fail, -1 pending Nonce uint64 `json:"nonce"` GasLimit *big.Int `json:"gaslimit"` GasUsed *big.Int `json:"gasused"` GasPrice *Amount `json:"gasprice"` }
EthereumSpecific contains ethereum specific transaction data
type GetAddressOption ¶ added in v0.2.0
type GetAddressOption int
GetAddressOption specifies what data returns GetAddress api call
const ( // Basic - only that address is indexed and some basic info Basic GetAddressOption = iota // Balance - only balances Balance // TxidHistory - balances and txids, subject to paging TxidHistory // TxHistoryLight - balances and easily obtained tx data (not requiring request to backend), subject to paging TxHistoryLight // TxHistory - balances and full tx data, subject to paging TxHistory )
type Paging ¶ added in v0.1.0
type Paging struct { Page int `json:"page,omitempty"` TotalPages int `json:"totalPages,omitempty"` ItemsOnPage int `json:"itemsOnPage,omitempty"` }
Paging contains information about paging for address, blocks and block
type ScriptPubKeyV1 ¶ added in v0.2.0
type ScriptPubKeyV1 struct { Hex string `json:"hex,omitempty"` Asm string `json:"asm,omitempty"` AddrDesc bchain.AddressDescriptor `json:"-"` Addresses []string `json:"addresses"` Searchable bool `json:"-"` Type string `json:"type,omitempty"` }
ScriptPubKeyV1 is used for legacy api v1
type ScriptSigV1 ¶ added in v0.2.0
ScriptSigV1 is used for legacy api v1
type SystemInfo ¶ added in v0.1.0
type SystemInfo struct { Blockbook *BlockbookInfo `json:"blockbook"` Backend *bchain.ChainInfo `json:"backend"` }
SystemInfo contains information about the running blockbook and backend instance
type Token ¶ added in v0.2.0
type Token struct { Type TokenType `json:"type"` Contract string `json:"contract"` Transfers int `json:"transfers"` Name string `json:"name"` Symbol string `json:"symbol"` Decimals int `json:"decimals"` BalanceSat *Amount `json:"balance,omitempty"` ContractIndex string `json:"-"` }
Token contains info about tokens held by an address
type TokenTransfer ¶ added in v0.2.0
type TokenTransfer struct { Type TokenType `json:"type"` From string `json:"from"` To string `json:"to"` Token string `json:"token"` Name string `json:"name"` Symbol string `json:"symbol"` Decimals int `json:"decimals"` Value *Amount `json:"value"` }
TokenTransfer contains info about a token transfer done in a transaction
type TokenType ¶ added in v0.2.0
type TokenType string
TokenType specifies type of token
const ERC20TokenType TokenType = "ERC20"
ERC20TokenType is Ethereum ERC20 token
type Tx ¶
type Tx struct { Txid string `json:"txid"` Version int32 `json:"version,omitempty"` Locktime uint32 `json:"locktime,omitempty"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` Blockhash string `json:"blockhash,omitempty"` Blockheight int `json:"blockheight"` Confirmations uint32 `json:"confirmations"` Blocktime int64 `json:"blocktime"` Size int `json:"size,omitempty"` ValueOutSat *Amount `json:"value"` ValueInSat *Amount `json:"valueIn,omitempty"` FeesSat *Amount `json:"fees,omitempty"` Hex string `json:"hex,omitempty"` CoinSpecificData interface{} `json:"-"` CoinSpecificJSON json.RawMessage `json:"-"` TokenTransfers []TokenTransfer `json:"tokentransfers,omitempty"` EthereumSpecific *EthereumSpecific `json:"ethereumspecific,omitempty"` }
Tx holds information about a transaction
type TxV1 ¶ added in v0.2.0
type TxV1 struct { Txid string `json:"txid"` Version int32 `json:"version,omitempty"` Locktime uint32 `json:"locktime,omitempty"` Vin []VinV1 `json:"vin"` Vout []VoutV1 `json:"vout"` Blockhash string `json:"blockhash,omitempty"` Blockheight int `json:"blockheight"` Confirmations uint32 `json:"confirmations"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime"` ValueOut string `json:"valueOut"` ValueOutSat big.Int `json:"-"` Size int `json:"size,omitempty"` ValueIn string `json:"valueIn"` ValueInSat big.Int `json:"-"` Fees string `json:"fees"` FeesSat big.Int `json:"-"` Hex string `json:"hex"` }
TxV1 is used for legacy api v1
type Vin ¶
type Vin struct { Txid string `json:"txid,omitempty"` Vout uint32 `json:"vout,omitempty"` Sequence int64 `json:"sequence,omitempty"` N int `json:"n"` AddrDesc bchain.AddressDescriptor `json:"-"` Addresses []string `json:"addresses,omitempty"` Searchable bool `json:"-"` ValueSat *Amount `json:"value,omitempty"` Hex string `json:"hex,omitempty"` Asm string `json:"asm,omitempty"` Coinbase string `json:"coinbase,omitempty"` }
Vin contains information about single transaction input
type VinV1 ¶ added in v0.2.0
type VinV1 struct { Txid string `json:"txid"` Vout uint32 `json:"vout"` Sequence int64 `json:"sequence,omitempty"` N int `json:"n"` ScriptSig ScriptSigV1 `json:"scriptSig"` AddrDesc bchain.AddressDescriptor `json:"-"` Addresses []string `json:"addresses"` Searchable bool `json:"-"` Value string `json:"value"` ValueSat big.Int `json:"-"` }
VinV1 is used for legacy api v1
type Vout ¶
type Vout struct { ValueSat *Amount `json:"value,omitempty"` N int `json:"n"` Spent bool `json:"spent,omitempty"` SpentTxID string `json:"spentTxId,omitempty"` SpentIndex int `json:"spentIndex,omitempty"` SpentHeight int `json:"spentHeight,omitempty"` Hex string `json:"hex,omitempty"` Asm string `json:"asm,omitempty"` AddrDesc bchain.AddressDescriptor `json:"-"` Addresses []string `json:"addresses"` Searchable bool `json:"-"` Type string `json:"type,omitempty"` }
Vout contains information about single transaction output
type VoutV1 ¶ added in v0.2.0
type VoutV1 struct { Value string `json:"value"` ValueSat big.Int `json:"-"` N int `json:"n"` ScriptPubKey ScriptPubKeyV1 `json:"scriptPubKey"` Spent bool `json:"spent"` SpentTxID string `json:"spentTxId,omitempty"` SpentIndex int `json:"spentIndex,omitempty"` SpentHeight int `json:"spentHeight,omitempty"` }
VoutV1 is used for legacy api v1
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is handle to api worker
func NewWorker ¶
func NewWorker(db *db.RocksDB, chain bchain.BlockChain, txCache *db.TxCache, is *common.InternalState) (*Worker, error)
NewWorker creates new api worker
func (*Worker) AddressToV1 ¶ added in v0.2.0
AddressToV1 converts Address to AddressV1
func (*Worker) AddressUtxoToV1 ¶ added in v0.2.0
func (w *Worker) AddressUtxoToV1(au []AddressUtxo) []AddressUtxoV1
AddressUtxoToV1 converts []AddressUtxo to []AddressUtxoV1
func (*Worker) GetAddress ¶
func (w *Worker) GetAddress(address string, page int, txsOnPage int, option GetAddressOption, filter *AddressFilter) (*Address, error)
GetAddress computes address value and gets transactions for given address
func (*Worker) GetAddressUtxo ¶ added in v0.1.1
func (w *Worker) GetAddressUtxo(address string, onlyConfirmed bool) ([]AddressUtxo, error)
GetAddressUtxo returns unspent outputs for given address
func (*Worker) GetSpendingTxid ¶ added in v0.1.0
GetSpendingTxid returns transaction id of transaction that spent given output
func (*Worker) GetSystemInfo ¶ added in v0.1.0
func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error)
GetSystemInfo returns information about system
func (*Worker) GetTransaction ¶
GetTransaction reads transaction data from txid