Documentation ¶
Overview ¶
Package wire implements the bitcoin wire protocol.
For the complete details of the bitcoin protocol, see the official wiki entry at https://en.bitcoin.it/wiki/Protocol_specification. The following only serves as a quick overview to provide information on how to use the package.
At a high level, this package provides support for marshalling and unmarshalling supported bitcoin messages to and from the wire. This package does not deal with the specifics of message handling such as what to do when a message is received. This provides the caller with a high level of flexibility.
Bitcoin Message Overview ¶
The bitcoin protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which bitcoin network it is a part of, its type, how big it is, and a checksum to verify validity. All encoding and decoding of message headers is handled by this package.
To accomplish this, there is a generic interface for bitcoin messages named Message which allows messages of any type to be read, written, or passed around through channels, functions, etc. In addition, concrete implementations of most of the currently supported bitcoin messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the wire using bitcoin encoding are handled so the caller doesn't have to concern themselves with the specifics.
Message Interaction ¶
The following provides a quick summary of how the bitcoin messages are intended to interact with one another. As stated above, these interactions are not directly handled by this package. For more in-depth details about the appropriate interactions, see the official bitcoin protocol wiki entry at https://en.bitcoin.it/wiki/Protocol_specification.
The initial handshake consists of two peers sending each other a version message (MsgVersion) followed by responding with a verack message (MsgVerAck). Both peers use the information in the version message (MsgVersion) to negotiate things such as protocol version and supported services with each other. Once the initial handshake is complete, the following chart indicates message interactions in no particular order.
Peer A Sends Peer B Responds ----------------------------------------------------------------------------- getaddr message (MsgGetAddr) addr message (MsgAddr) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - getblocks message (MsgGetBlocks) inv message (MsgInv) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - inv message (MsgInv) getdata message (MsgGetData) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - getdata message (MsgGetData) block message (MsgBlock) -or- tx message (MsgTx) -or- notfound message (MsgNotFound) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - getheaders message (MsgGetHeaders) headers message (MsgHeaders) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ping message (MsgPing) pong message (MsgHeaders)* -or- (none -- Ability to send message is enough) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NOTES: * The pong message was not added until later protocol versions as defined in BIP0031. The BIP0031Version constant can be used to detect a recent enough protocol version for this purpose (version > BIP0031Version).
Common Parameters ¶
There are several common parameters that arise when using this package to read and write bitcoin messages. The following sections provide a quick overview of these parameters so the next sections can build on them.
Protocol Version ¶
The protocol version should be negotiated with the remote server at a higher level than this package via the version (MsgVersion) message exchange, however, this package provides the wire.ProtocolVersion constant which indicates the latest protocol version this package supports and is typically the value to use for all outbound connections before a potentially lower protocol version is negotiated.
Jax Network ¶
The jax network is a magic number which is used to identify the start of a message and which jax network the message applies to. This package provides the following constants:
wire.MainNet wire.FastTestNet (Development network) wire.TestNet (Test network) wire.SimNet (Simulation test network)
Determining Message Type ¶
As discussed in the bitcoin message overview section, this package reads and writes bitcoin messages using a generic interface named Message. In order to determine the actual concrete type of the message, use a type switch or type assertion. An example of a type switch follows:
// Assumes msg is already a valid concrete message such as one created // via NewMsgVersion or read via ReadMessage. switch msg := msg.(type) { case *wire.MsgVersion: // The message is a pointer to a MsgVersion struct. fmt.Printf("Protocol version: %v", msg.ProtocolVersion) case *wire.MsgBlock: // The message is a pointer to a MsgBlock struct. fmt.Printf("Number of tx in block: %v", msg.Header.TxnCount) }
Reading Messages ¶
In order to unmarshall bitcoin messages from the wire, use the ReadMessage function. It accepts any io.Reader, but typically this will be a net.Conn to a remote node running a bitcoin server. Example syntax is:
// Reads and validates the next bitcoin message from conn using the // protocol version pver and the bitcoin network btcnet. The returns // are a wire.Message, a []byte which contains the unmarshalled // raw payload, and a possible error. msg, rawPayload, err := wire.ReadMessage(conn, pver, btcnet) if err != nil { // Log and handle the error }
Writing Messages ¶
In order to marshall bitcoin messages to the wire, use the WriteMessage function. It accepts any io.Writer, but typically this will be a net.Conn to a remote node running a bitcoin server. Example syntax to request addresses from a remote server is:
// Create a new getaddr bitcoin message. msg := wire.NewMsgGetAddr() // Writes a bitcoin message msg to conn using the protocol version // pver, and the bitcoin network btcnet. The return is a possible // error. err := wire.WriteMessage(conn, msg, pver, btcnet) if err != nil { // Log and handle the error }
Errors ¶
Errors returned by this package are either the raw errors provided by underlying calls to read/write from streams such as io.EOF, io.ErrUnexpectedEOF, and io.ErrShortWrite, or of type wire.MessageError. This allows the caller to differentiate between general IO errors and malformed messages through type assertions.
Bitcoin Improvement Proposals ¶
This package includes spec changes outlined by the following BIPs:
BIP0014 (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) BIP0031 (https://github.com/bitcoin/bips/blob/master/bip-0031.mediawiki) BIP0035 (https://github.com/bitcoin/bips/blob/master/bip-0035.mediawiki) BIP0037 (https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki) BIP0111 (https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki) BIP0130 (https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki) BIP0133 (https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki)
Index ¶
- Constants
- Variables
- func CollectTxHashes(transactions []*MsgTx, witness bool) []chainhash.Hash
- func PutUint32(w io.Writer, val uint32) error
- func PutUint64(w io.Writer, val uint64) error
- func RandomUint64() (uint64, error)
- func ReadElement(r io.Reader, element interface{}) error
- func ReadElements(r io.Reader, elements ...interface{}) error
- func ReadHashArray(r io.Reader) ([]chainhash.Hash, error)
- func ReadInvVect(r io.Reader, iv *InvVect) error
- func ReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error)
- func ReadVarInt(r io.Reader, pver uint32) (uint64, error)
- func ReadVarString(r io.Reader, pver uint32) (string, error)
- func Uint32(r io.Reader) (uint32, error)
- func Uint64(r io.Reader) (uint64, error)
- func VarIntSerializeSize(val uint64) int
- func WriteElement(w io.Writer, element interface{}) error
- func WriteElements(w io.Writer, elements ...interface{}) error
- func WriteHashArray(w io.Writer, data []chainhash.Hash) error
- func WriteInvVect(w io.Writer, iv *InvVect) error
- func WriteMessage(w io.Writer, msg Message, pver uint32, btcnet JaxNet) error
- func WriteMessageN(w io.Writer, msg Message, pver uint32, btcnet JaxNet) (int, error)
- func WriteMessageWithEncodingN(w io.Writer, msg Message, pver uint32, btcnet JaxNet, encoding MessageEncoding) (int, error)
- func WriteShardBlockHeader(w io.Writer, bh *ShardHeader) error
- func WriteTxOut(w io.Writer, pver uint32, version int32, to *TxOut) error
- func WriteVarBytes(w io.Writer, pver uint32, bytes []byte) error
- func WriteVarInt(w io.Writer, val uint64) error
- func WriteVarString(w io.Writer, pver uint32, str string) error
- type Alert
- type BTCBlockAux
- func (h *BTCBlockAux) BlockHash() chainhash.Hash
- func (h *BTCBlockAux) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (h *BTCBlockAux) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (h *BTCBlockAux) Copy() *BTCBlockAux
- func (h *BTCBlockAux) Deserialize(r io.Reader) error
- func (h *BTCBlockAux) Serialize(w io.Writer) error
- func (h *BTCBlockAux) UpdateCoinbaseScript(coinbaseScript []byte)
- type BVersion
- func (bv BVersion) ExpansionApproved() bool
- func (bv BVersion) ExpansionMade() bool
- func (bv BVersion) SetExpansionApproved() BVersion
- func (bv BVersion) SetExpansionMade() BVersion
- func (bv BVersion) UnsetExpansionApproved() BVersion
- func (bv BVersion) UnsetExpansionMade() BVersion
- func (bv BVersion) Version() int32
- type BeaconHeader
- func (h *BeaconHeader) BTCAux() *BTCBlockAux
- func (h *BeaconHeader) BeaconExclusiveHash() chainhash.Hash
- func (h *BeaconHeader) BeaconHeader() *BeaconHeader
- func (h *BeaconHeader) Bits() uint32
- func (h *BeaconHeader) BlockHash() chainhash.Hash
- func (h *BeaconHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (h *BeaconHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (h *BeaconHeader) ChainWeight() uint64
- func (h *BeaconHeader) Copy() BlockHeader
- func (h *BeaconHeader) ExclusiveHash() chainhash.Hash
- func (h *BeaconHeader) Height() int32
- func (h *BeaconHeader) K() uint32
- func (h *BeaconHeader) MaxLength() int
- func (h *BeaconHeader) MergeMiningNumber() uint32
- func (h *BeaconHeader) MergeMiningRoot() chainhash.Hash
- func (h *BeaconHeader) MergedMiningTree() []byte
- func (h *BeaconHeader) MergedMiningTreeCodingProof() ([]chainhash.Hash, []byte, uint32)
- func (h *BeaconHeader) MergedMiningTreeSize() uint32
- func (h *BeaconHeader) MerkleRoot() chainhash.Hash
- func (h *BeaconHeader) Nonce() uint32
- func (h *BeaconHeader) PoWHash() chainhash.Hash
- func (h *BeaconHeader) PrevBlocksMMRRoot() chainhash.Hash
- func (h *BeaconHeader) Read(r io.Reader) error
- func (h *BeaconHeader) Serialize(w io.Writer) error
- func (h *BeaconHeader) SetBTCAux(header BTCBlockAux)
- func (h *BeaconHeader) SetBeaconHeader(bh *BeaconHeader, _ CoinbaseAux)
- func (h *BeaconHeader) SetBits(bits uint32)
- func (h *BeaconHeader) SetK(value uint32)
- func (h *BeaconHeader) SetMergeMiningNumber(n uint32)
- func (h *BeaconHeader) SetMergeMiningRoot(value chainhash.Hash)
- func (h *BeaconHeader) SetMergedMiningTreeCodingProof(hashes []chainhash.Hash, coding []byte, codingLengthBits uint32)
- func (h *BeaconHeader) SetMerkleRoot(hash chainhash.Hash)
- func (h *BeaconHeader) SetNonce(n uint32)
- func (h *BeaconHeader) SetPrevBlocksMMRRoot(root chainhash.Hash)
- func (h *BeaconHeader) SetShardMerkleProof([]chainhash.Hash)
- func (h *BeaconHeader) SetShards(value uint32)
- func (h *BeaconHeader) SetTimestamp(t time.Time)
- func (h *BeaconHeader) SetVersion(v BVersion)
- func (h *BeaconHeader) SetVoteK(value uint32)
- func (h *BeaconHeader) ShardMerkleProof() []chainhash.Hash
- func (h *BeaconHeader) Shards() uint32
- func (h *BeaconHeader) Timestamp() time.Time
- func (h *BeaconHeader) UpdateCoinbaseScript(coinbaseScript []byte)
- func (h *BeaconHeader) Version() BVersion
- func (h *BeaconHeader) VoteK() uint32
- func (h *BeaconHeader) Write(w io.Writer) error
- type BeaconHeaderConstructor
- type BlockHeader
- type BlockLocatorMeta
- type BloomUpdateType
- type CoinbaseAux
- func (h *CoinbaseAux) Copy() *CoinbaseAux
- func (h *CoinbaseAux) Deserialize(r io.Reader) error
- func (CoinbaseAux) FromBlock(block *MsgBlock, witness bool) CoinbaseAux
- func (CoinbaseAux) New() CoinbaseAux
- func (h *CoinbaseAux) Serialize(w io.Writer) error
- func (h *CoinbaseAux) UpdatedMerkleRoot() chainhash.Hash
- type EADAddress
- func (msg *EADAddress) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
- func (msg *EADAddress) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
- func (msg *EADAddress) Command() string
- func (msg *EADAddress) Eq(ip net.IP, url string, shardID uint32) bool
- func (msg *EADAddress) HasShard(shards ...uint32) (hasOneOf bool)
- func (msg *EADAddress) MaxPayloadLength(uint32) uint32
- type EADAddresses
- func (msg *EADAddresses) AddAddress(ip net.IP, url string, port uint16, expiresAt int64, shardID uint32, ...)
- func (msg *EADAddresses) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *EADAddresses) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *EADAddresses) Command() string
- func (msg *EADAddresses) MaxPayloadLength(uint32) uint32
- type FilterType
- type HeaderBox
- type HeaderConstructor
- type Int64Time
- type InvType
- type InvVect
- type JaxNet
- type Message
- type MessageEncoding
- type MessageError
- type MsgAddr
- func (msg *MsgAddr) AddAddress(na *NetAddress) error
- func (msg *MsgAddr) AddAddresses(netAddrs ...*NetAddress) error
- func (msg *MsgAddr) AddShardAddress(shardId uint32, na *NetAddress) error
- func (msg *MsgAddr) AddShards(netAddrs ...*ShardAddress) error
- func (msg *MsgAddr) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgAddr) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgAddr) ClearAddresses()
- func (msg *MsgAddr) Command() string
- func (msg *MsgAddr) MaxPayloadLength(pver uint32) uint32
- type MsgAlert
- type MsgBlock
- func (msg *MsgBlock) AddTransaction(tx *MsgTx) error
- func (msg *MsgBlock) BlockHash() chainhash.Hash
- func (msg *MsgBlock) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) (err error)
- func (msg *MsgBlock) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgBlock) ClearTransactions()
- func (msg *MsgBlock) Command() string
- func (msg *MsgBlock) Copy() *MsgBlock
- func (msg *MsgBlock) Deserialize(r io.Reader) error
- func (msg *MsgBlock) DeserializeNoWitness(r io.Reader) error
- func (msg *MsgBlock) DeserializeTxLoc(r *bytes.Buffer) ([]TxLoc, error)
- func (msg *MsgBlock) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgBlock) Serialize(w io.Writer) error
- func (msg *MsgBlock) SerializeNoWitness(w io.Writer) error
- func (msg *MsgBlock) SerializeSize() int
- func (msg *MsgBlock) SerializeSizeStripped() int
- func (msg *MsgBlock) TxHashes() ([]chainhash.Hash, error)
- type MsgBlockBox
- type MsgCFCheckpt
- func (msg *MsgCFCheckpt) AddCFHeader(header *chainhash.Hash) error
- func (msg *MsgCFCheckpt) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
- func (msg *MsgCFCheckpt) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
- func (msg *MsgCFCheckpt) Command() string
- func (msg *MsgCFCheckpt) Deserialize(r io.Reader) error
- func (msg *MsgCFCheckpt) MaxPayloadLength(pver uint32) uint32
- type MsgCFHeaders
- func (msg *MsgCFHeaders) AddCFHash(hash *chainhash.Hash) error
- func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
- func (msg *MsgCFHeaders) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
- func (msg *MsgCFHeaders) Command() string
- func (msg *MsgCFHeaders) Deserialize(r io.Reader) error
- func (msg *MsgCFHeaders) MaxPayloadLength(pver uint32) uint32
- type MsgCFilter
- func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
- func (msg *MsgCFilter) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
- func (msg *MsgCFilter) Command() string
- func (msg *MsgCFilter) Deserialize(r io.Reader) error
- func (msg *MsgCFilter) MaxPayloadLength(pver uint32) uint32
- type MsgFeeFilter
- type MsgFilterAdd
- type MsgFilterClear
- type MsgFilterLoad
- type MsgGetAddr
- type MsgGetBlocks
- func (msg *MsgGetBlocks) AddBlockLocatorMeta(hash *BlockLocatorMeta) error
- func (msg *MsgGetBlocks) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgGetBlocks) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgGetBlocks) Command() string
- func (msg *MsgGetBlocks) MaxPayloadLength(pver uint32) uint32
- type MsgGetCFCheckpt
- type MsgGetCFHeaders
- type MsgGetCFilters
- type MsgGetData
- func (msg *MsgGetData) AddInvVect(iv *InvVect) error
- func (msg *MsgGetData) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgGetData) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgGetData) Command() string
- func (msg *MsgGetData) MaxPayloadLength(pver uint32) uint32
- type MsgGetHeaders
- func (msg *MsgGetHeaders) AddBlockLocatorMeta(hash *BlockLocatorMeta) error
- func (msg *MsgGetHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgGetHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgGetHeaders) Command() string
- func (msg *MsgGetHeaders) MaxPayloadLength(pver uint32) uint32
- type MsgHeaders
- func (msg *MsgHeaders) AddBlockHeader(bh BlockHeader, mmrRoot chainhash.Hash) error
- func (msg *MsgHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgHeaders) Command() string
- func (msg *MsgHeaders) MaxPayloadLength(pver uint32) uint32
- type MsgInv
- func (msg *MsgInv) AddInvVect(iv *InvVect) error
- func (msg *MsgInv) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgInv) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgInv) Command() string
- func (msg *MsgInv) MaxPayloadLength(pver uint32) uint32
- type MsgMemPool
- type MsgMerkleBlock
- func (msg *MsgMerkleBlock) AddTxHash(hash *chainhash.Hash) error
- func (msg *MsgMerkleBlock) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) (err error)
- func (msg *MsgMerkleBlock) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgMerkleBlock) Command() string
- func (msg *MsgMerkleBlock) MaxPayloadLength(pver uint32) uint32
- type MsgNotFound
- func (msg *MsgNotFound) AddInvVect(iv *InvVect) error
- func (msg *MsgNotFound) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgNotFound) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgNotFound) Command() string
- func (msg *MsgNotFound) MaxPayloadLength(pver uint32) uint32
- type MsgPing
- type MsgPong
- type MsgPortRedirect
- type MsgReject
- type MsgSendHeaders
- type MsgTx
- func (msg *MsgTx) AddTxIn(ti *TxIn)
- func (msg *MsgTx) AddTxOut(to *TxOut)
- func (msg *MsgTx) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgTx) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgTx) CleanVersion() int32
- func (msg *MsgTx) Command() string
- func (msg *MsgTx) Copy() *MsgTx
- func (msg *MsgTx) Deserialize(r io.Reader) error
- func (msg *MsgTx) DeserializeNoWitness(r io.Reader) error
- func (msg *MsgTx) HasWitness() bool
- func (msg *MsgTx) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgTx) PkScriptLocs() []int
- func (msg *MsgTx) Serialize(w io.Writer) error
- func (msg *MsgTx) SerializeNoWitness(w io.Writer) error
- func (msg *MsgTx) SerializeSize() int
- func (msg *MsgTx) SerializeSizeStripped() int
- func (msg *MsgTx) SerializeToHex() (string, error)
- func (msg *MsgTx) SwapTx() bool
- func (msg *MsgTx) TxHash() chainhash.Hash
- func (msg *MsgTx) WitnessHash() chainhash.Hash
- type MsgVerAck
- type MsgVersion
- func (msg *MsgVersion) AddService(service ServiceFlag)
- func (msg *MsgVersion) AddUserAgent(name string, version string, comments ...string) error
- func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (*MsgVersion) Command() string
- func (msg *MsgVersion) HasService(service ServiceFlag) bool
- func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32
- type NetAddress
- type OutPoint
- type RejectCode
- type ServiceFlag
- type ShardAddress
- type ShardHeader
- func (h *ShardHeader) BeaconCoinbaseAux() *CoinbaseAux
- func (h *ShardHeader) BeaconHeader() *BeaconHeader
- func (h *ShardHeader) Bits() uint32
- func (h *ShardHeader) BlockHash() chainhash.Hash
- func (h *ShardHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (h *ShardHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (h *ShardHeader) ChainWeight() uint64
- func (h *ShardHeader) Copy() BlockHeader
- func (h *ShardHeader) ExclusiveHash() chainhash.Hash
- func (h *ShardHeader) Height() int32
- func (h *ShardHeader) K() uint32
- func (h *ShardHeader) MaxLength() int
- func (h *ShardHeader) MergeMiningNumber() uint32
- func (h *ShardHeader) MergeMiningRoot() chainhash.Hash
- func (h *ShardHeader) MerkleRoot() chainhash.Hash
- func (h *ShardHeader) Nonce() uint32
- func (h *ShardHeader) PoWHash() chainhash.Hash
- func (h *ShardHeader) PrevBlocksMMRRoot() chainhash.Hash
- func (h *ShardHeader) Read(r io.Reader) error
- func (h *ShardHeader) Serialize(w io.Writer) error
- func (h *ShardHeader) SetBeaconHeader(bh *BeaconHeader, beaconAux CoinbaseAux)
- func (h *ShardHeader) SetBits(bits uint32)
- func (h *ShardHeader) SetK(value uint32)
- func (h *ShardHeader) SetMergeMiningNumber(n uint32)
- func (h *ShardHeader) SetMergeMiningRoot(value chainhash.Hash)
- func (h *ShardHeader) SetMerkleRoot(hash chainhash.Hash)
- func (h *ShardHeader) SetNonce(n uint32)
- func (h *ShardHeader) SetPrevBlocksMMRRoot(root chainhash.Hash)
- func (h *ShardHeader) SetShardMerkleProof(value []chainhash.Hash)
- func (h *ShardHeader) SetTimestamp(t time.Time)
- func (h *ShardHeader) SetVoteK(value uint32)
- func (h *ShardHeader) ShardExclusiveBlockHash() chainhash.Hash
- func (h *ShardHeader) ShardMerkleProof() []chainhash.Hash
- func (h *ShardHeader) Timestamp() time.Time
- func (h *ShardHeader) UpdateCoinbaseScript(coinbaseScript []byte)
- func (h *ShardHeader) Version() BVersion
- func (h *ShardHeader) VoteK() uint32
- func (h *ShardHeader) Write(w io.Writer) error
- type ShardHeaderConstructor
- type TxIn
- type TxLoc
- type TxOut
- type TxWitness
- type Uint32Time
Constants ¶
const ( ExpansionApprove = 1 << iota ExpansionMade )
const ( // MaxInvPerMsg is the maximum number of inventory vectors that can be in a // single jaxnetd inv message. MaxInvPerMsg = 50000 // MaxInvVectPayload is maximum payload size for an inventory vector. MaxInvVectPayload = 4 + chainhash.HashSize // InvWitnessFlag denotes that the inventory vector type is requesting, // or sending a version which includes witness data. InvWitnessFlag = 1 << 30 )
const ( CmdVersion = "version" CmdVerAck = "verack" CmdGetAddr = "getaddr" CmdAddr = "addr" CmdGetBlocks = "getblocks" CmdInv = "inv" CmdGetData = "getdata" CmdNotFound = "notfound" CmdBlock = "block" CmdBlockBox = "blockbox" CmdTx = "tx" CmdGetHeaders = "getheaders" CmdHeaders = "headers" CmdPing = "ping" CmdPong = "pong" CmdAlert = "alert" CmdMemPool = "mempool" CmdFilterAdd = "filteradd" CmdFilterClear = "filterclear" CmdFilterLoad = "filterload" CmdMerkleBlock = "merkleblock" CmdReject = "reject" CmdSendHeaders = "sendheaders" CmdFeeFilter = "feefilter" CmdGetCFilters = "getcfilters" CmdGetCFHeaders = "getcfheaders" CmdGetCFCheckpt = "getcfcheckpt" CmdCFilter = "cfilter" CmdCFHeaders = "cfheaders" CmdCFCheckpt = "cfcheckpt" CmdPortRedirect = "portredirect" CmdEadAddresses = "eaddresses" CmdEadIp = "eadip" )
Commands used in bitcoin message headers which describe the type of message.
const ( // MaxCFHeaderPayload is the maximum byte size of a committed // filter header. MaxCFHeaderPayload = chainhash.HashSize // MaxCFHeadersPerMsg is the maximum number of committed filter headers // that can be in a single bitcoin cfheaders message. MaxCFHeadersPerMsg = 2000 )
const ( // MaxFilterLoadHashFuncs is the maximum number of hash functions to // load into the Bloom filter. MaxFilterLoadHashFuncs = 50 // MaxFilterLoadFilterSize is the maximum size in bytes a filter may be. MaxFilterLoadFilterSize = 36000 )
const ( // TxVersion is the current latest supported transaction version. TxVersion = TxVerRegular MaxTxVersion = TxVerCrossShardSwap // MaxTxInSequenceNum is the maximum sequence number the sequence field // of a transaction input can be. MaxTxInSequenceNum uint32 = 0xffffffff // MaxPrevOutIndex is the maximum index the index field of a previous // outpoint can be. MaxPrevOutIndex uint32 = 0xffffffff // SequenceLockTimeDisabled is a flag that if set on a transaction // input's sequence number, the sequence number will not be interpreted // as a relative locktime. SequenceLockTimeDisabled = 1 << 31 // SequenceLockTimeIsSeconds is a flag that if set on a transaction // input's sequence number, the relative locktime has units of 512 // seconds. SequenceLockTimeIsSeconds = 1 << 22 // SequenceLockTimeMask is a mask that extracts the relative locktime // when masked against the transaction input sequence number. SequenceLockTimeMask = 0x0000ffff // SequenceLockTimeGranularity is the defined time based granularity // for seconds-based relative time locks. When converting from seconds // to a sequence number, the value is right shifted by this amount, // therefore the granularity of relative time locks in 512 or 2^9 // seconds. Enforced relative lock times are multiples of 512 seconds. SequenceLockTimeGranularity = 9 // MinTxOutPayload is the minimum payload size for a transaction output. // Value 8 bytes + Varint for PkScript length 1 byte. MinTxOutPayload = 9 )
const ( TxVerRegular = 1 // TxVerRegular is a simple transaction. TxVerTimeLock = 2 // TxVerTimeLock - tx will not be accepted until the LockTime expires. TxVerEADAction = 3 // TxVerEADAction is a tx for EAD Address Registration/Revoking TxVerCrossShardSwap = 4 // TxVerCrossShardSwap is a tx for EAD Address Registration/Revoking )
const ( BaseJaxProtocol uint32 = iota // ProtocolVersion is the latest protocol version this package supports. ProtocolVersion = BaseJaxProtocol )
todo(mike): we will probably need to bump this.
const ( // CFCheckptInterval is the gap (in number of blocks) between each // filter header checkpoint. CFCheckptInterval = 1000 )
const CommandSize = 12
CommandSize is the fixed size of all commands in the common bitcoin message header. Shorter commands must be zero padded.
const DefaultUserAgent = "/jaxnetwire:0.1.0/"
DefaultUserAgent for wire in the stack
const MaxAddrPerMsg = 1000
MaxAddrPerMsg is the maximum number of addresses that can be in a single bitcoin addr message (MsgAddr).
const ( // MaxBeaconBlockHeaderPayload is the maximum number of bytes a block BeaconHeader can be. // Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes + Shards 4 bytes + // PrevBlock, MerkleRoot, MergeMiningRoot hashes + tree X bytes. //todo: add treeEncoding len MaxBeaconBlockHeaderPayload = 1024 )
const MaxBlockHeaderPayload = 16 + (chainhash.HashSize * 2)
MaxBlockHeaderPayload is the maximum number of bytes a block header can be. Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes + PrevBlock and MerkleRoot hashes.
const MaxBlockHeadersPerMsg = 1000
MaxBlockHeadersPerMsg is the maximum number of block headers that can be in a single bitcoin headers message.
const MaxBlockLocatorsPerMsg = 500
MaxBlockLocatorsPerMsg is the maximum number of block locator hashes allowed per message.
const MaxBlockPayload = 768 * 1024 // 768 kB
MaxBlockPayload is the maximum bytes a block message can be in bytes. After Segregated Witness, the max block payload has been raised to 4MB. const MaxBlockPayload = 4000000 // 4MB
const MaxBlocksPerMsg = 500
MaxBlocksPerMsg is the maximum number of blocks allowed per message.
const ( // MaxCFilterDataSize is the maximum byte size of a committed filter. // The maximum size is currently defined as 256KiB. MaxCFilterDataSize = 256 * 1024 )
const (
// MaxEADDomainLen is limit for the length of ead address host/URI
MaxEADDomainLen = 256
)
const ( // MaxFilterAddDataSize is the maximum byte size of a data // element to add to the Bloom filter. It is equal to the // maximum element size of a script. MaxFilterAddDataSize = 520 )
const MaxGetCFiltersReqRange = 1000
MaxGetCFiltersReqRange the maximum number of filters that may be requested in a getcfheaders message.
const MaxMessagePayload = 1024 * 1024 * 1024 * 2 // 2 GB
MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves. const MaxMessagePayload = 1024 * 1024 * 32 // 32MB
const ( // MaxShardBlockHeaderPayload is the maximum number of bytes a block ShardHeader can be. // PrevBlock and MerkleRoot hashes + Timestamp 4 bytes + Bits 4 bytes + // + mergeMiningNumber 4 bytes + MaxBeaconBlockHeaderPayload. MaxShardBlockHeaderPayload = MaxBeaconBlockHeaderPayload * 2 )
const MaxUserAgentLen = 256
MaxUserAgentLen is the maximum allowed length for the user agent field in a version message (MsgVersion).
const (
// MaxVarIntPayload is the maximum payload size for a variable length integer.
MaxVarIntPayload = 9
)
const MessageHeaderSize = 24
MessageHeaderSize is the number of bytes in a bitcoin message header. Bitcoin network (magic) 4 bytes + command 12 bytes + payload length 4 bytes + checksum 4 bytes.
Variables ¶
var BinarySerializer binaryFreeList = make(chan []byte, binaryFreeListMaxItems)
BinarySerializer provides a free list of buffers to use for serializing and deserializing primitive integer values to and from io.Readers and io.Writers.
var ErrInsaneCFHeaderCount = errors.New(
"refusing to decode unreasonable number of filter headers")
ErrInsaneCFHeaderCount signals that we were asked to decode an unreasonable number of cfilter headers.
var LatestEncoding = WitnessEncoding
LatestEncoding is the most recently specified encoding for the Bitcoin wire protocol.
Functions ¶
func CollectTxHashes ¶ added in v0.4.2
func RandomUint64 ¶ added in v0.4.2
RandomUint64 returns a cryptographically random uint64 value.
func ReadElement ¶ added in v0.4.2
ReadElement reads the next sequence of bytes from r using little endian depending on the concrete type of element pointed to.
func ReadElements ¶ added in v0.4.2
ReadElements reads multiple items from r. It is equivalent to multiple calls to readElement.
func ReadInvVect ¶ added in v0.4.2
ReadInvVect reads an encoded InvVect from r depending on the protocol version.
func ReadVarBytes ¶ added in v0.4.2
ReadVarBytes reads a variable length byte array. A byte array is encoded as a varInt containing the length of the array followed by the bytes themselves. An error is returned if the length is greater than the passed maxAllowed parameter which helps protect against memory exhaustion attacks and forced panics through malformed messages. The fieldName parameter is only used for the error message so it provides more context in the error.
func ReadVarInt ¶ added in v0.4.2
ReadVarInt reads a variable length integer from r and returns it as a uint64.
func ReadVarString ¶ added in v0.4.2
ReadVarString reads a variable length string from r and returns it as a Go string. A variable length string is encoded as a variable length integer containing the length of the string followed by the bytes that represent the string itself. An error is returned if the length is greater than the maximum block payload size since it helps protect against memory exhaustion attacks and forced panics through malformed messages.
func VarIntSerializeSize ¶ added in v0.4.2
VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.
func WriteElement ¶ added in v0.4.2
WriteElement writes the little endian representation of element to w.
func WriteElements ¶ added in v0.4.2
WriteElements writes multiple items to w. It is equivalent to multiple calls to writeElement.
func WriteInvVect ¶ added in v0.4.2
WriteInvVect serializes an InvVect to w depending on the protocol version.
func WriteMessage ¶
WriteMessage writes a bitcoin Message to w including the necessary header information. This function is the same as WriteMessageN except it doesn't doesn't return the number of bytes written. This function is mainly provided for backwards compatibility with the original API, but it's also useful for callers that don't care about byte counts.
func WriteMessageN ¶
WriteMessageN writes a bitcoin Message to w including the necessary header information and returns the number of bytes written. This function is the same as WriteMessage except it also returns the number of bytes written.
func WriteMessageWithEncodingN ¶
func WriteMessageWithEncodingN(w io.Writer, msg Message, pver uint32, btcnet JaxNet, encoding MessageEncoding) (int, error)
WriteMessageWithEncodingN writes a bitcoin Message to w including the necessary header information and returns the number of bytes written. This function is the same as WriteMessageN except it also allows the caller to specify the message encoding format to be used when serializing wire messages.
func WriteShardBlockHeader ¶
func WriteShardBlockHeader(w io.Writer, bh *ShardHeader) error
WriteShardBlockHeader writes a bitcoin block ShardHeader to w. See Serialize for encoding block headers to be stored to disk, such as in a database, as opposed to encoding for the wire.
func WriteTxOut ¶
WriteTxOut encodes to into the bitcoin protocol encoding for a transaction output (TxOut) to w.
NOTE: This function is exported in order to allow txscript to compute the new sighashes for witness transactions (BIP0143).
func WriteVarBytes ¶ added in v0.4.2
WriteVarBytes serializes a variable length byte array to w as a varInt containing the number of bytes, followed by the bytes themselves.
func WriteVarInt ¶ added in v0.4.2
WriteVarInt serializes val to w using a variable number of bytes depending on its value.
Types ¶
type Alert ¶
type Alert struct { // Alert format version Version int32 // Timestamp beyond which nodes should stop relaying this alert RelayUntil int64 // Timestamp beyond which this alert is no longer in effect and // should be ignored Expiration int64 // A unique ID number for this alert ID int32 // All alerts with an ID less than or equal to this number should // cancelled, deleted and not accepted in the future Cancel int32 // All alert IDs contained in this set should be cancelled as above SetCancel []int32 // This alert only applies to versions greater than or equal to this // version. Other versions should still relay it. MinVer int32 // This alert only applies to versions less than or equal to this version. // Other versions should still relay it. MaxVer int32 // If this set contains any elements, then only nodes that have their // subVer contained in this set are affected by the alert. Other versions // should still relay it. SetSubVer []string // Relative priority compared to other alerts Priority int32 // A comment on the alert that is not displayed Comment string // The alert message that is displayed to the user StatusBar string // Reserved Reserved string }
Alert contains the data deserialized from the MsgAlert payload.
func NewAlert ¶
func NewAlert(version int32, relayUntil int64, expiration int64, id int32, cancel int32, setCancel []int32, minVer int32, maxVer int32, setSubVer []string, priority int32, comment string, statusBar string) *Alert
NewAlert returns an new Alert with values provided.
func NewAlertFromPayload ¶
NewAlertFromPayload returns an Alert with values deserialized from the serialized payload.
func (*Alert) Deserialize ¶
Deserialize decodes from r into the receiver using the alert protocol encoding format.
type BTCBlockAux ¶
type BTCBlockAux 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 CoinbaseAux CoinbaseAux }
BTCBlockAux defines information about a block and is used in the bitcoin block (MsgBlock) and headers (MsgHeaders) messages.
func NewBTCBlockHeader ¶
func NewBTCBlockHeader(version int32, prevHash, merkleRootHash *chainhash.Hash, bits uint32, nonce uint32) *BTCBlockAux
NewBTCBlockHeader returns a new BTCBlockAux using the provided version, previous block hash, merkle root hash, difficulty bits, and nonce used to generate the block with defaults for the remaining fields.
func (*BTCBlockAux) BlockHash ¶
func (h *BTCBlockAux) BlockHash() chainhash.Hash
BlockHash computes the block identifier hash for the given block header.
func (*BTCBlockAux) BtcDecode ¶
func (h *BTCBlockAux) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding block headers stored to disk, such as in a database, as opposed to decoding block headers from the wire.
func (*BTCBlockAux) BtcEncode ¶
func (h *BTCBlockAux) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding block headers to be stored to disk, such as in a database, as opposed to encoding block headers for the wire.
func (*BTCBlockAux) Copy ¶
func (h *BTCBlockAux) Copy() *BTCBlockAux
Copy creates a deep copy of a BlockHeader so that the original does not get modified when the copy is manipulated.
func (*BTCBlockAux) Deserialize ¶
func (h *BTCBlockAux) Deserialize(r io.Reader) error
Deserialize decodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BTCBlockAux) Serialize ¶
func (h *BTCBlockAux) Serialize(w io.Writer) error
Serialize encodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BTCBlockAux) UpdateCoinbaseScript ¶
func (h *BTCBlockAux) UpdateCoinbaseScript(coinbaseScript []byte)
UpdateCoinbaseScript sets new coinbase script, rebuilds BTCBlockAux.TxMerkleProof and recalculates the BTCBlockAux.MerkleRoot with the updated extra nonce.
type BVersion ¶
type BVersion int32
func NewBVersion ¶
func (BVersion) ExpansionApproved ¶
func (BVersion) ExpansionMade ¶
func (BVersion) SetExpansionApproved ¶
func (BVersion) SetExpansionMade ¶
func (BVersion) UnsetExpansionApproved ¶
func (BVersion) UnsetExpansionMade ¶
type BeaconHeader ¶
type BeaconHeader struct {
// contains filtered or unexported fields
}
BeaconHeader defines information about a block and is used in the bitcoin block (MsgBlock) and headers (MsgHeaders) messages.
func EmptyBeaconHeader ¶
func EmptyBeaconHeader() *BeaconHeader
func NewBeaconBlockHeader ¶
func NewBeaconBlockHeader(height int32, version BVersion, blocksMerkleMountainRoot, merkleRootHash chainhash.Hash, mergeMiningRoot chainhash.Hash, timestamp time.Time, bits uint32, chainWeight uint64, nonce uint32) *BeaconHeader
NewBeaconBlockHeader returns a new BlockHeader using the provided version, previous block hash, merkle root hash, difficulty bits, and nonce used to generate the block with defaults for the remaining fields.
func (*BeaconHeader) BTCAux ¶
func (h *BeaconHeader) BTCAux() *BTCBlockAux
func (*BeaconHeader) BeaconExclusiveHash ¶ added in v0.3.9
func (h *BeaconHeader) BeaconExclusiveHash() chainhash.Hash
BeaconExclusiveHash computes the hash of the BeaconHeader without BtcAux. This hash needs to be set into Bitcoin coinbase tx, as proof of merge mining.
func (*BeaconHeader) BeaconHeader ¶
func (h *BeaconHeader) BeaconHeader() *BeaconHeader
func (*BeaconHeader) Bits ¶
func (h *BeaconHeader) Bits() uint32
func (*BeaconHeader) BlockHash ¶
func (h *BeaconHeader) BlockHash() chainhash.Hash
BlockHash computes the block identifier hash for the given block BeaconHeader.
func (*BeaconHeader) BtcDecode ¶
func (h *BeaconHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding block headers stored to disk, such as in a database, as opposed to decoding block headers from the wire.
func (*BeaconHeader) BtcEncode ¶
func (h *BeaconHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding block headers to be stored to disk, such as in a database, as opposed to encoding block headers for the wire.
func (*BeaconHeader) ChainWeight ¶ added in v0.4.2
func (h *BeaconHeader) ChainWeight() uint64
func (*BeaconHeader) Copy ¶
func (h *BeaconHeader) Copy() BlockHeader
Copy creates a deep copy of a BlockHeader so that the original does not get modified when the copy is manipulated.
func (*BeaconHeader) ExclusiveHash ¶ added in v0.4.0
func (h *BeaconHeader) ExclusiveHash() chainhash.Hash
ExclusiveHash computes the hash of the BeaconHeader without BtcAux. This hash needs to be set into Bitcoin coinbase tx, as proof of merge mining.
func (*BeaconHeader) Height ¶ added in v0.4.2
func (h *BeaconHeader) Height() int32
func (*BeaconHeader) K ¶
func (h *BeaconHeader) K() uint32
func (*BeaconHeader) MaxLength ¶
func (h *BeaconHeader) MaxLength() int
func (*BeaconHeader) MergeMiningNumber ¶ added in v0.4.0
func (h *BeaconHeader) MergeMiningNumber() uint32
func (*BeaconHeader) MergeMiningRoot ¶
func (h *BeaconHeader) MergeMiningRoot() chainhash.Hash
func (*BeaconHeader) MergedMiningTree ¶
func (h *BeaconHeader) MergedMiningTree() []byte
func (*BeaconHeader) MergedMiningTreeCodingProof ¶
func (h *BeaconHeader) MergedMiningTreeCodingProof() ([]chainhash.Hash, []byte, uint32)
func (*BeaconHeader) MergedMiningTreeSize ¶ added in v0.4.0
func (h *BeaconHeader) MergedMiningTreeSize() uint32
func (*BeaconHeader) MerkleRoot ¶
func (h *BeaconHeader) MerkleRoot() chainhash.Hash
func (*BeaconHeader) Nonce ¶
func (h *BeaconHeader) Nonce() uint32
func (*BeaconHeader) PoWHash ¶
func (h *BeaconHeader) PoWHash() chainhash.Hash
PoWHash computes the hash for block that will be used to check ProofOfWork.
func (*BeaconHeader) PrevBlocksMMRRoot ¶ added in v0.4.2
func (h *BeaconHeader) PrevBlocksMMRRoot() chainhash.Hash
func (*BeaconHeader) Read ¶
func (h *BeaconHeader) Read(r io.Reader) error
Deserialize decodes a block BeaconHeader from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BeaconHeader) Serialize ¶
func (h *BeaconHeader) Serialize(w io.Writer) error
Serialize encodes a block BeaconHeader from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BeaconHeader) SetBTCAux ¶
func (h *BeaconHeader) SetBTCAux(header BTCBlockAux)
func (*BeaconHeader) SetBeaconHeader ¶
func (h *BeaconHeader) SetBeaconHeader(bh *BeaconHeader, _ CoinbaseAux)
func (*BeaconHeader) SetBits ¶
func (h *BeaconHeader) SetBits(bits uint32)
func (*BeaconHeader) SetK ¶
func (h *BeaconHeader) SetK(value uint32)
func (*BeaconHeader) SetMergeMiningNumber ¶ added in v0.4.0
func (h *BeaconHeader) SetMergeMiningNumber(n uint32)
func (*BeaconHeader) SetMergeMiningRoot ¶
func (h *BeaconHeader) SetMergeMiningRoot(value chainhash.Hash)
func (*BeaconHeader) SetMergedMiningTreeCodingProof ¶
func (h *BeaconHeader) SetMergedMiningTreeCodingProof(hashes []chainhash.Hash, coding []byte, codingLengthBits uint32)
func (*BeaconHeader) SetMerkleRoot ¶
func (h *BeaconHeader) SetMerkleRoot(hash chainhash.Hash)
func (*BeaconHeader) SetNonce ¶
func (h *BeaconHeader) SetNonce(n uint32)
func (*BeaconHeader) SetPrevBlocksMMRRoot ¶ added in v0.4.2
func (h *BeaconHeader) SetPrevBlocksMMRRoot(root chainhash.Hash)
func (*BeaconHeader) SetShardMerkleProof ¶ added in v0.4.0
func (h *BeaconHeader) SetShardMerkleProof([]chainhash.Hash)
func (*BeaconHeader) SetShards ¶
func (h *BeaconHeader) SetShards(value uint32)
func (*BeaconHeader) SetTimestamp ¶
func (h *BeaconHeader) SetTimestamp(t time.Time)
func (*BeaconHeader) SetVersion ¶
func (h *BeaconHeader) SetVersion(v BVersion)
func (*BeaconHeader) SetVoteK ¶
func (h *BeaconHeader) SetVoteK(value uint32)
func (*BeaconHeader) ShardMerkleProof ¶ added in v0.4.0
func (h *BeaconHeader) ShardMerkleProof() []chainhash.Hash
func (*BeaconHeader) Shards ¶
func (h *BeaconHeader) Shards() uint32
func (*BeaconHeader) Timestamp ¶
func (h *BeaconHeader) Timestamp() time.Time
func (*BeaconHeader) UpdateCoinbaseScript ¶
func (h *BeaconHeader) UpdateCoinbaseScript(coinbaseScript []byte)
UpdateCoinbaseScript sets new coinbase script, rebuilds BTCBlockAux.TxMerkleProof and recalculates the BTCBlockAux.MerkleRoot with the updated extra nonce.
func (*BeaconHeader) Version ¶
func (h *BeaconHeader) Version() BVersion
func (*BeaconHeader) VoteK ¶
func (h *BeaconHeader) VoteK() uint32
type BeaconHeaderConstructor ¶
type BeaconHeaderConstructor struct{}
func (BeaconHeaderConstructor) BlockHeaderOverhead ¶
func (b BeaconHeaderConstructor) BlockHeaderOverhead() int
func (BeaconHeaderConstructor) EmptyHeader ¶
func (b BeaconHeaderConstructor) EmptyHeader() BlockHeader
func (BeaconHeaderConstructor) IsBeacon ¶
func (b BeaconHeaderConstructor) IsBeacon() bool
func (BeaconHeaderConstructor) MaxBlockHeaderPayload ¶
func (b BeaconHeaderConstructor) MaxBlockHeaderPayload() int
func (BeaconHeaderConstructor) ShardID ¶
func (b BeaconHeaderConstructor) ShardID() uint32
type BlockHeader ¶
type BlockHeader interface { BeaconHeader() *BeaconHeader SetBeaconHeader(bh *BeaconHeader, beaconAux CoinbaseAux) Version() BVersion Height() int32 ChainWeight() uint64 PrevBlocksMMRRoot() chainhash.Hash SetPrevBlocksMMRRoot(prevBlock chainhash.Hash) Timestamp() time.Time SetTimestamp(time.Time) MerkleRoot() chainhash.Hash SetMerkleRoot(chainhash.Hash) Bits() uint32 SetBits(uint32) Nonce() uint32 SetNonce(uint32) K() uint32 SetK(value uint32) VoteK() uint32 SetVoteK(value uint32) // BlockHash computes hash of header data including hash of the aux data. // BlockHash must be used as unique block identifier eq to BLOCK_ID. BlockHash() chainhash.Hash // ExclusiveHash computes hash of header data without any extra aux data. // ExclusiveHash needed to build inclusion proofs for merge mining ExclusiveHash() chainhash.Hash // PoWHash computes the hash for block that will be used to check ProofOfWork. PoWHash() chainhash.Hash // UpdateCoinbaseScript sets new coinbase script, rebuilds BTCBlockAux.TxMerkleProof // and recalculates the BTCBlockAux.MerkleRoot with the updated extra nonce. UpdateCoinbaseScript(coinbaseScript []byte) MergeMiningNumber() uint32 SetMergeMiningNumber(n uint32) SetShardMerkleProof(path []chainhash.Hash) ShardMerkleProof() []chainhash.Hash MergeMiningRoot() chainhash.Hash SetMergeMiningRoot(value chainhash.Hash) Read(r io.Reader) error Write(r io.Writer) error BtcEncode(w io.Writer, prev uint32, enc MessageEncoding) error // Copy creates a deep copy of a BlockHeader so that the original does not get // modified when the copy is manipulated. Copy() BlockHeader MaxLength() int }
func DecodeHeader ¶ added in v0.4.2
func DecodeHeader(r io.Reader) (BlockHeader, error)
type BlockLocatorMeta ¶ added in v0.4.2
func (*BlockLocatorMeta) Deserialize ¶ added in v0.4.2
func (msg *BlockLocatorMeta) Deserialize(r io.Reader) error
func (*BlockLocatorMeta) Serialize ¶ added in v0.4.2
func (msg *BlockLocatorMeta) Serialize(w io.Writer) error
func (*BlockLocatorMeta) SerializeSize ¶ added in v0.4.2
func (msg *BlockLocatorMeta) SerializeSize() int
func (*BlockLocatorMeta) String ¶ added in v0.4.2
func (msg *BlockLocatorMeta) String() string
type BloomUpdateType ¶ added in v0.4.2
type BloomUpdateType uint8
BloomUpdateType specifies how the filter is updated when a match is found
const ( // BloomUpdateNone indicates the filter is not adjusted when a match is // found. BloomUpdateNone BloomUpdateType = 0 // BloomUpdateAll indicates if the filter matches any data element in a // public key script, the outpoint is serialized and inserted into the // filter. BloomUpdateAll BloomUpdateType = 1 // BloomUpdateP2PubkeyOnly indicates if the filter matches a data // element in a public key script and the script is of the standard // pay-to-pubkey or multisig, the outpoint is serialized and inserted // into the filter. BloomUpdateP2PubkeyOnly BloomUpdateType = 2 )
type CoinbaseAux ¶
type CoinbaseAux struct { // Tx is the first tx from block with reward. Tx MsgTx // Merkle tree leaves of all transactions for the block. TxMerkleProof []chainhash.Hash }
func (*CoinbaseAux) Copy ¶
func (h *CoinbaseAux) Copy() *CoinbaseAux
Copy creates a deep copy of a CoinbaseAux so that the original does not get modified when the copy is manipulated.
func (*CoinbaseAux) Deserialize ¶
func (h *CoinbaseAux) Deserialize(r io.Reader) error
Deserialize decodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (CoinbaseAux) FromBlock ¶ added in v0.4.0
func (CoinbaseAux) FromBlock(block *MsgBlock, witness bool) CoinbaseAux
func (CoinbaseAux) New ¶
func (CoinbaseAux) New() CoinbaseAux
func (*CoinbaseAux) Serialize ¶
func (h *CoinbaseAux) Serialize(w io.Writer) error
Serialize encodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*CoinbaseAux) UpdatedMerkleRoot ¶ added in v0.4.0
func (h *CoinbaseAux) UpdatedMerkleRoot() chainhash.Hash
type EADAddress ¶
type EADAddress struct { // IP address of the server. IP net.IP // Port the server is using. Port uint16 // URL address of the server. URL string // ExpiresAt Address expiration time. ExpiresAt time.Time // Shard shows what shards the agent works with. Shard uint32 TxHash *chainhash.Hash TxOutIndex int }
EADAddress defines information about a Exchange Agent server on the network including the expiration time its IP address, and port.
func (*EADAddress) BtcDecode ¶
func (msg *EADAddress) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
func (*EADAddress) BtcEncode ¶
func (msg *EADAddress) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
func (*EADAddress) Command ¶
func (msg *EADAddress) Command() string
func (*EADAddress) HasShard ¶
func (msg *EADAddress) HasShard(shards ...uint32) (hasOneOf bool)
func (*EADAddress) MaxPayloadLength ¶
func (msg *EADAddress) MaxPayloadLength(uint32) uint32
type EADAddresses ¶
type EADAddresses struct { ID uint64 OwnerPubKey []byte Addresses []EADAddress // Address is unique combination of {IP|URL, SHARD_ID} }
func (*EADAddresses) AddAddress ¶
func (*EADAddresses) BtcDecode ¶
func (msg *EADAddresses) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
func (*EADAddresses) BtcEncode ¶
func (msg *EADAddresses) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*EADAddresses) Command ¶
func (msg *EADAddresses) Command() string
func (*EADAddresses) MaxPayloadLength ¶
func (msg *EADAddresses) MaxPayloadLength(uint32) uint32
type FilterType ¶
type FilterType uint8
FilterType is used to represent a filter type.
const ( // GCSFilterRegular is the regular filter type. GCSFilterRegular FilterType = iota )
type HeaderBox ¶ added in v0.4.2
type HeaderBox struct { ActualMMRRoot chainhash.Hash Header BlockHeader }
type HeaderConstructor ¶
type HeaderConstructor interface { EmptyHeader() BlockHeader BlockHeaderOverhead() int MaxBlockHeaderPayload() int IsBeacon() bool ShardID() uint32 }
type Int64Time ¶ added in v0.4.2
Int64Time represents a unix timestamp encoded with an int64. It is used as a way to signal the readElement function how to decode a timestamp into a Go time.Time since it is otherwise ambiguous.
type InvType ¶ added in v0.4.2
type InvType uint32
InvType represents the allowed types of inventory vectors. See InvVect.
const ( InvTypeError InvType = 0 InvTypeTx InvType = 1 InvTypeBlock InvType = 2 InvTypeFilteredBlock InvType = 3 InvTypeMMRRoot InvType = 4 InvTypeWitnessBlock InvType = InvTypeBlock | InvWitnessFlag InvTypeWitnessTx InvType = InvTypeTx | InvWitnessFlag InvTypeFilteredWitnessBlock InvType = InvTypeFilteredBlock | InvWitnessFlag )
These constants define the various supported inventory vector types.
type InvVect ¶ added in v0.4.2
InvVect defines a bitcoin inventory vector which is used to describe data, as specified by the Type field, that a server wants, has, or does not have to another server.
type JaxNet ¶ added in v0.4.2
type JaxNet uint32
JaxNet represents which JAX network a message belongs to.
const ( // MainNet represents the main jax network. MainNet JaxNet = 0x6a_61_78_64 // TestNet represents the test network. // TestNet JaxNet = 0x0709110b TestNet JaxNet = 0x76_6e_64_6d // SimNet represents the simulation test network. SimNet JaxNet = 0x12141c16 // FastTestNet represents the development jax network. FastTestNet JaxNet = 0x12121212 )
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 Message ¶
type Message interface { BtcDecode(io.Reader, uint32, MessageEncoding) error BtcEncode(io.Writer, uint32, MessageEncoding) error Command() string MaxPayloadLength(uint32) uint32 }
Message is an interface that describes a bitcoin message. A type that implements Message has complete control over the representation of its data and may therefore contain additional or fewer fields than those which are used directly in the protocol encoded message.
func ReadMessage ¶
ReadMessage reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the parsed Message and raw bytes which comprise the message. This function only differs from ReadMessageN in that it doesn't return the number of bytes read. This function is mainly provided for backwards compatibility with the original API, but it's also useful for callers that don't care about byte counts.
func ReadMessageN ¶
ReadMessageN reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the number of bytes read in addition to the parsed Message and raw bytes which comprise the message. This function is the same as ReadMessage except it also returns the number of bytes read.
func ReadMessageWithEncodingN ¶
func ReadMessageWithEncodingN(r io.Reader, pver uint32, btcnet JaxNet, enc MessageEncoding) (int, Message, []byte, error)
ReadMessageWithEncodingN reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the number of bytes read in addition to the parsed Message and raw bytes which comprise the message. This function is the same as ReadMessageN except it allows the caller to specify which message encoding is to to consult when decoding wire messages.
type MessageEncoding ¶ added in v0.4.2
type MessageEncoding uint32
const ( // BaseEncoding encodes all messages in the default format specified // for the Bitcoin wire protocol. BaseEncoding MessageEncoding = 1 << iota // WitnessEncoding encodes all messages other than transaction messages // using the default Bitcoin wire protocol specification. For transaction // messages, the new encoding format detailed in BIP0144 will be used. WitnessEncoding )
type MessageError ¶
type MessageError struct { Func string // Function name Description string // Human readable description of the issue }
MessageError describes an issue with a message. An example of some potential issues are messages from the wrong bitcoin network, invalid commands, mismatched checksums, and exceeding max payloads.
This provides a mechanism for the caller to type assert the error to differentiate between general io errors such as io.EOF and issues that resulted from malformed messages.
func Error ¶ added in v0.4.2
func Error(f string, desc string) *MessageError
Error creates an error for the given function and description.
func (*MessageError) Error ¶
func (e *MessageError) Error() string
Error satisfies the error interface and prints human-readable errors.
type MsgAddr ¶
type MsgAddr struct { AddrList []*NetAddress Shards []*ShardAddress }
MsgAddr implements the Message interface and represents a bitcoin addr message. It is used to provide a list of known active peers on the network. An active server is considered one that has transmitted a message within the last 3 hours. Nodes which have not transmitted in that time frame should be forgotten. Each message is limited to a maximum number of addresses, which is currently 1000. As a result, multiple messages must be used to relay the full list.
Use the AddAddress function to build up the list of known addresses when sending an addr message to another server.
func NewMsgAddr ¶
func NewMsgAddr() *MsgAddr
NewMsgAddr returns a new bitcoin addr message that conforms to the Message interface. See MsgAddr for details.
func (*MsgAddr) AddAddress ¶
func (msg *MsgAddr) AddAddress(na *NetAddress) error
AddAddress adds a known active server to the message.
func (*MsgAddr) AddAddresses ¶
func (msg *MsgAddr) AddAddresses(netAddrs ...*NetAddress) error
AddAddresses adds multiple known active peers to the message.
func (*MsgAddr) AddShardAddress ¶
func (msg *MsgAddr) AddShardAddress(shardId uint32, na *NetAddress) error
AddShardAddress adds a known active server to the message.
func (*MsgAddr) AddShards ¶
func (msg *MsgAddr) AddShards(netAddrs ...*ShardAddress) error
AddAddresses adds multiple known active peers to the message.
func (*MsgAddr) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgAddr) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgAddr) ClearAddresses ¶
func (msg *MsgAddr) ClearAddresses()
ClearAddresses removes all addresses from the message.
func (*MsgAddr) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAddr) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgAlert ¶
type MsgAlert struct { // SerializedPayload is the alert payload serialized as a string so that the // version can change but the Alert can still be passed on by older // clients. SerializedPayload []byte // Signature is the ECDSA signature of the message. Signature []byte // Deserialized Payload Payload *Alert }
MsgAlert implements the Message interface and defines a bitcoin alert message.
This is a signed message that provides notifications that the client should display if the signature matches the key. jaxnetd/bitcoin-qt only checks against a signature from the core developers.
func NewMsgAlert ¶
NewMsgAlert returns a new bitcoin alert message that conforms to the Message interface. See MsgAlert for details.
func (*MsgAlert) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgAlert) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgAlert) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAlert) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
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.
func EmptyBeaconBlock ¶
func EmptyBeaconBlock() MsgBlock
func EmptyShardBlock ¶
func EmptyShardBlock() MsgBlock
func NewMsgBlock ¶
func NewMsgBlock(blockHeader BlockHeader) *MsgBlock
NewMsgBlock returns a new bitcoin block message that conforms to the Message interface. See MsgBlock for details.
func (*MsgBlock) AddTransaction ¶
AddTransaction adds a transaction to the message.
func (*MsgBlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding blocks stored to disk, such as in a database, as opposed to decoding blocks from the wire.
func (*MsgBlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the wire.
func (*MsgBlock) ClearTransactions ¶
func (msg *MsgBlock) ClearTransactions()
ClearTransactions removes all transactions from the message.
func (*MsgBlock) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgBlock) Copy ¶
Copy creates a deep copy of a MsgBlock so that the original does not get modified when the copy is manipulated.
func (*MsgBlock) Deserialize ¶
Deserialize decodes a block from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) DeserializeNoWitness ¶
DeserializeNoWitness decodes a block from r into the receiver similar to Deserialize, however DeserializeWitness strips all (if any) witness data from the transactions within the block before encoding them.
func (*MsgBlock) DeserializeTxLoc ¶
DeserializeTxLoc decodes r in the same manner Deserialize does, but it takes a byte buffer instead of a generic reader and returns a slice containing the start and length of each transaction within the raw data that is being deserialized.
func (*MsgBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgBlock) Serialize ¶
Serialize encodes the block to w using a format that suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from BtcEncode in that BtcEncode encodes the block to the bitcoin wire protocol in order to be sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) SerializeNoWitness ¶
SerializeNoWitness encodes a block to w using an identical format to Serialize, with all (if any) witness data stripped from all transactions. This method is provided in additon to the regular Serialize, in order to allow one to selectively encode transaction witness data to non-upgraded peers which are unaware of the new encoding.
func (*MsgBlock) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the block, factoring in any witness data within transaction.
func (*MsgBlock) SerializeSizeStripped ¶
SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).
type MsgBlockBox ¶ added in v0.4.2
func (*MsgBlockBox) BtcDecode ¶ added in v0.4.2
func (b *MsgBlockBox) BtcDecode(r io.Reader, ver uint32, enc MessageEncoding) error
func (*MsgBlockBox) BtcEncode ¶ added in v0.4.2
func (b *MsgBlockBox) BtcEncode(w io.Writer, ver uint32, enc MessageEncoding) error
func (*MsgBlockBox) Command ¶ added in v0.4.2
func (b *MsgBlockBox) Command() string
func (*MsgBlockBox) MaxPayloadLength ¶ added in v0.4.2
func (b *MsgBlockBox) MaxPayloadLength(u uint32) uint32
type MsgCFCheckpt ¶
type MsgCFCheckpt struct { FilterType FilterType StopHash chainhash.Hash FilterHeaders []*chainhash.Hash }
MsgCFCheckpt implements the Message interface and represents a bitcoin cfcheckpt message. It is used to deliver committed filter header information in response to a getcfcheckpt message (MsgGetCFCheckpt). See MsgGetCFCheckpt for details on requesting the headers.
func NewMsgCFCheckpt ¶
func NewMsgCFCheckpt(filterType FilterType, stopHash *chainhash.Hash, headersCount int) *MsgCFCheckpt
NewMsgCFCheckpt returns a new bitcoin cfheaders message that conforms to the Message interface. See MsgCFCheckpt for details.
func (*MsgCFCheckpt) AddCFHeader ¶
func (msg *MsgCFCheckpt) AddCFHeader(header *chainhash.Hash) error
AddCFHeader adds a new committed filter header to the message.
func (*MsgCFCheckpt) BtcDecode ¶
func (msg *MsgCFCheckpt) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgCFCheckpt) BtcEncode ¶
func (msg *MsgCFCheckpt) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgCFCheckpt) Command ¶
func (msg *MsgCFCheckpt) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCFCheckpt) Deserialize ¶
func (msg *MsgCFCheckpt) Deserialize(r io.Reader) error
Deserialize decodes a filter header from r into the receiver using a format that is suitable for long-term storage such as a database. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored filter header at all. As of the time this comment was written, the encoded filter header is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgCFCheckpt) MaxPayloadLength ¶
func (msg *MsgCFCheckpt) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgCFHeaders ¶
type MsgCFHeaders struct { FilterType FilterType StopHash chainhash.Hash PrevFilterHeader chainhash.Hash FilterHashes []*chainhash.Hash }
MsgCFHeaders implements the Message interface and represents a bitcoin cfheaders message. It is used to deliver committed filter header information in response to a getcfheaders message (MsgGetCFHeaders). The maximum number of committed filter headers per message is currently 2000. See MsgGetCFHeaders for details on requesting the headers.
func NewMsgCFHeaders ¶
func NewMsgCFHeaders() *MsgCFHeaders
NewMsgCFHeaders returns a new bitcoin cfheaders message that conforms to the Message interface. See MsgCFHeaders for details.
func (*MsgCFHeaders) AddCFHash ¶
func (msg *MsgCFHeaders) AddCFHash(hash *chainhash.Hash) error
AddCFHash adds a new filter hash to the message.
func (*MsgCFHeaders) BtcDecode ¶
func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgCFHeaders) BtcEncode ¶
func (msg *MsgCFHeaders) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgCFHeaders) Command ¶
func (msg *MsgCFHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCFHeaders) Deserialize ¶
func (msg *MsgCFHeaders) Deserialize(r io.Reader) error
Deserialize decodes a filter header from r into the receiver using a format that is suitable for long-term storage such as a database. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored filter header at all. As of the time this comment was written, the encoded filter header is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgCFHeaders) MaxPayloadLength ¶
func (msg *MsgCFHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgCFilter ¶
type MsgCFilter struct { FilterType FilterType BlockHash chainhash.Hash Data []byte }
MsgCFilter implements the Message interface and represents a bitcoin cfilter message. It is used to deliver a committed filter in response to a getcfilters (MsgGetCFilters) message.
func NewMsgCFilter ¶
func NewMsgCFilter(filterType FilterType, blockHash *chainhash.Hash, data []byte) *MsgCFilter
NewMsgCFilter returns a new bitcoin cfilter message that conforms to the Message interface. See MsgCFilter for details.
func (*MsgCFilter) BtcDecode ¶
func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgCFilter) BtcEncode ¶
func (msg *MsgCFilter) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgCFilter) Command ¶
func (msg *MsgCFilter) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCFilter) Deserialize ¶
func (msg *MsgCFilter) Deserialize(r io.Reader) error
Deserialize decodes a filter from r into the receiver using a format that is suitable for long-term storage such as a database. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored filter at all. As of the time this comment was written, the encoded filter is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgCFilter) MaxPayloadLength ¶
func (msg *MsgCFilter) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFeeFilter ¶
type MsgFeeFilter struct {
MinFee int64
}
MsgFeeFilter implements the Message interface and represents a bitcoin feefilter message. It is used to request the receiving server does not announce any transactions below the specified minimum fee rate.
This message was not added until protocol versions starting with FeeFilterVersion.
func NewMsgFeeFilter ¶
func NewMsgFeeFilter(minfee int64) *MsgFeeFilter
NewMsgFeeFilter returns a new bitcoin feefilter message that conforms to the Message interface. See MsgFeeFilter for details.
func (*MsgFeeFilter) BtcDecode ¶
func (msg *MsgFeeFilter) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFeeFilter) BtcEncode ¶
func (msg *MsgFeeFilter) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFeeFilter) Command ¶
func (msg *MsgFeeFilter) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFeeFilter) MaxPayloadLength ¶
func (msg *MsgFeeFilter) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterAdd ¶
type MsgFilterAdd struct {
Data []byte
}
MsgFilterAdd implements the Message interface and represents a bitcoin filteradd message. It is used to add a data element to an existing Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgFilterAdd ¶
func NewMsgFilterAdd(data []byte) *MsgFilterAdd
NewMsgFilterAdd returns a new bitcoin filteradd message that conforms to the Message interface. See MsgFilterAdd for details.
func (*MsgFilterAdd) BtcDecode ¶
func (msg *MsgFilterAdd) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterAdd) BtcEncode ¶
func (msg *MsgFilterAdd) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterAdd) Command ¶
func (msg *MsgFilterAdd) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterAdd) MaxPayloadLength ¶
func (msg *MsgFilterAdd) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterClear ¶
type MsgFilterClear struct{}
MsgFilterClear implements the Message interface and represents a bitcoin filterclear message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version and has no payload.
func NewMsgFilterClear ¶
func NewMsgFilterClear() *MsgFilterClear
NewMsgFilterClear returns a new bitcoin filterclear message that conforms to the Message interface. See MsgFilterClear for details.
func (*MsgFilterClear) BtcDecode ¶
func (msg *MsgFilterClear) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterClear) BtcEncode ¶
func (msg *MsgFilterClear) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterClear) Command ¶
func (msg *MsgFilterClear) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterClear) MaxPayloadLength ¶
func (msg *MsgFilterClear) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterLoad ¶
type MsgFilterLoad struct { Filter []byte HashFuncs uint32 Tweak uint32 Flags BloomUpdateType }
MsgFilterLoad implements the Message interface and represents a bitcoin filterload message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgFilterLoad ¶
func NewMsgFilterLoad(filter []byte, hashFuncs uint32, tweak uint32, flags BloomUpdateType) *MsgFilterLoad
NewMsgFilterLoad returns a new bitcoin filterload message that conforms to the Message interface. See MsgFilterLoad for details.
func (*MsgFilterLoad) BtcDecode ¶
func (msg *MsgFilterLoad) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterLoad) BtcEncode ¶
func (msg *MsgFilterLoad) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterLoad) Command ¶
func (msg *MsgFilterLoad) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterLoad) MaxPayloadLength ¶
func (msg *MsgFilterLoad) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetAddr ¶
type MsgGetAddr struct {
ShardID uint32
}
MsgGetAddr implements the Message interface and represents a bitcoin getaddr message. It is used to request a list of known active peers on the network from a server to help identify potential nodes. The list is returned via one or more addr messages (MsgAddr).
This message has no payload.
func NewMsgGetAddr ¶
func NewMsgGetAddr() *MsgGetAddr
NewMsgGetAddr returns a new bitcoin getaddr message that conforms to the Message interface. See MsgGetAddr for details.
func (*MsgGetAddr) BtcDecode ¶
func (msg *MsgGetAddr) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetAddr) BtcEncode ¶
func (msg *MsgGetAddr) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetAddr) Command ¶
func (msg *MsgGetAddr) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetAddr) MaxPayloadLength ¶
func (msg *MsgGetAddr) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetBlocks ¶
type MsgGetBlocks struct { ProtocolVersion uint32 BlockLocatorMetas []*BlockLocatorMeta HashStop chainhash.Hash }
MsgGetBlocks implements the Message interface and represents a bitcoin getblocks message. It is used to request a list of blocks starting after the last known hash in the slice of block locator hashes. The list is returned via an inv message (MsgInv) and is limited by a specific hash to stop at or the maximum number of blocks per message, which is currently 500.
Set the HashStop field to the hash at which to stop and use AddBlockLocatorMeta to build up the list of block locator hashes.
The algorithm for building the block locator hashes should be to add the hashes in reverse order until you reach the genesis block. In order to keep the list of locator hashes to a reasonable number of entries, first add the most recent 10 block hashes, then double the step each loop iteration to exponentially decrease the number of hashes the further away from head and closer to the genesis block you get.
func NewMsgGetBlocks ¶
func NewMsgGetBlocks(hashStop *chainhash.Hash) *MsgGetBlocks
NewMsgGetBlocks returns a new bitcoin getblocks message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetBlocks) AddBlockLocatorMeta ¶ added in v0.4.2
func (msg *MsgGetBlocks) AddBlockLocatorMeta(hash *BlockLocatorMeta) error
AddBlockLocatorMeta adds a new block locator hash to the message.
func (*MsgGetBlocks) BtcDecode ¶
func (msg *MsgGetBlocks) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetBlocks) BtcEncode ¶
func (msg *MsgGetBlocks) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetBlocks) Command ¶
func (msg *MsgGetBlocks) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetBlocks) MaxPayloadLength ¶
func (msg *MsgGetBlocks) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetCFCheckpt ¶
type MsgGetCFCheckpt struct { FilterType FilterType StopHash chainhash.Hash }
MsgGetCFCheckpt is a request for filter headers at evenly spaced intervals throughout the blockchain history. It allows to set the FilterType field to get headers in the Chain of basic (0x00) or extended (0x01) headers.
func NewMsgGetCFCheckpt ¶
func NewMsgGetCFCheckpt(filterType FilterType, stopHash *chainhash.Hash) *MsgGetCFCheckpt
NewMsgGetCFCheckpt returns a new bitcoin getcfcheckpt message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetCFCheckpt) BtcDecode ¶
func (msg *MsgGetCFCheckpt) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetCFCheckpt) BtcEncode ¶
func (msg *MsgGetCFCheckpt) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFCheckpt) Command ¶
func (msg *MsgGetCFCheckpt) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFCheckpt) MaxPayloadLength ¶
func (msg *MsgGetCFCheckpt) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetCFHeaders ¶
type MsgGetCFHeaders struct { FilterType FilterType StartHeight uint32 StopHash chainhash.Hash }
MsgGetCFHeaders is a message similar to MsgGetHeaders, but for committed filter headers. It allows to set the FilterType field to get headers in the Chain of basic (0x00) or extended (0x01) headers.
func NewMsgGetCFHeaders ¶
func NewMsgGetCFHeaders(filterType FilterType, startHeight uint32, stopHash *chainhash.Hash) *MsgGetCFHeaders
NewMsgGetCFHeaders returns a new bitcoin getcfheader message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetCFHeaders) BtcDecode ¶
func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetCFHeaders) BtcEncode ¶
func (msg *MsgGetCFHeaders) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFHeaders) Command ¶
func (msg *MsgGetCFHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFHeaders) MaxPayloadLength ¶
func (msg *MsgGetCFHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetCFilters ¶
type MsgGetCFilters struct { FilterType FilterType StartHeight uint32 StopHash chainhash.Hash }
MsgGetCFilters implements the Message interface and represents a bitcoin getcfilters message. It is used to request committed filters for a range of blocks.
func NewMsgGetCFilters ¶
func NewMsgGetCFilters(filterType FilterType, startHeight uint32, stopHash *chainhash.Hash) *MsgGetCFilters
NewMsgGetCFilters returns a new bitcoin getcfilters message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetCFilters) BtcDecode ¶
func (msg *MsgGetCFilters) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetCFilters) BtcEncode ¶
func (msg *MsgGetCFilters) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFilters) Command ¶
func (msg *MsgGetCFilters) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFilters) MaxPayloadLength ¶
func (msg *MsgGetCFilters) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetData ¶
type MsgGetData struct {
InvList []*InvVect
}
MsgGetData implements the Message interface and represents a bitcoin getdata message. It is used to request data such as blocks and transactions from another server. It should be used in response to the inv (MsgInv) message to request the actual data referenced by each inventory vector the receiving server doesn't already have. Each message is limited to a maximum number of inventory vectors, which is currently 50,000. As a result, multiple messages must be used to request larger amounts of data.
Use the AddInvVect function to build up the list of inventory vectors when sending a getdata message to another server.
func NewMsgGetData ¶
func NewMsgGetData() *MsgGetData
NewMsgGetData returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetData for details.
func NewMsgGetDataSizeHint ¶
func NewMsgGetDataSizeHint(sizeHint uint) *MsgGetData
NewMsgGetDataSizeHint returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetData for details. This function differs from NewMsgGetData in that it allows a default allocation size for the backing array which houses the inventory vector list. This allows callers who know in advance how large the inventory list will grow to avoid the overhead of growing the internal backing array several times when appending large amounts of inventory vectors with AddInvVect. Note that the specified hint is just that - a hint that is used for the default allocation size. Adding more (or less) inventory vectors will still work properly. The size hint is limited to MaxInvPerMsg.
func (*MsgGetData) AddInvVect ¶
func (msg *MsgGetData) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgGetData) BtcDecode ¶
func (msg *MsgGetData) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetData) BtcEncode ¶
func (msg *MsgGetData) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetData) Command ¶
func (msg *MsgGetData) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetData) MaxPayloadLength ¶
func (msg *MsgGetData) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetHeaders ¶
type MsgGetHeaders struct { ProtocolVersion uint32 BlockLocatorMetas []*BlockLocatorMeta HashStop chainhash.Hash }
MsgGetHeaders implements the Message interface and represents a bitcoin getheaders message. It is used to request a list of block headers for blocks starting after the last known hash in the slice of block locator hashes. The list is returned via a headers message (MsgHeaders) and is limited by a specific hash to stop at or the maximum number of block headers per message, which is currently 2000.
Set the HashStop field to the hash at which to stop and use AddBlockLocatorMeta to build up the list of block locator hashes.
The algorithm for building the block locator hashes should be to add the hashes in reverse order until you reach the genesis block. In order to keep the list of locator hashes to a resonable number of entries, first add the most recent 10 block hashes, then double the step each loop iteration to exponentially decrease the number of hashes the further away from head and closer to the genesis block you get.
func NewMsgGetHeaders ¶
func NewMsgGetHeaders() *MsgGetHeaders
NewMsgGetHeaders returns a new bitcoin getheaders message that conforms to the Message interface. See MsgGetHeaders for details.
func (*MsgGetHeaders) AddBlockLocatorMeta ¶ added in v0.4.2
func (msg *MsgGetHeaders) AddBlockLocatorMeta(hash *BlockLocatorMeta) error
AddBlockLocatorMeta adds a new block locator hash to the message.
func (*MsgGetHeaders) BtcDecode ¶
func (msg *MsgGetHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetHeaders) BtcEncode ¶
func (msg *MsgGetHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetHeaders) Command ¶
func (msg *MsgGetHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetHeaders) MaxPayloadLength ¶
func (msg *MsgGetHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgHeaders ¶
type MsgHeaders struct {
Headers []HeaderBox
}
MsgHeaders implements the Message interface and represents a bitcoin headers message. It is used to deliver block header information in response to a getheaders message (MsgGetHeaders). The maximum number of block headers per message is currently 2000. See MsgGetHeaders for details on requesting the headers.
func NewMsgHeaders ¶
func NewMsgHeaders() *MsgHeaders
NewMsgHeaders returns a new bitcoin headers message that conforms to the Message interface. See MsgHeaders for details.
func (*MsgHeaders) AddBlockHeader ¶
func (msg *MsgHeaders) AddBlockHeader(bh BlockHeader, mmrRoot chainhash.Hash) error
AddBlockHeader adds a new block header to the message.
func (*MsgHeaders) BtcDecode ¶
func (msg *MsgHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgHeaders) BtcEncode ¶
func (msg *MsgHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgHeaders) Command ¶
func (msg *MsgHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgHeaders) MaxPayloadLength ¶
func (msg *MsgHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgInv ¶
type MsgInv struct {
InvList []*InvVect
}
MsgInv implements the Message interface and represents a bitcoin inv message. It is used to advertise a server's known data such as blocks and transactions through inventory vectors. It may be sent unsolicited to inform other peers of the data or in response to a getblocks message (MsgGetBlocks). Each message is limited to a maximum number of inventory vectors, which is currently 50,000.
Use the AddInvVect function to build up the list of inventory vectors when sending an inv message to another server.
func NewMsgInv ¶
func NewMsgInv() *MsgInv
NewMsgInv returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func NewMsgInvSizeHint ¶
NewMsgInvSizeHint returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details. This function differs from NewMsgInv in that it allows a default allocation size for the backing array which houses the inventory vector list. This allows callers who know in advance how large the inventory list will grow to avoid the overhead of growing the internal backing array several times when appending large amounts of inventory vectors with AddInvVect. Note that the specified hint is just that - a hint that is used for the default allocation size. Adding more (or less) inventory vectors will still work properly. The size hint is limited to MaxInvPerMsg.
func (*MsgInv) AddInvVect ¶
AddInvVect adds an inventory vector to the message.
func (*MsgInv) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgInv) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgInv) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgInv) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgMemPool ¶
type MsgMemPool struct{}
MsgMemPool implements the Message interface and represents a bitcoin mempool message. It is used to request a list of transactions still in the active memory pool of a relay.
This message has no payload and was not added until protocol versions starting with BIP0035Version.
func NewMsgMemPool ¶
func NewMsgMemPool() *MsgMemPool
NewMsgMemPool returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgMemPool) BtcDecode ¶
func (msg *MsgMemPool) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMemPool) BtcEncode ¶
func (msg *MsgMemPool) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgMemPool) Command ¶
func (msg *MsgMemPool) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMemPool) MaxPayloadLength ¶
func (msg *MsgMemPool) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgMerkleBlock ¶
type MsgMerkleBlock struct { Header BlockHeader Transactions uint32 Hashes []*chainhash.Hash Flags []byte }
MsgMerkleBlock implements the Message interface and represents a bitcoin merkleblock message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgMerkleBlock ¶
func NewMsgMerkleBlock(bh BlockHeader) *MsgMerkleBlock
NewMsgMerkleBlock returns a new bitcoin merkleblock message that conforms to the Message interface. See MsgMerkleBlock for details.
func (*MsgMerkleBlock) AddTxHash ¶
func (msg *MsgMerkleBlock) AddTxHash(hash *chainhash.Hash) error
AddTxHash adds a new transaction hash to the message.
func (*MsgMerkleBlock) BtcDecode ¶
func (msg *MsgMerkleBlock) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) (err error)
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMerkleBlock) BtcEncode ¶
func (msg *MsgMerkleBlock) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgMerkleBlock) Command ¶
func (msg *MsgMerkleBlock) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMerkleBlock) MaxPayloadLength ¶
func (msg *MsgMerkleBlock) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgNotFound ¶
type MsgNotFound struct {
InvList []*InvVect
}
MsgNotFound defines a bitcoin notfound message which is sent in response to a getdata message if any of the requested data in not available on the server. Each message is limited to a maximum number of inventory vectors, which is currently 50,000.
Use the AddInvVect function to build up the list of inventory vectors when sending a notfound message to another server.
func NewMsgNotFound ¶
func NewMsgNotFound() *MsgNotFound
NewMsgNotFound returns a new bitcoin notfound message that conforms to the Message interface. See MsgNotFound for details.
func (*MsgNotFound) AddInvVect ¶
func (msg *MsgNotFound) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgNotFound) BtcDecode ¶
func (msg *MsgNotFound) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgNotFound) BtcEncode ¶
func (msg *MsgNotFound) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgNotFound) Command ¶
func (msg *MsgNotFound) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgNotFound) MaxPayloadLength ¶
func (msg *MsgNotFound) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgPing ¶
type MsgPing struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 }
MsgPing implements the Message interface and represents a bitcoin ping message.
For versions BIP0031Version and earlier, it is used primarily to confirm that a connection is still valid. A transmission error is typically interpreted as a closed connection and that the server should be removed. For versions AFTER BIP0031Version it contains an identifier which can be returned in the pong message to determine network timing.
The payload for this message just consists of a nonce used for identifying it later.
func NewMsgPing ¶
NewMsgPing returns a new bitcoin ping message that conforms to the Message interface. See MsgPing for details.
func (*MsgPing) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPing) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgPing) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPing) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgPong ¶
type MsgPong struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 }
MsgPong implements the Message interface and represents a bitcoin pong message which is used primarily to confirm that a connection is still valid in response to a bitcoin ping message (MsgPing).
This message was not added until protocol versions AFTER BIP0031Version.
func NewMsgPong ¶
NewMsgPong returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgPong) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPong) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgPong) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPong) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgPortRedirect ¶
type MsgPortRedirect struct { ShardID uint32 // Port the server is using. Port uint32 // IP address of the server. IP net.IP }
func NewMsgPortRedirect ¶
func NewMsgPortRedirect(shardID, port uint32, ip net.IP) *MsgPortRedirect
func (*MsgPortRedirect) BtcDecode ¶
func (m *MsgPortRedirect) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
func (*MsgPortRedirect) BtcEncode ¶
func (m *MsgPortRedirect) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
func (*MsgPortRedirect) Command ¶
func (m *MsgPortRedirect) Command() string
func (*MsgPortRedirect) MaxPayloadLength ¶
func (m *MsgPortRedirect) MaxPayloadLength(uint32) uint32
type MsgReject ¶
type MsgReject struct { // Cmd is the command for the message which was rejected such as // as CmdBlock or CmdTx. This can be obtained from the Command function // of a Message. Cmd string // RejectCode is a code indicating why the command was rejected. It // is encoded as a uint8 on the wire. Code RejectCode // Reason is a human-readable string with specific details (over and // above the reject code) about why the command was rejected. Reason string // Hash identifies a specific block or transaction that was rejected // and therefore only applies the MsgBlock and MsgTx messages. Hash chainhash.Hash }
MsgReject implements the Message interface and represents a bitcoin reject message.
This message was not added until protocol version RejectVersion.
func NewMsgReject ¶
func NewMsgReject(command string, code RejectCode, reason string) *MsgReject
NewMsgReject returns a new bitcoin reject message that conforms to the Message interface. See MsgReject for details.
func (*MsgReject) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgReject) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgReject) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgReject) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgSendHeaders ¶
type MsgSendHeaders struct{}
MsgSendHeaders implements the Message interface and represents a bitcoin sendheaders message. It is used to request the server send block headers rather than inventory vectors.
This message has no payload and was not added until protocol versions starting with SendHeadersVersion.
func NewMsgSendHeaders ¶
func NewMsgSendHeaders() *MsgSendHeaders
NewMsgSendHeaders returns a new bitcoin sendheaders message that conforms to the Message interface. See MsgSendHeaders for details.
func (*MsgSendHeaders) BtcDecode ¶
func (msg *MsgSendHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgSendHeaders) BtcEncode ¶
func (msg *MsgSendHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgSendHeaders) Command ¶
func (msg *MsgSendHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgSendHeaders) MaxPayloadLength ¶
func (msg *MsgSendHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgTx ¶
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.
func NewMsgTx ¶
NewMsgTx returns a new bitcoin tx message that conforms to the Message interface. The return instance has a default version of TxVersion and there are no transaction inputs or outputs. Also, the lock time is set to zero to indicate the transaction is valid immediately as opposed to some time in future.
func (*MsgTx) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding transactions stored to disk, such as in a database, as opposed to decoding transactions from the wire.
func (*MsgTx) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding transactions to be stored to disk, such as in a database, as opposed to encoding transactions for the wire.
func (*MsgTx) CleanVersion ¶
func (*MsgTx) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgTx) Copy ¶
Copy creates a deep copy of a transaction so that the original does not get modified when the copy is manipulated.
func (*MsgTx) Deserialize ¶
Deserialize decodes a transaction from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the transaction. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored transaction at all. As of the time this comment was written, the encoded transaction is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgTx) DeserializeNoWitness ¶
DeserializeNoWitness decodes a transaction from r into the receiver, where the transaction encoding format within r MUST NOT utilize the new serialization format created to encode transaction bearing witness data within inputs.
func (*MsgTx) HasWitness ¶
HasWitness returns false if none of the inputs within the transaction contain witness data, true false otherwise.
func (*MsgTx) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgTx) PkScriptLocs ¶
PkScriptLocs returns a slice containing the start of each public key script within the raw serialized transaction. The caller can easily obtain the length of each script by using len on the script available via the appropriate transaction output entry.
func (*MsgTx) Serialize ¶
Serialize encodes the transaction to w using a format that suitable for long-term storage such as a database while respecting the Version field in the transaction. This function differs from BtcEncode in that BtcEncode encodes the transaction to the bitcoin wire protocol in order to be sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored transaction at all. As of the time this comment was written, the encoded transaction is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgTx) SerializeNoWitness ¶
SerializeNoWitness encodes the transaction to w in an identical manner to Serialize, however even if the source transaction has inputs with witness data, the old serialization format will still be used.
func (*MsgTx) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction.
func (*MsgTx) SerializeSizeStripped ¶
SerializeSizeStripped returns the number of bytes it would take to serialize the transaction, excluding any included witness data.
func (*MsgTx) SerializeToHex ¶ added in v0.3.8
func (*MsgTx) WitnessHash ¶
WitnessHash generates the hash of the transaction serialized according to the new witness serialization defined in BIP0141 and BIP0144. The final output is used within the Segregated Witness commitment of all the witnesses within a block. If a transaction has no witness data, then the witness hash, is the same as its txid.
type MsgVerAck ¶
type MsgVerAck struct{}
MsgVerAck defines a bitcoin verack message which is used for a server to acknowledge a version message (MsgVersion) after it has used the information to negotiate parameters. It implements the Message interface.
This message has no payload.
func NewMsgVerAck ¶
func NewMsgVerAck() *MsgVerAck
NewMsgVerAck returns a new jaxnet verack message that conforms to the Message interface.
func (*MsgVerAck) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgVerAck) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgVerAck) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVerAck) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgVersion ¶
type MsgVersion struct { // Version of the protocol the node is using. ProtocolVersion int32 IsBeacon bool Shard uint32 // Bitfield which identifies the enabled services. Services ServiceFlag // Time the message was generated. This is encoded as an int64 on the wire. Timestamp time.Time // Address of the remote server. AddrYou NetAddress // Address of the local server. AddrMe NetAddress // Unique value associated with message that is used to detect self // connections. Nonce uint64 // The user agent that generated messsage. This is a encoded as a varString // on the wire. This has a max length of MaxUserAgentLen. UserAgent string // Last block seen by the generator of the version message. LastBlock int32 ChainWeight uint64 // Don't announce transactions to server. DisableRelayTx bool }
MsgVersion implements the Message interface and represents a bitcoin version message. It is used for a server to advertise itself as soon as an outbound connection is made. The remote server then uses this information along with its own to negotiate. The remote server must then respond with a version message of its own containing the negotiated values followed by a verack message (MsgVerAck). This exchange must take place before any further communication is allowed to proceed.
func NewMsgVersion ¶
func NewMsgVersion(chain HeaderConstructor, me *NetAddress, you *NetAddress, nonce uint64, lastBlock int32, chainWeight uint64) *MsgVersion
NewMsgVersion returns a new bitcoin version message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgVersion) AddService ¶
func (msg *MsgVersion) AddService(service ServiceFlag)
AddService adds service as a supported service by the server generating the message.
func (*MsgVersion) AddUserAgent ¶
func (msg *MsgVersion) AddUserAgent(name string, version string, comments ...string) error
AddUserAgent adds a user agent to the user agent string for the version message. The version string is not defined to any strict format, although it is recommended to use the form "major.minor.revision" e.g. "2.6.41".
func (*MsgVersion) BtcDecode ¶
func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. The version message is special in that the protocol version hasn't been negotiated yet. As a result, the pver field is ignored and any fields which are added in new versions are optional. This also mean that r must be a *bytes.Buffer so the number of remaining bytes can be ascertained.
This is part of the Message interface implementation.
func (*MsgVersion) BtcEncode ¶
func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgVersion) Command ¶
func (*MsgVersion) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVersion) HasService ¶
func (msg *MsgVersion) HasService(service ServiceFlag) bool
HasService returns whether the specified service is supported by the server that generated the message.
func (*MsgVersion) MaxPayloadLength ¶
func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type NetAddress ¶
type NetAddress struct { // Last time the address was seen. This is, unfortunately, encoded as a // uint32 on the wire and therefore is limited to 2106. This field is // not present in the bitcoin version message (MsgVersion) nor was it // added until protocol version >= NetAddressTimeVersion. Timestamp time.Time // Bitfield which identifies the services supported by the address. Services ServiceFlag // IP address of the server. IP net.IP // Port the server is using. This is encoded in big endian on the wire // which differs from most everything else. Port uint16 }
NetAddress defines information about a server on the network including the time it was last seen, the services it supports, its IP address, and port.
func NewNetAddress ¶
func NewNetAddress(addr *net.TCPAddr, services ServiceFlag) *NetAddress
NewNetAddress returns a new NetAddress using the provided TCP address and supported services with defaults for the remaining fields.
func NewNetAddressIPPort ¶
func NewNetAddressIPPort(ip net.IP, port uint16, services ServiceFlag) *NetAddress
NewNetAddressIPPort returns a new NetAddress using the provided IP, port, and supported services with defaults for the remaining fields.
func NewNetAddressTimestamp ¶
func NewNetAddressTimestamp( timestamp time.Time, services ServiceFlag, ip net.IP, port uint16) *NetAddress
NewNetAddressTimestamp returns a new NetAddress using the provided timestamp, IP, port, and supported services. The timestamp is rounded to single second precision.
func (*NetAddress) AddService ¶
func (na *NetAddress) AddService(service ServiceFlag)
AddService adds service as a supported service by the server generating the message.
func (*NetAddress) HasService ¶
func (na *NetAddress) HasService(service ServiceFlag) bool
HasService returns whether the specified service is supported by the address.
type OutPoint ¶
OutPoint defines a bitcoin data type that is used to track previous transaction outputs.
func NewOutPoint ¶
NewOutPoint returns a new bitcoin transaction outpoint point with the provided hash and index.
type RejectCode ¶
type RejectCode uint8
RejectCode represents a numeric value by which a remote server indicates why a message was rejected.
const ( RejectMalformed RejectCode = 0x01 RejectInvalid RejectCode = 0x10 RejectObsolete RejectCode = 0x11 RejectDuplicate RejectCode = 0x12 RejectNonstandard RejectCode = 0x40 RejectDust RejectCode = 0x41 RejectInsufficientFee RejectCode = 0x42 RejectCheckpoint RejectCode = 0x43 )
These constants define the various supported reject codes.
func (RejectCode) String ¶
func (code RejectCode) String() string
String returns the RejectCode in human-readable form.
type ServiceFlag ¶
type ServiceFlag uint64
ServiceFlag identifies services supported by a jaxnet server.
const ( // SFNodeNetwork is a flag used to indicate a server is a full node. SFNodeNetwork ServiceFlag = 1 << iota // SFNodeGetUTXO is a flag used to indicate a server supports the // getutxos and utxos commands (BIP0064). SFNodeGetUTXO // SFNodeBloom is a flag used to indicate a server supports bloom // filtering. SFNodeBloom // SFNodeWitness is a flag used to indicate a server supports blocks // and transactions including witness data (BIP0144). SFNodeWitness // SFNodeXthin is a flag used to indicate a server supports xthin blocks. SFNodeXthin // SFNodeBit5 is a flag used to indicate a server supports a service // defined by bit 5. SFNodeBit5 // SFNodeCF is a flag used to indicate a server supports committed // filters (CFs). SFNodeCF // SFNode2X is a flag used to indicate a server is running the Segwit2X // software. SFNode2X )
func (ServiceFlag) String ¶
func (f ServiceFlag) String() string
String returns the ServiceFlag in human-readable form.
type ShardAddress ¶
type ShardAddress struct { ShardID uint32 Address *NetAddress }
ShardAddress ....
type ShardHeader ¶
type ShardHeader struct {
// contains filtered or unexported fields
}
ShardHeader defines information about a block and is used in the bitcoin block (MsgBlock) and headers (MsgHeaders) messages.
func EmptyShardHeader ¶
func EmptyShardHeader() *ShardHeader
func NewShardBlockHeader ¶
func NewShardBlockHeader(height int32, blocksMerkleMountainRoot, merkleRootHash chainhash.Hash, bits uint32, weight uint64, bcHeader BeaconHeader, aux CoinbaseAux) *ShardHeader
NewShardBlockHeader returns a new BlockHeader using the provided version, previous block hash, merkle root hash, difficulty bits, and nonce used to generate the block with defaults for the remaining fields.
func (*ShardHeader) BeaconCoinbaseAux ¶ added in v0.4.0
func (h *ShardHeader) BeaconCoinbaseAux() *CoinbaseAux
func (*ShardHeader) BeaconHeader ¶
func (h *ShardHeader) BeaconHeader() *BeaconHeader
func (*ShardHeader) Bits ¶
func (h *ShardHeader) Bits() uint32
func (*ShardHeader) BlockHash ¶
func (h *ShardHeader) BlockHash() chainhash.Hash
BlockHash computes the block identifier hash for the BeaconChain Container for the given block.
func (*ShardHeader) BtcDecode ¶
func (h *ShardHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding block headers stored to disk, such as in a database, as opposed to decoding block headers from the wire.
func (*ShardHeader) BtcEncode ¶
func (h *ShardHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding block headers to be stored to disk, such as in a database, as opposed to encoding block headers for the wire.
func (*ShardHeader) ChainWeight ¶ added in v0.4.2
func (h *ShardHeader) ChainWeight() uint64
func (*ShardHeader) Copy ¶
func (h *ShardHeader) Copy() BlockHeader
Copy creates a deep copy of a BlockHeader so that the original does not get modified when the copy is manipulated.
func (*ShardHeader) ExclusiveHash ¶ added in v0.4.0
func (h *ShardHeader) ExclusiveHash() chainhash.Hash
ExclusiveHash computes hash of header data without any extra aux (beacon & btc).
func (*ShardHeader) Height ¶ added in v0.4.2
func (h *ShardHeader) Height() int32
func (*ShardHeader) K ¶
func (h *ShardHeader) K() uint32
func (*ShardHeader) MaxLength ¶
func (h *ShardHeader) MaxLength() int
func (*ShardHeader) MergeMiningNumber ¶
func (h *ShardHeader) MergeMiningNumber() uint32
func (*ShardHeader) MergeMiningRoot ¶
func (h *ShardHeader) MergeMiningRoot() chainhash.Hash
func (*ShardHeader) MerkleRoot ¶
func (h *ShardHeader) MerkleRoot() chainhash.Hash
func (*ShardHeader) Nonce ¶
func (h *ShardHeader) Nonce() uint32
func (*ShardHeader) PoWHash ¶
func (h *ShardHeader) PoWHash() chainhash.Hash
PoWHash computes the hash for block that will be used to check ProofOfWork.
func (*ShardHeader) PrevBlocksMMRRoot ¶ added in v0.4.2
func (h *ShardHeader) PrevBlocksMMRRoot() chainhash.Hash
func (*ShardHeader) Read ¶
func (h *ShardHeader) Read(r io.Reader) error
Deserialize decodes a block ShardHeader from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*ShardHeader) Serialize ¶
func (h *ShardHeader) Serialize(w io.Writer) error
Serialize encodes a block ShardHeader from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*ShardHeader) SetBeaconHeader ¶
func (h *ShardHeader) SetBeaconHeader(bh *BeaconHeader, beaconAux CoinbaseAux)
func (*ShardHeader) SetBits ¶
func (h *ShardHeader) SetBits(bits uint32)
func (*ShardHeader) SetK ¶
func (h *ShardHeader) SetK(value uint32)
func (*ShardHeader) SetMergeMiningNumber ¶
func (h *ShardHeader) SetMergeMiningNumber(n uint32)
func (*ShardHeader) SetMergeMiningRoot ¶
func (h *ShardHeader) SetMergeMiningRoot(value chainhash.Hash)
func (*ShardHeader) SetMerkleRoot ¶
func (h *ShardHeader) SetMerkleRoot(hash chainhash.Hash)
func (*ShardHeader) SetNonce ¶
func (h *ShardHeader) SetNonce(n uint32)
func (*ShardHeader) SetPrevBlocksMMRRoot ¶ added in v0.4.2
func (h *ShardHeader) SetPrevBlocksMMRRoot(root chainhash.Hash)
func (*ShardHeader) SetShardMerkleProof ¶ added in v0.4.0
func (h *ShardHeader) SetShardMerkleProof(value []chainhash.Hash)
func (*ShardHeader) SetTimestamp ¶
func (h *ShardHeader) SetTimestamp(t time.Time)
func (*ShardHeader) SetVoteK ¶
func (h *ShardHeader) SetVoteK(value uint32)
func (*ShardHeader) ShardExclusiveBlockHash ¶ added in v0.4.0
func (h *ShardHeader) ShardExclusiveBlockHash() chainhash.Hash
DEPRECATED ShardExclusiveBlockHash computes the block identifier hash for the given ShardHeader.
func (*ShardHeader) ShardMerkleProof ¶ added in v0.4.0
func (h *ShardHeader) ShardMerkleProof() []chainhash.Hash
func (*ShardHeader) Timestamp ¶
func (h *ShardHeader) Timestamp() time.Time
func (*ShardHeader) UpdateCoinbaseScript ¶
func (h *ShardHeader) UpdateCoinbaseScript(coinbaseScript []byte)
UpdateCoinbaseScript sets new coinbase script, rebuilds BTCBlockAux.TxMerkleProof and recalculates the BTCBlockAux.MerkleRoot with the updated extra nonce.
func (*ShardHeader) Version ¶
func (h *ShardHeader) Version() BVersion
func (*ShardHeader) VoteK ¶
func (h *ShardHeader) VoteK() uint32
type ShardHeaderConstructor ¶
type ShardHeaderConstructor struct{ ID uint32 }
func (ShardHeaderConstructor) BlockHeaderOverhead ¶
func (b ShardHeaderConstructor) BlockHeaderOverhead() int
func (ShardHeaderConstructor) EmptyHeader ¶
func (b ShardHeaderConstructor) EmptyHeader() BlockHeader
func (ShardHeaderConstructor) IsBeacon ¶
func (b ShardHeaderConstructor) IsBeacon() bool
func (ShardHeaderConstructor) MaxBlockHeaderPayload ¶
func (b ShardHeaderConstructor) MaxBlockHeaderPayload() int
func (ShardHeaderConstructor) ShardID ¶
func (b ShardHeaderConstructor) ShardID() uint32
type TxIn ¶
type TxIn struct { PreviousOutPoint OutPoint SignatureScript []byte Witness TxWitness Sequence uint32 // Age is an internal field that needed for runtime processing, // it will be ignored during serialization and hashing. Age int32 }
TxIn defines a bitcoin transaction input.
func NewTxIn ¶
NewTxIn returns a new bitcoin transaction input with the provided previous outpoint point and signature script with a default sequence of MaxTxInSequenceNum.
func (*TxIn) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction input.
type TxLoc ¶
TxLoc holds locator data for the offset and length of where a transaction is located within a MsgBlock data buffer.
type TxOut ¶
TxOut defines a bitcoin transaction output.
func NewTxOut ¶
NewTxOut returns a new bitcoin transaction output with the provided transaction value and public key script.
func (*TxOut) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the 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.
func (TxWitness) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction input's witness.
type Uint32Time ¶ added in v0.4.2
Uint32Time represents a unix timestamp encoded with a uint32. It is used as a way to signal the readElement function how to decode a timestamp into a Go time.Time since it is otherwise ambiguous.
Source Files ¶
- block_header.go
- block_header_beacon.go
- block_header_btc.go
- block_header_shard.go
- bloom.go
- common.go
- doc.go
- encoder.go
- encoder.list.go
- error.go
- invvect.go
- message.go
- msg_addr.go
- msg_alert.go
- msg_block.go
- msg_cfcheckpt.go
- msg_cfheaders.go
- msg_cfilter.go
- msg_ead_info.go
- msg_feefilter.go
- msg_filteradd.go
- msg_filterclear.go
- msg_filterload.go
- msg_getaddr.go
- msg_getblocks.go
- msg_getcfcheckpt.go
- msg_getcfheaders.go
- msg_getcfilters.go
- msg_getdata.go
- msg_getheaders.go
- msg_headers.go
- msg_inv.go
- msg_mempool.go
- msg_merkleblock.go
- msg_notfound.go
- msg_ping.go
- msg_pong.go
- msg_reject.go
- msg_sendheaders.go
- msg_tx.go
- msg_verack.go
- msg_version.go
- net_address.go
- net_type.go
- protocol.go