Documentation ¶
Index ¶
- Variables
- func GetChainParams(chain string) *chaincfg.Params
- func NewBitcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)
- type BitcoinParser
- func (p *BitcoinParser) AddressToOutputScript(address string) ([]byte, error)
- func (p *BitcoinParser) GetAddrIDFromAddress(address string) ([]byte, error)
- func (p *BitcoinParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error)
- func (p *BitcoinParser) OutputScriptToAddresses(script []byte) ([]string, error)
- func (p *BitcoinParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error)
- func (p *BitcoinParser) ParseBlock(b []byte) (*bchain.Block, error)
- func (p *BitcoinParser) ParseTx(b []byte) (*bchain.Tx, error)
- func (p *BitcoinParser) TxFromMsgTx(t *wire.MsgTx, parseAddresses bool) bchain.Tx
- func (p *BitcoinParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error)
- type BitcoinRPC
- func (b *BitcoinRPC) Call(req interface{}, res interface{}) error
- func (b *BitcoinRPC) EstimateFee(blocks int) (float64, error)
- func (b *BitcoinRPC) EstimateSmartFee(blocks int, conservative bool) (float64, error)
- func (b *BitcoinRPC) GetBestBlockHash() (string, error)
- func (b *BitcoinRPC) GetBestBlockHeight() (uint32, error)
- func (b *BitcoinRPC) GetBlock(hash string, height uint32) (*bchain.Block, error)
- func (b *BitcoinRPC) GetBlockChainInfo() (string, error)
- func (b *BitcoinRPC) GetBlockFull(hash string) (*bchain.Block, error)
- func (b *BitcoinRPC) GetBlockHash(height uint32) (string, error)
- func (b *BitcoinRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error)
- func (b *BitcoinRPC) GetBlockRaw(hash string) ([]byte, error)
- func (b *BitcoinRPC) GetBlockWithoutHeader(hash string, height uint32) (*bchain.Block, error)
- func (b *BitcoinRPC) GetChainInfoAndInitializeMempool(bc bchain.BlockChain) (string, error)
- func (b *BitcoinRPC) GetChainParser() bchain.BlockChainParser
- func (b *BitcoinRPC) GetCoinName() string
- func (b *BitcoinRPC) GetMempool() ([]string, error)
- func (b *BitcoinRPC) GetMempoolEntry(txid string) (*bchain.MempoolEntry, error)
- func (b *BitcoinRPC) GetMempoolTransactions(address string) ([]string, error)
- func (b *BitcoinRPC) GetNetworkName() string
- func (b *BitcoinRPC) GetSubversion() string
- func (b *BitcoinRPC) GetTransaction(txid string) (*bchain.Tx, error)
- func (b *BitcoinRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error)
- func (b *BitcoinRPC) Initialize() error
- func (b *BitcoinRPC) IsTestnet() bool
- func (b *BitcoinRPC) ResyncMempool(onNewTxAddr bchain.OnNewTxAddrFunc) (int, error)
- func (b *BitcoinRPC) SendRawTransaction(tx string) (string, error)
- func (b *BitcoinRPC) Shutdown(ctx context.Context) error
- type CmdEstimateFee
- type CmdEstimateSmartFee
- type CmdGetBestBlockHash
- type CmdGetBlock
- type CmdGetBlockChainInfo
- type CmdGetBlockCount
- type CmdGetBlockHash
- type CmdGetBlockHeader
- type CmdGetMempool
- type CmdGetMempoolEntry
- type CmdGetRawTransaction
- type CmdSendRawTransaction
- type Configuration
- type JSONMarshalerV1
- type JSONMarshalerV2
- type OutputScriptToAddressesFunc
- type RPCMarshaler
- type ResEstimateFee
- type ResEstimateSmartFee
- type ResGetBestBlockHash
- type ResGetBlockChainInfo
- type ResGetBlockCount
- type ResGetBlockFull
- type ResGetBlockHash
- type ResGetBlockHeader
- type ResGetBlockRaw
- type ResGetBlockThin
- type ResGetMempool
- type ResGetMempoolEntry
- type ResGetRawTransaction
- type ResGetRawTransactionNonverbose
- type ResSendRawTransaction
Constants ¶
This section is empty.
Variables ¶
var InvalidValue = errors.New("Invalid value to marshal")
Functions ¶
func GetChainParams ¶
GetChainParams contains network parameters for the main Bitcoin network, the regression test Bitcoin network, the test Bitcoin network and the simulation test Bitcoin network, in this order
func NewBitcoinRPC ¶
func NewBitcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)
NewBitcoinRPC returns new BitcoinRPC instance.
Types ¶
type BitcoinParser ¶
type BitcoinParser struct { *bchain.BaseParser Params *chaincfg.Params OutputScriptToAddressesFunc OutputScriptToAddressesFunc }
BitcoinParser handle
func NewBitcoinParser ¶
func NewBitcoinParser(params *chaincfg.Params, c *Configuration) *BitcoinParser
NewBitcoinParser returns new BitcoinParser instance
func (*BitcoinParser) AddressToOutputScript ¶
func (p *BitcoinParser) AddressToOutputScript(address string) ([]byte, error)
AddressToOutputScript converts bitcoin address to ScriptPubKey
func (*BitcoinParser) GetAddrIDFromAddress ¶
func (p *BitcoinParser) GetAddrIDFromAddress(address string) ([]byte, error)
GetAddrIDFromAddress returns internal address representation of given address
func (*BitcoinParser) GetAddrIDFromVout ¶
func (p *BitcoinParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error)
GetAddrIDFromVout returns internal address representation of given transaction output
func (*BitcoinParser) OutputScriptToAddresses ¶
func (p *BitcoinParser) OutputScriptToAddresses(script []byte) ([]string, error)
OutputScriptToAddresses converts ScriptPubKey to bitcoin addresses
func (*BitcoinParser) ParseBlock ¶
func (p *BitcoinParser) ParseBlock(b []byte) (*bchain.Block, error)
ParseBlock parses raw block to our Block struct
func (*BitcoinParser) ParseTx ¶
func (p *BitcoinParser) ParseTx(b []byte) (*bchain.Tx, error)
ParseTx parses byte array containing transaction and returns Tx struct
func (*BitcoinParser) TxFromMsgTx ¶
type BitcoinRPC ¶
type BitcoinRPC struct { Parser bchain.BlockChainParser Testnet bool Network string Mempool *bchain.UTXOMempool ParseBlocks bool ChainConfig *Configuration RPCMarshaler RPCMarshaler // contains filtered or unexported fields }
BitcoinRPC is an interface to JSON-RPC bitcoind service.
func (*BitcoinRPC) Call ¶
func (b *BitcoinRPC) Call(req interface{}, res interface{}) error
func (*BitcoinRPC) EstimateFee ¶
func (b *BitcoinRPC) EstimateFee(blocks int) (float64, error)
EstimateFee returns fee estimation.
func (*BitcoinRPC) EstimateSmartFee ¶
func (b *BitcoinRPC) EstimateSmartFee(blocks int, conservative bool) (float64, error)
EstimateSmartFee returns fee estimation.
func (*BitcoinRPC) GetBestBlockHash ¶
func (b *BitcoinRPC) GetBestBlockHash() (string, error)
GetBestBlockHash returns hash of the tip of the best-block-chain.
func (*BitcoinRPC) GetBestBlockHeight ¶
func (b *BitcoinRPC) GetBestBlockHeight() (uint32, error)
GetBestBlockHeight returns height of the tip of the best-block-chain.
func (*BitcoinRPC) GetBlockChainInfo ¶
func (b *BitcoinRPC) GetBlockChainInfo() (string, error)
GetBlockChainInfo returns the name of the block chain: main/test/regtest.
func (*BitcoinRPC) GetBlockFull ¶
func (b *BitcoinRPC) GetBlockFull(hash string) (*bchain.Block, error)
GetBlockFull returns block with given hash.
func (*BitcoinRPC) GetBlockHash ¶
func (b *BitcoinRPC) GetBlockHash(height uint32) (string, error)
GetBlockHash returns hash of block in best-block-chain at given height.
func (*BitcoinRPC) GetBlockHeader ¶
func (b *BitcoinRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error)
GetBlockHeader returns header of block with given hash.
func (*BitcoinRPC) GetBlockRaw ¶
func (b *BitcoinRPC) GetBlockRaw(hash string) ([]byte, error)
GetBlockRaw returns block with given hash as bytes.
func (*BitcoinRPC) GetBlockWithoutHeader ¶
getBlockWithoutHeader is an optimization - it does not call GetBlockHeader to get prev, next hashes instead it sets to header only block hash and height passed in parameters
func (*BitcoinRPC) GetChainInfoAndInitializeMempool ¶
func (b *BitcoinRPC) GetChainInfoAndInitializeMempool(bc bchain.BlockChain) (string, error)
GetChainInfoAndInitializeMempool is called by Initialize and reused by other coins it contacts the blockchain rpc interface for the first time and if successful it connects to ZeroMQ and creates mempool handler
func (*BitcoinRPC) GetChainParser ¶
func (b *BitcoinRPC) GetChainParser() bchain.BlockChainParser
GetChainParser returns BlockChainParser
func (*BitcoinRPC) GetCoinName ¶
func (b *BitcoinRPC) GetCoinName() string
func (*BitcoinRPC) GetMempool ¶
func (b *BitcoinRPC) GetMempool() ([]string, error)
GetMempool returns transactions in mempool.
func (*BitcoinRPC) GetMempoolEntry ¶
func (b *BitcoinRPC) GetMempoolEntry(txid string) (*bchain.MempoolEntry, error)
GetMempoolEntry returns mempool data for given transaction
func (*BitcoinRPC) GetMempoolTransactions ¶
func (b *BitcoinRPC) GetMempoolTransactions(address string) ([]string, error)
GetMempoolTransactions returns slice of mempool transactions for given address.
func (*BitcoinRPC) GetNetworkName ¶
func (b *BitcoinRPC) GetNetworkName() string
func (*BitcoinRPC) GetSubversion ¶
func (b *BitcoinRPC) GetSubversion() string
func (*BitcoinRPC) GetTransaction ¶
func (b *BitcoinRPC) GetTransaction(txid string) (*bchain.Tx, error)
GetTransaction returns a transaction by the transaction ID.
func (*BitcoinRPC) GetTransactionForMempool ¶
func (b *BitcoinRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error)
GetTransactionForMempool returns a transaction by the transaction ID. It could be optimized for mempool, i.e. without block time and confirmations
func (*BitcoinRPC) Initialize ¶
func (b *BitcoinRPC) Initialize() error
Initialize initializes BitcoinRPC instance.
func (*BitcoinRPC) IsTestnet ¶
func (b *BitcoinRPC) IsTestnet() bool
func (*BitcoinRPC) ResyncMempool ¶
func (b *BitcoinRPC) ResyncMempool(onNewTxAddr bchain.OnNewTxAddrFunc) (int, error)
ResyncMempool gets mempool transactions and maps output scripts to transactions. ResyncMempool is not reentrant, it should be called from a single thread. It returns number of transactions in mempool
func (*BitcoinRPC) SendRawTransaction ¶
func (b *BitcoinRPC) SendRawTransaction(tx string) (string, error)
SendRawTransaction sends raw transaction.
type CmdEstimateFee ¶
type CmdEstimateSmartFee ¶
type CmdGetBestBlockHash ¶
type CmdGetBestBlockHash struct {
Method string `json:"method"`
}
type CmdGetBlock ¶
type CmdGetBlockChainInfo ¶
type CmdGetBlockChainInfo struct {
Method string `json:"method"`
}
type CmdGetBlockCount ¶
type CmdGetBlockCount struct {
Method string `json:"method"`
}
type CmdGetBlockHash ¶
type CmdGetBlockHeader ¶
type CmdGetMempool ¶
type CmdGetMempool struct {
Method string `json:"method"`
}
type CmdGetMempoolEntry ¶
type CmdGetRawTransaction ¶
type CmdSendRawTransaction ¶
type Configuration ¶
type Configuration struct { CoinName string `json:"coin_name"` CoinShortcut string `json:"coin_shortcut"` RPCURL string `json:"rpc_url"` RPCUser string `json:"rpc_user"` RPCPass string `json:"rpc_pass"` RPCTimeout int `json:"rpc_timeout"` Parse bool `json:"parse"` MessageQueueBinding string `json:"message_queue_binding"` Subversion string `json:"subversion"` BlockAddressesToKeep int `json:"block_addresses_to_keep"` MempoolWorkers int `json:"mempool_workers"` MempoolSubWorkers int `json:"mempool_sub_workers"` AddressFormat string `json:"address_format"` }
type JSONMarshalerV1 ¶
type JSONMarshalerV1 struct{}
func (JSONMarshalerV1) Marshal ¶
func (JSONMarshalerV1) Marshal(v interface{}) ([]byte, error)
type JSONMarshalerV2 ¶
type JSONMarshalerV2 struct{}
func (JSONMarshalerV2) Marshal ¶
func (JSONMarshalerV2) Marshal(v interface{}) ([]byte, error)
type OutputScriptToAddressesFunc ¶
OutputScriptToAddressesFunc converts ScriptPubKey to bitcoin addresses
type RPCMarshaler ¶
type ResEstimateFee ¶
type ResEstimateSmartFee ¶
type ResGetBestBlockHash ¶
type ResGetBlockChainInfo ¶
type ResGetBlockCount ¶
type ResGetBlockFull ¶
type ResGetBlockHash ¶
type ResGetBlockHeader ¶
type ResGetBlockHeader struct { Error *bchain.RPCError `json:"error"` Result bchain.BlockHeader `json:"result"` }
type ResGetBlockRaw ¶
type ResGetBlockThin ¶
type ResGetMempool ¶
type ResGetMempoolEntry ¶
type ResGetMempoolEntry struct { Error *bchain.RPCError `json:"error"` Result *bchain.MempoolEntry `json:"result"` }
type ResGetRawTransaction ¶
type ResGetRawTransaction struct { Error *bchain.RPCError `json:"error"` Result json.RawMessage `json:"result"` }