wire

package
v1.2.26 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Unlicense, ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type B

type B = []byte

type BitcoinNet

type BitcoinNet uint32

BitcoinNet represents which bitcoin network a message belongs to.

const (
	// MainNet represents the main bitcoin network.
	MainNet BitcoinNet = 0xd9b4bef9

	// TestNet represents the regression test network.
	TestNet BitcoinNet = 0xdab5bffa

	// TestNet3 represents the test network (version 3).
	TestNet3 BitcoinNet = 0x0709110b

	// SimNet represents the simulation test network.
	SimNet BitcoinNet = 0x12141c16
)

Constants used to indicate the message bitcoin network. They can also be used to seek to the next message when a stream's state is unknown, but this package does not provide that functionality since it's generally a better idea to simply disconnect clients that are misbehaving over TCP.

type BlockHeader

type BlockHeader struct {
	// Version of the block.  This is not the same as the protocol version.
	Version int32
	// Hash of the previous block header in the block chain.
	PrevBlock chainhash.Hash
	// Merkle tree reference to hash of all transactions for the block.
	MerkleRoot chainhash.Hash
	// Time the block was created.  This is, unfortunately, encoded as a
	// uint32 on the wire and therefore is limited to 2106.
	Timestamp time.Time
	// Difficulty target for the block.
	Bits uint32
	// Nonce used to generate the block.
	Nonce uint32
}

BlockHeader defines information about a block and is used in the bitcoin block (MsgBlock) and headers (MsgHeaders) messages.

type Ctx

type Ctx = context.T

type E

type E = error

type MsgBlock

type MsgBlock struct {
	Header       BlockHeader
	Transactions []*MsgTx
}

MsgBlock implements the Message interface and represents a bitcoin block message. It is used to deliver block and transaction information in response to a getdata message (MsgGetData) for a given block hash.

type MsgTx

type MsgTx struct {
	Version  int32
	TxIn     []*TxIn
	TxOut    []*TxOut
	LockTime uint32
}

MsgTx implements the Message interface and represents a bitcoin tx message. It is used to deliver transaction information in response to a getdata message (MsgGetData) for a given transaction.

Use the AddTxIn and AddTxOut functions to build up the list of transaction inputs and outputs.

type N

type N = int

type OutPoint

type OutPoint struct {
	Hash  chainhash.Hash
	Index uint32
}

OutPoint defines a bitcoin data type that is used to track previous transaction outputs.

type S

type S = string

type TxIn

type TxIn struct {
	PreviousOutPoint OutPoint
	SignatureScript  []byte
	Witness          TxWitness
	Sequence         uint32
}

TxIn defines a bitcoin transaction input.

type TxOut

type TxOut struct {
	Value    int64
	PkScript []byte
}

TxOut defines a bitcoin transaction output.

type TxWitness

type TxWitness [][]byte

TxWitness defines the witness for a TxIn. A witness is to be interpreted as a slice of byte slices, or a stack with one or many elements.

Jump to

Keyboard shortcuts

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