Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeInventoryVector(inv InventoryVector) ([]byte, error)
- func ParseBytes(r io.Reader, l int) ([]byte, error)
- func ParseCompactUint(r io.Reader) (uint, error)
- func ParseVarBytes(r io.Reader) ([]byte, error)
- func ParseVarString(r io.Reader) (string, error)
- func TypeString(t uint32) string
- func WriteCompactUint(val uint, w io.Writer) error
- func WriteVarBytes(b []byte, w io.Writer) error
- func WriteVarString(s string, w io.Writer) error
- type Block
- type BlockHeader
- type ExtendedHeader
- type FilterAdd
- type FilterLoad
- type GetBlocks
- type Headers
- type Inventory
- type InventoryVector
- type MerkleBlock
- type Message
- type OutPoint
- type Transaction
- func (t *Transaction) AddInput(i *TxInput)
- func (t *Transaction) AddOutput(o *TxOutput)
- func (t *Transaction) Data() []byte
- func (t *Transaction) Fingerprint() []byte
- func (t *Transaction) Hash() []byte
- func (t *Transaction) HashInternal() string
- func (t *Transaction) InputTransactions() [][]byte
- func (t *Transaction) MatchesFilter(filter *FilterLoad) bool
- func (t *Transaction) Serialize() []byte
- func (t *Transaction) SerializeWithoutSignature() []byte
- func (t *Transaction) SignSerialize(signInput int, subscript []byte, hashCode uint32) []byte
- func (t *Transaction) String() string
- type TxInput
- type TxOutput
- func (o TxOutput) AddressHash() []byte
- func (o TxOutput) Fingerprint() []byte
- func (o TxOutput) Index() uint32
- func (o *TxOutput) MatchesFilter(filter *FilterLoad) bool
- func (o TxOutput) Serialize() []byte
- func (o *TxOutput) String() string
- func (o TxOutput) TxFingerprint() []byte
- func (o TxOutput) TxHash() []byte
Constants ¶
const ( BloomUpdateNone = 0 BloomUpdateAll = 1 BloomUpdateP2PubKeyOnly = 2 )
const ( TypeError = 0 TypeMsgTX = 1 TypeMsgBlock = 2 TypeMsgFilteredBlock = 3 )
const ( SigTypeAll = 1 SigTypeNone = 2 SigTypeSingle = 3 SigTypeAnyOneCanPay = 0x80 )
Variables ¶
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 TypeString ¶
Types ¶
type Block ¶
type Block struct { BlockHeader // 80 bytes Transactions []*Transaction Hash []byte // 32 bytes }
func ParseBlock ¶
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
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 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
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 ¶
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) MatchesFilter ¶
func (i *TxInput) MatchesFilter(filter *FilterLoad) bool
func (*TxInput) Serialize ¶
Serialize returns the serialized version of the input as described by the protocol.
func (*TxInput) SerializeWithoutSignature ¶
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 ¶
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.
type TxOutput ¶
func (TxOutput) AddressHash ¶
AddressHash returns the hash of the address being paid, or nil of the output is non-standard.
func (TxOutput) Fingerprint ¶
Fingerprint returns a unique identifier of the transaction (unique across modified versions) and the output.
func (*TxOutput) MatchesFilter ¶
func (o *TxOutput) MatchesFilter(filter *FilterLoad) bool