blkparser

package
v0.0.0-...-4969170 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeVariableLengthInteger

func DecodeVariableLengthInteger(raw []byte) (cnt int, cnt_size int)

Get the Tx count, decode the variable length integer https://en.bitcoin.it/wiki/Protocol_specification#Variable_length_integer

func GetShaString

func GetShaString(data []byte) (res string)

func HashString

func HashString(data []byte) (res string)

Types

type Block

type Block struct {
	Raw         []byte  `json:"-"`
	Hash        string  `json:"hash"`
	Height      uint    `json:"height"`
	Txs         []*Tx   `json:"tx,omitempty"`
	Version     uint32  `json:"ver"`
	MerkleRoot  string  `json:"mrkl_root"`
	BlockTime   uint32  `json:"time"`
	Bits        uint32  `json:"bits"`
	Nonce       uint32  `json:"nonce"`
	Size        uint32  `json:"size"`
	TxCnt       uint32  `json:"n_tx"`
	TotalBTC    uint64  `json:"total_out"`
	BlockReward float64 `json:"-"`
	Parent      string  `json:"prev_block"`
	Next        string  `json:"next_block"`
}

func NewBlock

func NewBlock(rawblock []byte) (block *Block, err error)

type Blockchain

type Blockchain struct {
	Path        string
	Magic       [4]byte
	CurrentFile *os.File
	CurrentId   uint32
}

func NewBlockchain

func NewBlockchain(path string, magic [4]byte) (blockchain *Blockchain, err error)

func (*Blockchain) FetchNextBlock

func (blockchain *Blockchain) FetchNextBlock() (rawblock []byte, err error)

func (*Blockchain) NextBlock

func (blockchain *Blockchain) NextBlock() (block *Block, err error)

func (*Blockchain) SkipBlock

func (blockchain *Blockchain) SkipBlock() (err error)

func (*Blockchain) SkipTo

func (blockchain *Blockchain) SkipTo(blkId uint32, offset int64) (err error)

Convenience method to skip directly to the given blkfile / offset, you must take care of the height

type Tx

type Tx struct {
	Hash     string
	Size     uint32
	LockTime uint32
	Version  uint32
	TxInCnt  uint32
	TxOutCnt uint32
	TxIns    []*TxIn
	TxOuts   []*TxOut
}

func NewTx

func NewTx(rawtx []byte) (tx *Tx, offset int)

func ParseTxs

func ParseTxs(txsraw []byte) (txs []*Tx, err error)

type TxIn

type TxIn struct {
	InputHash string
	InputVout uint32
	ScriptSig []byte
	Sequence  uint32
}

func NewTxIn

func NewTxIn(txinraw []byte) (txin *TxIn, offset int)

type TxOut

type TxOut struct {
	Addr     string
	Value    uint64
	Pkscript []byte
}

func NewTxOut

func NewTxOut(txoutraw []byte) (txout *TxOut, offset int)

Jump to

Keyboard shortcuts

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