bitcoin

package
v0.0.0-...-9588916 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpcodeMap = make(map[uint8]string)

These constants are the values of the official opcodes used on the btc wiki, in bitcoin core and in most if not all other references and software related to handling BTC scripts.

Functions

func GetFollowLenWhenDataOp

func GetFollowLenWhenDataOp(op uint8) int

Types

type BitcoinBlock

type BitcoinBlock struct {
	BlockHash string              `json:"blockHash"`
	Header    *BitcoinBolckHeader `json:"header"`

	TxCount uint64       `json:"txCount"`
	Txs     []*BitcoinTx `json:"txs"`
	// contains filtered or unexported fields
}

func NewBitcoinBlock

func NewBitcoinBlock() *BitcoinBlock

func (*BitcoinBlock) ParseHeader

func (b *BitcoinBlock) ParseHeader(headerHex []byte) error

func (*BitcoinBlock) ParseTxs

func (b *BitcoinBlock) ParseTxs(txsHex []byte) error

func (*BitcoinBlock) String

func (b *BitcoinBlock) String() string

type BitcoinBolckHeader

type BitcoinBolckHeader struct {
	Version        uint32 `json:"version"`
	PreBlockHash   string `json:"preBlockHash"`
	MerkleRootHash string `json:"merkleRootHash"`
	Time           uint32 `json:"time"`
	NBits          uint32 `json:"nBits"`
	Nonce          uint32 `json:"nonce"`
}

head struct

func (*BitcoinBolckHeader) String

func (h *BitcoinBolckHeader) String() string

type BitcoinProcessor

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

func NewBitcoinProcessor

func NewBitcoinProcessor(config *models.EsBlockChain) *BitcoinProcessor

func (*BitcoinProcessor) BestHeight

func (b *BitcoinProcessor) BestHeight() (int, error)

func (*BitcoinProcessor) GetBlockHashes

func (b *BitcoinProcessor) GetBlockHashes(start int, count int) ([]string, error)

func (*BitcoinProcessor) SyncBlock

func (b *BitcoinProcessor) SyncBlock(syncHeight int, count int) error

type BitcoinTestNet

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

func (*BitcoinTestNet) BroadcastTransactions

func (b *BitcoinTestNet) BroadcastTransactions(rawTx *models.EsTransaction) error

func (*BitcoinTestNet) GetBlockHashes

func (b *BitcoinTestNet) GetBlockHashes(start int, count int) ([]string, error)

func (*BitcoinTestNet) GetBlocks

func (b *BitcoinTestNet) GetBlocks(blockHashes []string) ([]*BitcoinBlock, error)

func (*BitcoinTestNet) GetTransactions

func (b *BitcoinTestNet) GetTransactions(txHashes []string) (*models.EsTransaction, error)

func (*BitcoinTestNet) Height

func (b *BitcoinTestNet) Height() (int, error)

type BitcoinTx

type BitcoinTx struct {
	TxHash     string            `json:"txHash"` //doubleHash(Version+TxInCount+TxIns+TxOutCount+TxOuts+LockTime) when segwit should exclude marker flag and witness
	Version    uint32            `json:"version"`
	Marker     uint8             `json:"marker"`    // when the byte follow version is 0, the block is SegWitBlk
	Flag       uint8             `json:"flag"`      // flag must non 0, and must be 1 in SegWit
	TxInCount  uint64            `json:"txInCount"` // TxIn follow
	TxIns      []*BitcoinTxIn    `json:"txIns"`
	TxOutCount uint64            `json:"txOutCount"` // TxOut follow
	TxOuts     []*BitcoinTxOut   `json:"txOuts"`
	Witness    []*BitcoinWitness `json:"witness"` // the len equals to TxInCount
	LockTime   uint32            `json:"lockTime"`
}

transaction struct coinbase transaction only has one input support SegWit BIP141

func (*BitcoinTx) String

func (t *BitcoinTx) String() string

type BitcoinTxIn

type BitcoinTxIn struct {
	UnspentHash     string `json:"unspentHash"`     //the TXID of outpoint in TxIn
	UnspentIndex    uint32 `json:"unspentIndex"`    //the output index number of outpoint in TxIn
	ScriptSize      uint64 `json:"scriptSize"`      //signature script's size in TxIn
	SignatureScript string `json:"signatureScript"` // signatureScript in TxIn
	Sequence        uint32 `json:"sequence"`        // sequence in TxIn
}

TxIn

func (*BitcoinTxIn) String

func (t *BitcoinTxIn) String() string

type BitcoinTxOut

type BitcoinTxOut struct {
	Value        uint64 `json:"value"`        // Number of satoshis to spend in TxOut
	PkScriptSize uint64 `json:"pkScriptSize"` // pkScriptSize in TxOut
	PkScript     string `json:"pkScript"`     // Defines the conditions which must be satisfied to spend this output in TxOut
}

TxOut

func (*BitcoinTxOut) String

func (t *BitcoinTxOut) String() string

type BitcoinWitness

type BitcoinWitness struct {
	Size uint64   `json:"size"`
	Wits []string `json:"wits"` //one TxIn correspond to seravel Witness
}

witness in BIP141

func (*BitcoinWitness) String

func (w *BitcoinWitness) String() string

Jump to

Keyboard shortcuts

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