btc

package
v0.0.0-...-14fb5e5 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright (c) 2020 Michael Madgett Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.

Copyright (c) 2020 Michael Madgett Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.

Copyright (c) 2020 Michael Madgett Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.

Copyright (c) 2020 Michael Madgett Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.

Copyright (c) 2020 Michael Madgett Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.

Index

Constants

This section is empty.

Variables

View Source
var MainNetParams = chaincfg.Params{
	Name:        "mainnet",
	Net:         0xd9b4bef9,
	DefaultPort: "8333",

	Bech32HRPSegwit: "bc",

	PubKeyHashAddrID:        0x00,
	ScriptHashAddrID:        0x05,
	PrivateKeyID:            0x80,
	WitnessPubKeyHashAddrID: 0x06,
	WitnessScriptHashAddrID: 0x0A,

	HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4},
	HDPublicKeyID:  [4]byte{0x04, 0x88, 0xb2, 0x1e},

	HDCoinType: 0x0,
}

MainNetParams returns the chain configuration for mainnet.

View Source
var TestnetParams = chaincfg.Params{
	Name:        "testnet",
	Net:         0x0709110b,
	DefaultPort: "18333",

	Bech32HRPSegwit: "tb",

	PubKeyHashAddrID:        0x6f,
	ScriptHashAddrID:        0xc4,
	PrivateKeyID:            0xef,
	WitnessPubKeyHashAddrID: 0x06,
	WitnessScriptHashAddrID: 0x0A,

	HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94},
	HDPublicKeyID:  [4]byte{0x04, 0x35, 0x87, 0xcf},

	HDCoinType: 0x1,
}

TestnetParams returns the chain configuration for testnet.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin(cfg *chaincfg.Params, tokenCfg data.TokenConfig) *Plugin

NewPlugin returns new BLOCK plugin instance.

func (*Plugin) AddBlocks

func (bp *Plugin) AddBlocks(blocks []byte) ([]*data.Tx, error)

AddBlocks process new blocks received by the network to keep internal chain data up to date.

func (*Plugin) AddTransactionToCache

func (bp *Plugin) AddTransactionToCache(tx *data.Tx)

AddAddrToCache adds the transaction to the cache.

func (*Plugin) BlocksDir

func (bp *Plugin) BlocksDir() string

BlocksDir returns the location of all block dat files.

func (*Plugin) Config

func (bp *Plugin) Config() chaincfg.Params

Config returns the network magic number.

func (*Plugin) GetRawMempool

func (bp *Plugin) GetRawMempool() ([]string, error)

GetRawMempool calls getrawmempool on the specified rpc endpoint.

func (*Plugin) GetRawTransaction

func (bp *Plugin) GetRawTransaction(txid string) (*wire.MsgTx, error)

GetRawTransaction calls getrawtransaction on the specified rpc endpoint.

func (*Plugin) GetRawTransactions

func (bp *Plugin) GetRawTransactions(txids []string) ([]*wire.MsgTx, error)

GetRawTransactions calls getrawtransaction on the specified rpc endpoint.

func (*Plugin) ImportTransactions

func (bp *Plugin) ImportTransactions(transactions []*wire.MsgTx) ([]*data.Tx, error)

ImportTransactions imports the specified transactions into the data store.

func (*Plugin) ListTransactions

func (bp *Plugin) ListTransactions(fromTime, toTime int64, addresses []string) ([]*data.Tx, error)

ListTransactions lists all transactions during the time period.

func (*Plugin) LoadBlocks

func (bp *Plugin) LoadBlocks(blocksDir string) error

LoadBlocks load all transactions in the blocks dir.

func (*Plugin) Mu

func (bp *Plugin) Mu() *sync.RWMutex

Mu returns the readwrite mutex.

func (*Plugin) Network

func (bp *Plugin) Network() wire.BitcoinNet

Network returns the network magic number.

func (*Plugin) ProcessBlocks

func (bp *Plugin) ProcessBlocks(sc *bufio.Reader) ([]*data.Tx, error)

ProcessBlocks will process all blocks in the buffer.

func (*Plugin) ProcessTxShard

func (bp *Plugin) ProcessTxShard(blocks []*data.ChainBlock, start, end int, wg *sync.WaitGroup) []*data.Tx

ProcessTxShard processes all transactions over specified range of blocks. Creates all send and receive transactions in the range. This func is thread safe.

func (*Plugin) ProcessTxs

func (bp *Plugin) ProcessTxs(sendTxs []*data.Tx, receiveTxs []*data.Tx) []*data.Tx

ProcessTxs processes and consolidates send and receive transactions.

func (*Plugin) ReadBlock

func (bp *Plugin) ReadBlock(buf io.ReadSeeker) (*wire.MsgBlock, error)

ReadBlock deserializes bytes into block

func (*Plugin) ReadBlockHeader

func (bp *Plugin) ReadBlockHeader(buf io.ReadSeeker) (header *wire.BlockHeader, err error)

ReadBlockHeader deserializes block header.

func (*Plugin) ReadBlocks

func (bp *Plugin) ReadBlocks(sc *bufio.Reader) ([]*data.ChainBlock, error)

ReadBlocks loads block from the reader.

func (*Plugin) ReadTransaction

func (bp *Plugin) ReadTransaction(buf io.ReadSeeker) (*wire.MsgTx, error)

ReadTransaction deserializes bytes into transaction

func (*Plugin) Ready

func (bp *Plugin) Ready() bool

Ready returns true if the block db has loaded.

func (*Plugin) SegwitActivated

func (bp *Plugin) SegwitActivated() int64

SegwitActivated returns the segwit activation unix time.

func (*Plugin) SetReady

func (bp *Plugin) SetReady()

setReady state on the plugin.

func (*Plugin) Ticker

func (bp *Plugin) Ticker() string

Ticker returns the ticker symbol (e.g. BLOCK, BTC, LTC).

func (*Plugin) TokenConf

func (bp *Plugin) TokenConf() data.TokenConfig

TokenConf returns the token configuration.

func (*Plugin) TxCache

func (bp *Plugin) TxCache() map[string]map[string]*data.Tx

TxCache returns the transaction cache

func (*Plugin) TxIndex

func (bp *Plugin) TxIndex() map[wire.OutPoint]*data.BlockTx

TxIndex returns the transaction index (lookup by outpoint).

func (*Plugin) WriteListTransactions

func (bp *Plugin) WriteListTransactions(fromMonth time.Time, toMonth time.Time, txDir string) error

WriteListTransactions writes transactions to disk at the specified location. Uses the format [txDir]/listtransactions/BLOCK/BoWcezbZ9vFTwArtVTHJHp51zQZSGdcLXt/2020-06.json

func (*Plugin) WriteListTransactionsForAddress

func (bp *Plugin) WriteListTransactionsForAddress(address string, fromMonth time.Time, toMonth time.Time, txDir string) error

WriteListTransactionsForAddress writes transactions to disk at the specified location. Uses the format [txDir]/listtransactions/BLOCK/BoWcezbZ9vFTwArtVTHJHp51zQZSGdcLXt/2020-06.json

Jump to

Keyboard shortcuts

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