messages

package
v0.0.0-...-79d14b3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2015 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	BloomUpdateNone         = 0
	BloomUpdateAll          = 1
	BloomUpdateP2PubKeyOnly = 2
)
View Source
const (
	TypeError            = 0
	TypeMsgTX            = 1
	TypeMsgBlock         = 2
	TypeMsgFilteredBlock = 3
)
View Source
const (
	SigTypeAll    = 1
	SigTypeNone   = 2
	SigTypeSingle = 3

	SigTypeAnyOneCanPay = 0x80
)

Variables

View Source
var NilOutput = TxOutput{
	math.MaxUint64,
	nil,
	nil,
	nil,
	0,
}

NilOutput is the nil value of an output and is used for nilling irrelevant outputs when signing.

Functions

func EncodeInventoryVector

func EncodeInventoryVector(inv InventoryVector) ([]byte, error)

func ParseBytes

func ParseBytes(r io.Reader, l int) ([]byte, error)

func ParseCompactUint

func ParseCompactUint(r io.Reader) (uint, error)

func ParseVarBytes

func ParseVarBytes(r io.Reader) ([]byte, error)

func ParseVarString

func ParseVarString(r io.Reader) (string, error)

func TypeString

func TypeString(t uint32) string

func WriteCompactUint

func WriteCompactUint(val uint, w io.Writer) error

func WriteVarBytes

func WriteVarBytes(b []byte, w io.Writer) error

func WriteVarString

func WriteVarString(s string, w io.Writer) error

Types

type Block

type Block struct {
	BlockHeader  // 80 bytes
	Transactions []*Transaction
	Hash         []byte // 32 bytes
}

func ParseBlock

func ParseBlock(data []byte) (*Block, error)

func (*Block) String

func (b *Block) String() string

type BlockHeader

type BlockHeader struct {
	Version    int32  // 4 bytes
	PrevBlock  []byte // 32 bytes
	MerkleRoot []byte // 32 bytes
	Timestamp  uint32
	Bits       uint32
	Nonce      uint32

	Height int // not in protocol message.
	// contains filtered or unexported fields
}

func (*BlockHeader) Hash

func (h *BlockHeader) Hash() []byte

func (*BlockHeader) Serialize

func (h *BlockHeader) Serialize(w io.Writer) error

type ExtendedHeader

type ExtendedHeader struct {
	BlockHeader
	Count uint
	// contains filtered or unexported fields
}

func ParseExtendedHeader

func ParseExtendedHeader(input io.Reader) (*ExtendedHeader, error)

func (*ExtendedHeader) Data

func (h *ExtendedHeader) Data() []byte

func (*ExtendedHeader) Hash

func (h *ExtendedHeader) Hash() []byte

type FilterAdd

type FilterAdd struct {
	Data []byte // Up to 520 bytes
}

func (*FilterAdd) Serialize

func (a *FilterAdd) Serialize(w io.Writer) error

type FilterLoad

type FilterLoad struct {
	Filter    []byte // Up to 36000 bytes
	FuncCount uint32
	Tweak     uint32
	Flags     uint8
}

func NewFilterLoad

func NewFilterLoad(size int, funcs uint32) (*FilterLoad, error)

func ParseFilterLoad

func ParseFilterLoad(r io.Reader) (*FilterLoad, error)

func (*FilterLoad) AddData

func (f *FilterLoad) AddData(data []byte)

func (*FilterLoad) MayContain

func (f *FilterLoad) MayContain(data []byte) bool

func (*FilterLoad) Serialize

func (l *FilterLoad) Serialize(w io.Writer) error

type GetBlocks

type GetBlocks struct {
	Version  int32
	Locators [][]byte
	HashStop []byte
}

func (*GetBlocks) Serialize

func (g *GetBlocks) Serialize(w io.Writer) error

type Headers

type Headers []*ExtendedHeader

func ParseHeaders

func ParseHeaders(data []byte) (Headers, error)

type Inventory

type Inventory struct {
	Type uint32
	Hash []byte
}

func ParseInventory

func ParseInventory(b io.Reader) (*Inventory, error)

func (*Inventory) Write

func (i *Inventory) Write(w io.Writer) error

type InventoryVector

type InventoryVector []*Inventory

func ParseInventoryVector

func ParseInventoryVector(data []byte) (InventoryVector, error)

type MerkleBlock

type MerkleBlock struct {
	BlockHeader // 80 bytes
	TotalTXs    uint32
	Hashes      [][]byte
	Flags       []byte
}

func ParseMerkleBlock

func ParseMerkleBlock(data []byte) (*MerkleBlock, error)

type Message

type Message struct {
	Endpoint string
	Type     string
	Data     []byte
	// contains filtered or unexported fields
}

func ErrorMessage

func ErrorMessage(name string, err error) Message

func (Message) Error

func (m Message) Error() error

type OutPoint

type OutPoint struct {
	Hash  []byte
	Index uint32
	// contains filtered or unexported fields
}

func ParseOutPoint

func ParseOutPoint(input io.Reader) (*OutPoint, error)

func (*OutPoint) Serialize

func (p *OutPoint) Serialize() []byte

func (OutPoint) String

func (p OutPoint) String() string

type Transaction

type Transaction struct {
	Version  uint32
	Inputs   []*TxInput
	Outputs  []*TxOutput
	LockTime uint32
	// contains filtered or unexported fields
}

func ParseCoinbaseTransactionFromStream

func ParseCoinbaseTransactionFromStream(input io.Reader) (*Transaction, error)

func ParseTransaction

func ParseTransaction(data []byte) (*Transaction, error)

func ParseTransactionFromStream

func ParseTransactionFromStream(input io.Reader) (*Transaction, error)

func (*Transaction) AddInput

func (t *Transaction) AddInput(i *TxInput)

func (*Transaction) AddOutput

func (t *Transaction) AddOutput(o *TxOutput)

func (*Transaction) Data

func (t *Transaction) Data() []byte

func (*Transaction) Fingerprint

func (t *Transaction) Fingerprint() []byte

Fingerprint returns a fingerprint that is unique for each tx but doen't include the signatures (or other things that can be changed after broadcast).

func (*Transaction) Hash

func (t *Transaction) Hash() []byte

func (*Transaction) HashInternal

func (t *Transaction) HashInternal() string

func (*Transaction) InputTransactions

func (t *Transaction) InputTransactions() [][]byte

func (*Transaction) MatchesFilter

func (t *Transaction) MatchesFilter(filter *FilterLoad) bool

func (*Transaction) Serialize

func (t *Transaction) Serialize() []byte

func (*Transaction) SerializeWithoutSignature

func (t *Transaction) SerializeWithoutSignature() []byte

func (*Transaction) SignSerialize

func (t *Transaction) SignSerialize(signInput int, subscript []byte, hashCode uint32) []byte

TODO This function is only weakly related to the message aspect of a transaction, consider moving it somewhere else.

func (*Transaction) String

func (t *Transaction) String() string

type TxInput

type TxInput struct {
	PreviousOutput *OutPoint
	Signature      []byte
	Sequence       uint32
	// contains filtered or unexported fields
}

func (*TxInput) Index

func (i *TxInput) Index() uint

func (*TxInput) MatchesFilter

func (i *TxInput) MatchesFilter(filter *FilterLoad) bool

func (*TxInput) Serialize

func (i *TxInput) Serialize() []byte

Serialize returns the serialized version of the input as described by the protocol.

func (*TxInput) SerializeWithoutSignature

func (i *TxInput) SerializeWithoutSignature() []byte

SerializeWithoutSignature serializes the input, leaving the signature field empty. This is intended to just cover the fields not affected by transaction malleability.

func (*TxInput) SignSerialize

func (i *TxInput) SignSerialize(subscript []byte, nilSequence bool) []byte

SignSerialize returns the serialized version of the input, as required for signing the transaction. If a subscript is provided, it will be put in the place of the signature, if not provided the signature field will be left empty. If nilSequence is true, the sequence number will be set to 0, otherwise left as-is.

func (*TxInput) String

func (i *TxInput) String() string

type TxOutput

type TxOutput struct {
	Value  uint64
	Script []byte
	// contains filtered or unexported fields
}

func ParseTxOutput

func ParseTxOutput(b io.Reader) (*TxOutput, error)

func (TxOutput) AddressHash

func (o TxOutput) AddressHash() []byte

AddressHash returns the hash of the address being paid, or nil of the output is non-standard.

func (TxOutput) Fingerprint

func (o TxOutput) Fingerprint() []byte

Fingerprint returns a unique identifier of the transaction (unique across modified versions) and the output.

func (TxOutput) Index

func (o TxOutput) Index() uint32

Index returns the index of the output in its transaction.

func (*TxOutput) MatchesFilter

func (o *TxOutput) MatchesFilter(filter *FilterLoad) bool

func (TxOutput) Serialize

func (o TxOutput) Serialize() []byte

func (*TxOutput) String

func (o *TxOutput) String() string

func (TxOutput) TxFingerprint

func (o TxOutput) TxFingerprint() []byte

func (TxOutput) TxHash

func (o TxOutput) TxHash() []byte

TxHash returns the hash of the transaction the output is a part of.

Jump to

Keyboard shortcuts

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