model

package
v0.0.0-...-25c57ca Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressBytesLength       = 25
	Hash160BytesLength       = 20
	PublicKeyToAddressInTest = 111
	PublicKeyToAddress       = 0
	ScriptToAddressInTest    = 196
	ScriptToAddress          = 5
)
View Source
const (
	MaxTxInSequenceNum uint32 = 0xffffffff
	FreeListMaxItems          = 12500
	MaxMessagePayload         = 32 * 1024 * 1024
	MinTxInPayload            = 9 + utils.HashSize
	MaxTxInPerMessage         = (MaxMessagePayload / MinTxInPayload) + 1
)

Variables

View Source
var EmptyByte = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Functions

func AddressVerPubKey

func AddressVerPubKey(isTest bool) byte

func AddressVerScript

func AddressVerScript(isTest bool) byte

func Hash160ToAddressStr

func Hash160ToAddressStr(hash160 []byte, version byte) (str string, err error)

func ReadScript

func ReadScript(reader io.Reader, pver uint32, maxAllowed uint32, fieldName string) (signScript []byte, err error)

Types

type Address

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

func AddressFromHash160

func AddressFromHash160(hash160 []byte, version byte) (address *Address, err error)

func AddressFromPublicKey

func AddressFromPublicKey(publicKey []byte, version byte) (address *Address, err error)

func AddressFromString

func AddressFromString(addressStr string) (btcAddress *Address, err error)

type Block

type Block struct {
	Raw          []byte
	Hash         utils.Hash
	Height       int32
	Transactions []*Tx
	Version      uint32
	MerkleRoot   string
	BlockTime    time.Time
	Bits         uint32
	Nonce        uint32
	Size         uint32
	TotalBTC     uint64
	BlockReward  float64
	PrevBlock    string
	NextBlock    string
}

func ParseBlock

func ParseBlock(raw []byte) (block *Block, err error)

type BlockChain

type BlockChain struct {
	Path        string
	Magic       [4]byte
	CurrentFile *os.File
	CurrentID   uint32
	LastBlock   *Block
	Lock        sync.Mutex
}

func ParseBlockchain

func ParseBlockchain(path string, magic [4]byte) (blockchain *BlockChain, err error)

func (*BlockChain) BestBlockHash

func (blockChain *BlockChain) BestBlockHash() (utils.Hash, int32, error)

func (*BlockChain) FetchNextBlock

func (blockChain *BlockChain) FetchNextBlock() (raw []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)

type Checkpoint

type Checkpoint struct {
	Height int32
	Hash   *utils.Hash
}

type OutPoint

type OutPoint struct {
	Hash  *utils.Hash
	Index uint32
}

func NewOutPoint

func NewOutPoint(hash *utils.Hash, index uint32) *OutPoint

func (*OutPoint) ReadOutPoint

func (outPoint *OutPoint) ReadOutPoint(reader io.Reader, pver uint32, version int32) (err error)

func (*OutPoint) String

func (outPoint *OutPoint) String() string

func (*OutPoint) WriteOutPoint

func (outPoint *OutPoint) WriteOutPoint(writer io.Writer, pver uint32, version int32) error

type ScriptFreeList

type ScriptFreeList chan []byte

func (ScriptFreeList) Borrow

func (scriptFreeList ScriptFreeList) Borrow(size uint64) []byte

func (ScriptFreeList) Return

func (scriptFreeList ScriptFreeList) Return(buf []byte)

type Tx

type Tx struct {
	Hash utils.Hash

	LockTime uint32
	Version  int32
	Ins      []*TxIn
	Outs     []*TxOut
}

func (*Tx) AddTxIn

func (tx *Tx) AddTxIn(txIn *TxIn)

func (*Tx) AddTxOut

func (tx *Tx) AddTxOut(txOut *TxOut)

func (*Tx) Deserialize

func (tx *Tx) Deserialize(reader io.Reader, pver uint32) (err error)

func (*Tx) Serialize

func (tx *Tx) Serialize(writer io.Writer, pver uint32) error

func (*Tx) SerializeSize

func (tx *Tx) SerializeSize() int

type TxIn

type TxIn struct {
	PreviousOutPoint *OutPoint
	ScriptSig        []byte
	Sequence         uint32 //todo ?
}

func NewTxIn

func NewTxIn(prevOut *OutPoint, pkScript []byte) *TxIn

func (*TxIn) ReadTxIn

func (txIn *TxIn) ReadTxIn(reader io.Reader, pver uint32, version int32) error

func (*TxIn) SerializeSize

func (txIn *TxIn) SerializeSize() int

func (*TxIn) WriteTxIn

func (txIn *TxIn) WriteTxIn(writer io.Writer, pver uint32, version int32) error

type TxOut

type TxOut struct {
	Address   string
	Value     int64
	OutScript []byte
}

func NewTxOut

func NewTxOut(value int64, pkScript []byte) *TxOut

func (*TxOut) ReadTxOut

func (txOut *TxOut) ReadTxOut(reader io.Reader, pver uint32, version int32) error

func (*TxOut) SerializeSize

func (txOut *TxOut) SerializeSize() int

func (*TxOut) WriteTxOut

func (txOut *TxOut) WriteTxOut(writer io.Writer, pver uint32, version int32) error

Jump to

Keyboard shortcuts

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