Documentation ¶
Index ¶
Constants ¶
const ( // BlockValidHeader - Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future BlockValidHeader = 1 // BlockValidTree - All parent headers found, difficulty matches, timestamp >= median previous, checkpoint. Implies all parents are also at least TREE. BlockValidTree = 2 // BlockValidTransactions - Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid, no duplicate txids, sigops, size, merkle root. Implies all parents are at least TREE but not necessarily TRANSACTIONS. When all parent blocks also have TRANSACTIONS. BlockValidTransactions = 3 // BlockValidChain - Outputs do not overspend inputs, no double spends, coinbase output ok, immature coinbase spends, BIP30. Implies all parents are also at least CHAIN. BlockValidChain = 4 // BlockValidScripts - Scripts & signatures ok. Implies all parents are also at least SCRIPTS. BlockValidScripts = 5 // BlockValidMask - All validity bits. BlockValidMask = BlockValidHeader | BlockValidTree | BlockValidTransactions | BlockValidChain | BlockValidScripts // BlockHaveData - full block available in blk*.dat BlockHaveData = 8 // BlockHaveUndo - undo data available in rev*.dat BlockHaveUndo = 16 // BlockHaveMask - Block and Undo data avaliable BlockHaveMask = BlockHaveData | BlockHaveUndo // BlockFailedValid - stage after last reached validness failed BlockFailedValid = 32 // BlockFailedChild - descends from failed block BlockFailedChild = 64 // BlockFailedMask - Mask for failed block. BlockFailedMask = BlockFailedValid | BlockFailedChild )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitcoinDAT ¶
type BitcoinDAT struct {
// contains filtered or unexported fields
}
BitcoinDAT is a parser that can read blocks from Bitcoin Core's blk????.dat files.
func NewBitcoinDAT ¶
func NewBitcoinDAT(datPath string) (*BitcoinDAT, error)
NewBitcoinDAT is the factory function to instantiate a new BitcoinDAT
func (*BitcoinDAT) GetBlockIndices ¶
func (p *BitcoinDAT) GetBlockIndices() (BlockIndices, error)
GetBlockIndices reads all indexed blocks from the leveldb database and returns these unordered.
func (*BitcoinDAT) ReadBlockData ¶
func (d *BitcoinDAT) ReadBlockData(ib BlockIndex) ([]byte, error)
ReadBlockData reads the data for the passed BlockIndex and returns a byte slice with the raw block data.
type BlockIndex ¶
type BlockIndex struct { Hash Hash256 // Block Hash BitcoinCoreVersion int32 // Bitcoin Core Version Height int32 // Block height Status uint32 // Block status NumTx uint32 // Number of transactions NumFile int32 // File Number PosData uint32 // Position of the block data in the file PosUndo uint32 // Position of the undo data for that block in the undo file BlockVersion int32 // Block version PreviousHash Hash256 // Previous Block Hash MerkleRootHash Hash256 // Hash of the Merkle Root Time uint32 // Block time Bits uint32 // Bits Nonce uint32 // Nonce }
BlockIndex represents an index entry in the leveldb database.
type BlockIndexChain ¶
type BlockIndexChain []BlockIndex
BlockIndexChain is a list of multiple BlockIndex which has only one block per hight
type BlockIndices ¶
type BlockIndices []BlockIndex
BlockIndices is a list of multiple BlockIndex which can contain multiple blocks at the same hight and forks
func (*BlockIndices) GetMainChain ¶
func (bi *BlockIndices) GetMainChain() BlockIndexChain
GetMainChain returns the most work chain of blocks containing no forks. BlockIndexChain is sorted by ascending block height (genesis -> tip).
type Hash256 ¶
type Hash256 [32]byte
Hash256 represents a 32bit hash. These are commonly used in Bitcoin.
func NewHash256WithReverse ¶
NewHash256WithReverse takes 32bytes, reverses them and returns a Hash256. Bitcoin hashes are internally saved in reverse.
type MovingBytes ¶
type MovingBytes struct {
// contains filtered or unexported fields
}
func NewMovingBytes ¶
func NewMovingBytes(b []byte) MovingBytes
func (*MovingBytes) PrintNext ¶
func (mb *MovingBytes) PrintNext(n uint64, tag string)
func (*MovingBytes) ReadHash ¶
func (mb *MovingBytes) ReadHash() (hash Hash256)
func (*MovingBytes) ReadInt32LitteEndian ¶
func (mb *MovingBytes) ReadInt32LitteEndian() (val int32)
func (*MovingBytes) ReadUInt32LitteEndian ¶
func (mb *MovingBytes) ReadUInt32LitteEndian() (val uint32)
func (*MovingBytes) ReadVarInt ¶
func (mb *MovingBytes) ReadVarInt() (n uint64)