Documentation ¶
Overview ¶
Package wire implements the Decred wire protocol.
For the complete details of the Decred 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 Decred 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.
Decred Message Overview ¶
The Decred protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which Decred 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 Decred 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 Decred messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the wire using Decred 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 Decred 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 Decred 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 Decred 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 peer 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.
Decred Network ¶
The Decred network is a magic number which is used to identify the start of a message and which Decred network the message applies to. This package provides the following constants:
wire.MainNet wire.TestNet3 (Test network version 3) wire.SimNet (Simulation test network) wire.RegNet (Regression test network)
Determining Message Type ¶
As discussed in the Decred message overview section, this package reads and writes Decred 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 Decred 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 Decred peer. Example syntax is:
// Reads and validates the next Decred message from conn using the // protocol version pver and the Decred 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 Decred 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 Decred peer. Example syntax to request addresses from a remote peer is:
// Create a new getaddr Decred message. msg := wire.NewMsgGetAddr() // Writes a Decred message msg to conn using the protocol version // pver, and the Decred network btcnet. The return is a possible // error. err := wire.WriteMessage(conn, msg, pver, btcnet) if err != nil { // Log and handle the error }
Errors ¶
The 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 MaxTxPerTxTree(pver uint32) uint64
- func RandomUint64() (uint64, error)
- func ReadAsciiVarString(r io.Reader, pver uint32, maxAllowed uint64) (string, error)
- func ReadOutPoint(r io.Reader, pver uint32, version uint16, op *OutPoint) 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 VarIntSerializeSize(val uint64) int
- func WriteMessage(w io.Writer, msg Message, pver uint32, dcrnet CurrencyNet) error
- func WriteMessageN(w io.Writer, msg Message, pver uint32, dcrnet CurrencyNet) (int, error)
- func WriteOutPoint(w io.Writer, pver uint32, version uint16, op *OutPoint) error
- func WriteVarBytes(w io.Writer, pver uint32, bytes []byte) error
- func WriteVarInt(w io.Writer, pver uint32, val uint64) error
- func WriteVarString(w io.Writer, pver uint32, str string) error
- type BlockHeader
- func (h *BlockHeader) BlockHash() chainhash.Hash
- func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32) error
- func (h *BlockHeader) BtcEncode(w io.Writer, pver uint32) error
- func (h *BlockHeader) Bytes() ([]byte, error)
- func (h *BlockHeader) Deserialize(r io.Reader) error
- func (h *BlockHeader) FromBytes(b []byte) error
- func (h *BlockHeader) PowHashV1() chainhash.Hash
- func (h *BlockHeader) PowHashV2() chainhash.Hash
- func (h *BlockHeader) Serialize(w io.Writer) error
- type CurrencyNet
- type ErrorCode
- type FilterType
- type InvType
- type InvVect
- type Message
- type MessageError
- type MixPairReqUTXO
- type MixVect
- type MsgAddr
- func (msg *MsgAddr) AddAddress(na *NetAddress) error
- func (msg *MsgAddr) AddAddresses(netAddrs ...*NetAddress) error
- func (msg *MsgAddr) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgAddr) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgAddr) ClearAddresses()
- func (msg *MsgAddr) Command() string
- func (msg *MsgAddr) MaxPayloadLength(pver uint32) uint32
- type MsgBlock
- func (msg *MsgBlock) AddSTransaction(tx *MsgTx) error
- func (msg *MsgBlock) AddTransaction(tx *MsgTx) error
- func (msg *MsgBlock) BlockHash() chainhash.Hash
- func (msg *MsgBlock) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgBlock) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgBlock) Bytes() ([]byte, error)
- func (msg *MsgBlock) ClearSTransactions()
- func (msg *MsgBlock) ClearTransactions()
- func (msg *MsgBlock) Command() string
- func (msg *MsgBlock) Deserialize(r io.Reader) error
- func (msg *MsgBlock) DeserializeTxLoc(r *bytes.Buffer) ([]TxLoc, []TxLoc, error)
- func (msg *MsgBlock) FromBytes(b []byte) error
- func (msg *MsgBlock) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgBlock) PowHashV1() chainhash.Hash
- func (msg *MsgBlock) PowHashV2() chainhash.Hash
- func (msg *MsgBlock) STxHashes() []chainhash.Hash
- func (msg *MsgBlock) Serialize(w io.Writer) error
- func (msg *MsgBlock) SerializeSize() int
- func (msg *MsgBlock) TxHashes() []chainhash.Hash
- type MsgCFHeadersdeprecated
- func NewMsgCFHeaders() *MsgCFHeadersdeprecated
- func (msg *MsgCFHeaders) AddCFHeader(headerHash *chainhash.Hash) error
- func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgCFHeaders) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgCFHeaders) Command() string
- func (msg *MsgCFHeaders) Deserialize(r io.Reader) error
- func (msg *MsgCFHeaders) MaxPayloadLength(pver uint32) uint32
- type MsgCFTypesdeprecated
- type MsgCFilterdeprecated
- type MsgCFilterV2
- type MsgCFiltersV2
- type MsgFeeFilter
- type MsgGetAddr
- type MsgGetBlocks
- func (msg *MsgGetBlocks) AddBlockLocatorHash(hash *chainhash.Hash) error
- func (msg *MsgGetBlocks) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetBlocks) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetBlocks) Command() string
- func (msg *MsgGetBlocks) MaxPayloadLength(pver uint32) uint32
- type MsgGetCFHeadersdeprecated
- func (msg *MsgGetCFHeaders) AddBlockLocatorHash(hash *chainhash.Hash) error
- func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetCFHeaders) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetCFHeaders) Command() string
- func (msg *MsgGetCFHeaders) MaxPayloadLength(pver uint32) uint32
- type MsgGetCFTypesdeprecated
- func NewMsgGetCFTypes() *MsgGetCFTypesdeprecated
- type MsgGetCFilterdeprecated
- type MsgGetCFilterV2
- type MsgGetCFsV2
- type MsgGetData
- type MsgGetHeaders
- func (msg *MsgGetHeaders) AddBlockLocatorHash(hash *chainhash.Hash) error
- func (msg *MsgGetHeaders) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetHeaders) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetHeaders) Command() string
- func (msg *MsgGetHeaders) MaxPayloadLength(pver uint32) uint32
- type MsgGetInitState
- func (msg *MsgGetInitState) AddType(typ string) error
- func (msg *MsgGetInitState) AddTypes(types ...string) error
- func (msg *MsgGetInitState) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetInitState) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetInitState) Command() string
- func (msg *MsgGetInitState) MaxPayloadLength(pver uint32) uint32
- type MsgGetMiningState
- type MsgHeaders
- type MsgInitState
- func (msg *MsgInitState) AddBlockHash(hash *chainhash.Hash) error
- func (msg *MsgInitState) AddTSpendHash(hash *chainhash.Hash) error
- func (msg *MsgInitState) AddVoteHash(hash *chainhash.Hash) error
- func (msg *MsgInitState) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgInitState) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgInitState) Command() string
- func (msg *MsgInitState) MaxPayloadLength(pver uint32) uint32
- type MsgInv
- type MsgMemPool
- type MsgMiningState
- func (msg *MsgMiningState) AddBlockHash(hash *chainhash.Hash) error
- func (msg *MsgMiningState) AddVoteHash(hash *chainhash.Hash) error
- func (msg *MsgMiningState) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMiningState) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMiningState) Command() string
- func (msg *MsgMiningState) MaxPayloadLength(pver uint32) uint32
- type MsgMixCiphertexts
- func (msg *MsgMixCiphertexts) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixCiphertexts) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixCiphertexts) Command() string
- func (msg *MsgMixCiphertexts) GetRun() uint32
- func (msg *MsgMixCiphertexts) Hash() chainhash.Hash
- func (msg *MsgMixCiphertexts) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixCiphertexts) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixCiphertexts) Pub() []byte
- func (msg *MsgMixCiphertexts) Sid() []byte
- func (msg *MsgMixCiphertexts) Sig() []byte
- func (msg *MsgMixCiphertexts) WriteHash(h hash.Hash)
- func (msg *MsgMixCiphertexts) WriteSignedData(h hash.Hash)
- type MsgMixConfirm
- func (msg *MsgMixConfirm) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixConfirm) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixConfirm) Command() string
- func (msg *MsgMixConfirm) GetRun() uint32
- func (msg *MsgMixConfirm) Hash() chainhash.Hash
- func (msg *MsgMixConfirm) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixConfirm) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixConfirm) Pub() []byte
- func (msg *MsgMixConfirm) Sid() []byte
- func (msg *MsgMixConfirm) Sig() []byte
- func (msg *MsgMixConfirm) WriteHash(h hash.Hash)
- func (msg *MsgMixConfirm) WriteSignedData(h hash.Hash)
- type MsgMixDCNet
- func (msg *MsgMixDCNet) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixDCNet) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixDCNet) Command() string
- func (msg *MsgMixDCNet) GetRun() uint32
- func (msg *MsgMixDCNet) Hash() chainhash.Hash
- func (msg *MsgMixDCNet) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixDCNet) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixDCNet) Pub() []byte
- func (msg *MsgMixDCNet) Sid() []byte
- func (msg *MsgMixDCNet) Sig() []byte
- func (msg *MsgMixDCNet) WriteHash(h hash.Hash)
- func (msg *MsgMixDCNet) WriteSignedData(h hash.Hash)
- type MsgMixFactoredPoly
- func (msg *MsgMixFactoredPoly) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixFactoredPoly) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixFactoredPoly) Command() string
- func (msg *MsgMixFactoredPoly) GetRun() uint32
- func (msg *MsgMixFactoredPoly) Hash() chainhash.Hash
- func (msg *MsgMixFactoredPoly) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixFactoredPoly) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixFactoredPoly) Pub() []byte
- func (msg *MsgMixFactoredPoly) Sid() []byte
- func (msg *MsgMixFactoredPoly) Sig() []byte
- func (msg *MsgMixFactoredPoly) WriteHash(h hash.Hash)
- func (msg *MsgMixFactoredPoly) WriteSignedData(h hash.Hash)
- type MsgMixKeyExchange
- func (msg *MsgMixKeyExchange) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixKeyExchange) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixKeyExchange) Command() string
- func (msg *MsgMixKeyExchange) GetRun() uint32
- func (msg *MsgMixKeyExchange) Hash() chainhash.Hash
- func (msg *MsgMixKeyExchange) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixKeyExchange) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixKeyExchange) Pub() []byte
- func (msg *MsgMixKeyExchange) Sid() []byte
- func (msg *MsgMixKeyExchange) Sig() []byte
- func (msg *MsgMixKeyExchange) WriteHash(h hash.Hash)
- func (msg *MsgMixKeyExchange) WriteSignedData(h hash.Hash)
- type MsgMixPairReq
- func (msg *MsgMixPairReq) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixPairReq) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixPairReq) Command() string
- func (msg *MsgMixPairReq) Expires() uint32
- func (msg *MsgMixPairReq) GetRun() uint32
- func (msg *MsgMixPairReq) Hash() chainhash.Hash
- func (msg *MsgMixPairReq) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixPairReq) Pairing() ([]byte, error)
- func (msg *MsgMixPairReq) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixPairReq) Pub() []byte
- func (msg *MsgMixPairReq) Sid() []byte
- func (msg *MsgMixPairReq) Sig() []byte
- func (msg *MsgMixPairReq) WriteHash(h hash.Hash)
- func (msg *MsgMixPairReq) WriteSignedData(h hash.Hash)
- type MsgMixSecrets
- func (msg *MsgMixSecrets) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixSecrets) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixSecrets) Command() string
- func (msg *MsgMixSecrets) Commitment(h hash.Hash) chainhash.Hash
- func (msg *MsgMixSecrets) GetRun() uint32
- func (msg *MsgMixSecrets) Hash() chainhash.Hash
- func (msg *MsgMixSecrets) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixSecrets) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixSecrets) Pub() []byte
- func (msg *MsgMixSecrets) Sid() []byte
- func (msg *MsgMixSecrets) Sig() []byte
- func (msg *MsgMixSecrets) WriteHash(h hash.Hash)
- func (msg *MsgMixSecrets) WriteSignedData(h hash.Hash)
- type MsgMixSlotReserve
- func (msg *MsgMixSlotReserve) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgMixSlotReserve) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgMixSlotReserve) Command() string
- func (msg *MsgMixSlotReserve) GetRun() uint32
- func (msg *MsgMixSlotReserve) Hash() chainhash.Hash
- func (msg *MsgMixSlotReserve) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgMixSlotReserve) PrevMsgs() []chainhash.Hash
- func (msg *MsgMixSlotReserve) Pub() []byte
- func (msg *MsgMixSlotReserve) Sid() []byte
- func (msg *MsgMixSlotReserve) Sig() []byte
- func (msg *MsgMixSlotReserve) WriteHash(h hash.Hash)
- func (msg *MsgMixSlotReserve) WriteSignedData(h hash.Hash)
- type MsgNotFound
- type MsgPing
- type MsgPong
- type MsgRejectdeprecated
- 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) error
- func (msg *MsgTx) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgTx) Bytes() ([]byte, error)
- func (msg *MsgTx) BytesPrefix() ([]byte, error)
- func (msg *MsgTx) BytesWitness() ([]byte, error)
- func (msg *MsgTx) CachedTxHash() *chainhash.Hash
- func (msg *MsgTx) Command() string
- func (msg *MsgTx) Copy() *MsgTx
- func (msg *MsgTx) Deserialize(r io.Reader) error
- func (msg *MsgTx) FromBytes(b []byte) error
- func (msg *MsgTx) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgTx) PkScriptLocs() []int
- func (msg *MsgTx) RecacheTxHash() *chainhash.Hash
- func (msg *MsgTx) Serialize(w io.Writer) error
- func (msg *MsgTx) SerializeSize() int
- func (msg *MsgTx) TxHash() chainhash.Hash
- func (msg *MsgTx) TxHashFull() chainhash.Hash
- func (msg *MsgTx) TxHashWitness() 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) error
- func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32) error
- func (msg *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 TxIn
- type TxLoc
- type TxOut
- type TxSerializeType
Constants ¶
const ( CmdVersion = "version" CmdVerAck = "verack" CmdGetAddr = "getaddr" CmdAddr = "addr" CmdGetBlocks = "getblocks" CmdInv = "inv" CmdGetData = "getdata" CmdNotFound = "notfound" CmdBlock = "block" CmdTx = "tx" CmdGetHeaders = "getheaders" CmdHeaders = "headers" CmdPing = "ping" CmdPong = "pong" CmdMemPool = "mempool" CmdMiningState = "miningstate" CmdGetMiningState = "getminings" CmdReject = "reject" CmdSendHeaders = "sendheaders" CmdFeeFilter = "feefilter" CmdGetCFilterV2 = "getcfilterv2" CmdCFilterV2 = "cfilterv2" CmdGetInitState = "getinitstate" CmdInitState = "initstate" CmdMixPairReq = "mixpairreq" CmdMixKeyExchange = "mixkeyxchg" CmdMixCiphertexts = "mixcphrtxt" CmdMixSlotReserve = "mixslotres" CmdMixFactoredPoly = "mixfactpoly" CmdMixDCNet = "mixdcnet" CmdMixConfirm = "mixconfirm" CmdMixSecrets = "mixsecrets" CmdGetCFiltersV2 = "getcfsv2" CmdCFiltersV2 = "cfiltersv2" )
Commands used in message headers which describe the type of message.
const ( // Deprecated: This command is no longer valid as of protocol version // CFilterV2Version. CmdGetCFilter = "getcfilter" // Deprecated: This command is no longer valid as of protocol version // CFilterV2Version. CmdGetCFHeaders = "getcfheaders" // Deprecated: This command is no longer valid as of protocol version // CFilterV2Version. CmdGetCFTypes = "getcftypes" // Deprecated: This command is no longer valid as of protocol version // CFilterV2Version. CmdCFilter = "cfilter" // Deprecated: This command is no longer valid as of protocol version // CFilterV2Version. CmdCFHeaders = "cfheaders" // Deprecated: This command is no longer valid as of protocol version // CFilterV2Version. CmdCFTypes = "cftypes" )
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 cfheaders message. MaxCFHeadersPerMsg = 2000 )
const ( // MaxInitStateTypeLen is the maximum length allowable for an // individual requested type. MaxInitStateTypeLen = 32 // MaxInitStateTypes is the maximum number of individual types stored // in a getinitialstate message. MaxInitStateTypes = 32 // InitStateHeadBlocks is the init state type used to request head // blocks for mining. InitStateHeadBlocks = "headblocks" // InitStateHeadBlockVotes is the init state type used to request votes // for the head blocks for mining. InitStateHeadBlockVotes = "headblockvotes" // InitStateTSpends is the init state type used to request tpends for // voting. InitStateTSpends = "tspends" )
const ( // MaxMixPairReqScriptClassLen is the maximum length allowable for a // MsgMixPairReq script class. MaxMixPairReqScriptClassLen = 32 // MaxMixPairReqUTXOs is the maximum number of unspent transaction // outputs that may be contributed in a single mixpairreq message. // This value is an high estimate of what a large mix may look like, // based on statistics from the centralized mixing server. MaxMixPairReqUTXOs = 512 // MaxMixPairReqUTXOScriptLen is the maximum length allowed for the // unhashed P2SH script of a UTXO ownership proof. MaxMixPairReqUTXOScriptLen = 16384 // txscript.MaxScriptSize // MaxMixPairReqUTXOPubKeyLen is the maximum length allowed for the // pubkey of a UTXO ownership proof. MaxMixPairReqUTXOPubKeyLen = 33 // MaxMixPairReqUTXOSignatureLen is the maximum length allowed for the // signature of a UTXO ownership proof. MaxMixPairReqUTXOSignatureLen = 64 )
const ( // MaxMixMcount is the maximum number of mixed messages that are allowed // in a single mix. This restricts the total allowed size of the slot // reservation and XOR DC-net matrices. // This value is an high estimate of what a large mix may look like, // based on statistics from the centralized mixing server. MaxMixMcount = 1024 // MaxMixFieldValLen is the maximum number of bytes allowed to represent // a value in the slot reservation mix bounded by the field prime. MaxMixFieldValLen = 32 )
const ( // TxVersion is the initial transaction version. TxVersion uint16 = 1 // TxVersionSeqLock is the transaction version that enables sequence // locks. TxVersionSeqLock uint16 = 2 // TxVersionTreasury is the transaction version that enables the // decentralized treasury features. TxVersionTreasury uint16 = 3 // 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 // NoExpiryValue is the value of expiry that indicates the transaction // has no expiry. NoExpiryValue uint32 = 0 // NullValueIn is a null value for an input witness. NullValueIn int64 = -1 // NullBlockHeight is the null value for an input witness. It references // the genesis block. NullBlockHeight uint32 = 0x00000000 // NullBlockIndex is the null transaction index in a block for an input // witness. NullBlockIndex uint32 = 0xffffffff // DefaultPkScriptVersion is the default pkScript version, referring to // extended Decred script. DefaultPkScriptVersion uint16 = 0x0000 // TxTreeUnknown is the value returned for a transaction tree that is // unknown. This is typically because the transaction has not been // inserted into a block yet. TxTreeUnknown int8 = -1 // TxTreeRegular is the value for a normal transaction tree for a // transaction's location in a block. TxTreeRegular int8 = 0 // TxTreeStake is the value for a stake transaction tree for a // transaction's location in a block. TxTreeStake int8 = 1 // 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 )
const ( // InitialProcotolVersion is the initial protocol version for the // network. InitialProcotolVersion uint32 = 1 // ProtocolVersion is the latest protocol version this package supports. ProtocolVersion uint32 = 11 // NodeBloomVersion is the protocol version which added the SFNodeBloom // service flag (unused). NodeBloomVersion uint32 = 2 // SendHeadersVersion is the protocol version which added a new // sendheaders message. SendHeadersVersion uint32 = 3 // MaxBlockSizeVersion is the protocol version which increased the // original blocksize. MaxBlockSizeVersion uint32 = 4 // FeeFilterVersion is the protocol version which added a new // feefilter message. FeeFilterVersion uint32 = 5 // NodeCFVersion is the protocol version which adds the SFNodeCF service // flag and the cfheaders, cfilter, cftypes, getcfheaders, getcfilter and // getcftypes messages. NodeCFVersion uint32 = 6 // CFilterV2Version is the protocol version which adds the getcfilterv2 and // cfiltverv2 messages. CFilterV2Version uint32 = 7 // InitStateVersion is the protocol version which adds the initstate // and getinitstate messages. InitStateVersion uint32 = 8 // RemoveRejectVersion is the protocol version which removes support for the // reject message. RemoveRejectVersion uint32 = 9 // MixVersion is the protocol version which adds peer-to-peer mixing. MixVersion uint32 = 10 // BatchedCFiltersV2Version is the protocol version which adds support // for the batched getcfsv2 and cfiltersv2 messages. BatchedCFiltersV2Version uint32 = 11 )
const CommandSize = 12
CommandSize is the fixed size of all commands in the common Decred message header. Shorter commands must be zero padded.
const DefaultUserAgent = "/dcrwire:1.0.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 MaxBlockHeaderPayload = 84 + (chainhash.HashSize * 3)
MaxBlockHeaderPayload is the maximum number of bytes a block header can be. Version 4 bytes + PrevBlock 32 bytes + MerkleRoot 32 bytes + StakeRoot 32 bytes + VoteBits 2 bytes + FinalState 6 bytes + Voters 2 bytes + FreshStake 1 byte + Revocations 1 bytes + PoolSize 4 bytes + Bits 4 bytes + SBits 8 bytes + Height 4 bytes + Size 4 bytes + Timestamp 4 bytes + Nonce 4 bytes + ExtraData 32 bytes + StakeVersion 4 bytes. --> Total 180 bytes.
const MaxBlockHeadersPerMsg = 2000
MaxBlockHeadersPerMsg is the maximum number of block headers that can be in a single Decred headers message.
const MaxBlockLocatorsPerMsg = 500
MaxBlockLocatorsPerMsg is the maximum number of block locator hashes allowed per message.
const MaxBlockPayload = 1310720 // 1.25MB
MaxBlockPayload is the maximum bytes a block message can be in bytes.
const MaxBlockPayloadV3 = 1000000 // Not actually 1MB which would be 1024 * 1024
MaxBlockPayloadV3 is the maximum bytes a block message can be in bytes as of version 3 of the protocol.
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 MaxCFiltersV2PerBatch = 100
MaxCFiltersV2PerBatch is the maximum number of committed filters that may be sent in a cfiltersv2 message.
This number has been decided assuming a sequence of blocks filled with transactions specifically designed to maximize the filter size, such that a cfiltersv2 message will not be larger than the maximum allowed P2P message size on any of the currently deployed networks.
const MaxFilterTypesPerMsg = 256
MaxFilterTypesPerMsg is the maximum number of filter types allowed per message.
const MaxHeaderProofHashes = 32
MaxHeaderProofHashes is the maximum number of header commitment inclusion proof hashes that can be in a single message. It is based on the fact that the proofs are logarithmic in nature and hence a value of 32 supports proofs of up to 2^32 commitments.
const MaxISBlocksAtHeadPerMsg = 8
MaxISBlocksAtHeadPerMsg is the maximum number of block hashes allowed per message.
const MaxISTSpendsAtHeadPerMsg = 7
MaxISTSpendsAtHeadPerMsg is the maximum number of tspends at head per message.
const MaxISVotesAtHeadPerMsg = 40 // 8 * 5
MaxISVotesAtHeadPerMsg is the maximum number of votes at head per message.
const ( // MaxInvPerMsg is the maximum number of inventory vectors that can be in a // single Decred inv message. MaxInvPerMsg = 50000 )
const MaxMSBlocksAtHeadPerMsg = 8
MaxMSBlocksAtHeadPerMsg is the maximum number of block hashes allowed per message.
const MaxMSVotesAtHeadPerMsg = 40 // 8 * 5
MaxMSVotesAtHeadPerMsg is the maximum number of votes at head per message.
const MaxMessagePayload = (1024 * 1024 * 32) // 32MB
MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves.
const ( // MaxMixPeers is the maximum number of peers allowed together in a // single mix. This restricts the maximum dimensions of the slot // reservation and XOR DC-net matrices and the maximum number of // previous messages that may be referenced by mix messages. // This value is an high estimate of what a large mix may look like, // based on statistics from the centralized mixing server. MaxMixPeers = 512 )
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 Decred message header. Decred network (magic) 4 bytes + command 12 bytes + payload length 4 bytes + checksum 4 bytes.
const MixMsgSize = 20
Variables ¶
var ErrInvalidNetAddr = errors.New("provided net.Addr is not a net.TCPAddr")
ErrInvalidNetAddr describes an error that indicates the caller didn't specify a TCP address as required.
Functions ¶
func MaxTxPerTxTree ¶
MaxTxPerTxTree returns the maximum number of transactions that could possibly fit into a block per each merkle root for the given protocol version.
func RandomUint64 ¶
RandomUint64 returns a cryptographically random uint64 value.
func ReadAsciiVarString ¶ added in v1.4.0
ReadAsciiVarString 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 specified maxAllowed argument, greater than the global maximum message payload length or if the decoded string is not strictly an ascii string.
func ReadOutPoint ¶
ReadOutPoint reads the next sequence of bytes from r as an OutPoint.
func ReadVarBytes ¶
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 ¶
ReadVarInt reads a variable length integer from r and returns it as a uint64.
func ReadVarString ¶
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 ¶
VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.
func WriteMessage ¶
WriteMessage writes a Decred Message to w including the necessary header information. This function is the same as WriteMessageN except it 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 Decred 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 WriteOutPoint ¶
WriteOutPoint encodes op to the Decred protocol encoding for an OutPoint to w.
func WriteVarBytes ¶
WriteVarBytes serializes a variable length byte array to w as a varInt containing the number of bytes, followed by the bytes themselves.
func WriteVarInt ¶
WriteVarInt serializes val to w using a variable number of bytes depending on its value.
Types ¶
type BlockHeader ¶
type BlockHeader struct { // Version of the block. This is not the same as the protocol version. Version int32 // Hash of the previous block in the block chain. PrevBlock chainhash.Hash // Merkle tree reference to hash of all transactions for the block. MerkleRoot chainhash.Hash // Merkle tree reference to hash of all stake transactions for the block. StakeRoot chainhash.Hash // Votes on the previous merkleroot and yet undecided parameters. VoteBits uint16 // Final state of the PRNG used for ticket selection in the lottery. FinalState [6]byte // Number of participating voters for this block. Voters uint16 // Number of new sstx in this block. FreshStake uint8 // Number of ssrtx present in this block. Revocations uint8 // Size of the ticket pool. PoolSize uint32 // Difficulty target for the block. Bits uint32 // Stake difficulty target. SBits int64 // Height is the block height in the block chain. Height uint32 // Size is the size of the serialized block in its entirety. Size uint32 // Time the block was created. This is, unfortunately, encoded as a // uint32 on the wire and therefore is limited to 2106. Timestamp time.Time // Nonce is technically a part of ExtraData, but we use it as the // classical 4-byte nonce here. Nonce uint32 // ExtraData is used to encode the nonce or any other extra data // that might be used later on in consensus. ExtraData [32]byte // StakeVersion used for voting. StakeVersion uint32 }
BlockHeader defines information about a block and is used in the decred block (MsgBlock) and headers (MsgHeaders) messages.
func NewBlockHeader ¶
func NewBlockHeader(version int32, prevHash *chainhash.Hash, merkleRootHash *chainhash.Hash, stakeRoot *chainhash.Hash, voteBits uint16, finalState [6]byte, voters uint16, freshStake uint8, revocations uint8, poolsize uint32, bits uint32, sbits int64, height uint32, size uint32, nonce uint32, extraData [32]byte, stakeVersion uint32) *BlockHeader
NewBlockHeader returns a new BlockHeader using the provided previous block hash, merkle root hash, difficulty bits, and nonce used to generate the block with defaults for the remaining fields.
func (*BlockHeader) BlockHash ¶
func (h *BlockHeader) BlockHash() chainhash.Hash
BlockHash computes the block identifier hash for the given block header.
func (*BlockHeader) BtcDecode ¶
func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32) 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 (*BlockHeader) BtcEncode ¶
func (h *BlockHeader) BtcEncode(w io.Writer, pver uint32) 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 (*BlockHeader) Bytes ¶
func (h *BlockHeader) Bytes() ([]byte, error)
Bytes returns a byte slice containing the serialized contents of the block header.
func (*BlockHeader) Deserialize ¶
func (h *BlockHeader) 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 (*BlockHeader) FromBytes ¶
func (h *BlockHeader) FromBytes(b []byte) error
FromBytes deserializes a block header byte slice.
func (*BlockHeader) PowHashV1 ¶ added in v1.6.0
func (h *BlockHeader) PowHashV1() chainhash.Hash
PowHashV1 calculates and returns the version 1 proof of work hash for the block header.
NOTE: This is the original proof of work hash function used at Decred launch and applies to all blocks prior to the activation of DCP0011.
func (*BlockHeader) PowHashV2 ¶ added in v1.6.0
func (h *BlockHeader) PowHashV2() chainhash.Hash
PowHashV2 calculates and returns the version 2 proof of work hash as defined in DCP0011 for the block header.
type CurrencyNet ¶
type CurrencyNet uint32
CurrencyNet represents which Decred network a message belongs to.
const ( // MainNet represents the main Decred network. MainNet CurrencyNet = 0xd9b400f9 // RegNet represents the regression test network. RegNet CurrencyNet = 0xdab500fa // RegTest represents the regression test network. // // DEPRECATED. This will be removed in the next major version bump. // Use Regnet instead. RegTest CurrencyNet = RegNet // TestNet3 represents the 3rd test network. TestNet3 CurrencyNet = 0xb194aa75 // SimNet represents the simulation test network. SimNet CurrencyNet = 0x12141c16 )
Constants used to indicate the message Decred 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.
func (CurrencyNet) String ¶
func (n CurrencyNet) String() string
String returns the CurrencyNet in human-readable form.
type ErrorCode ¶ added in v1.4.0
type ErrorCode int
ErrorCode describes a kind of message error.
const ( // ErrNonCanonicalVarInt is returned when a variable length integer is // not canonically encoded. ErrNonCanonicalVarInt ErrorCode = iota // ErrVarStringTooLong is returned when a variable string exceeds the // maximum message size allowed. ErrVarStringTooLong // ErrVarBytesTooLong is returned when a variable-length byte slice // exceeds the maximum message size allowed. ErrVarBytesTooLong // ErrCmdTooLong is returned when a command exceeds the maximum command // size allowed. ErrCmdTooLong // ErrPayloadTooLarge is returned when a payload exceeds the maximum // payload size allowed. ErrPayloadTooLarge // ErrWrongNetwork is returned when a message intended for a different // network is received. ErrWrongNetwork // ErrMalformedCmd is returned when a malformed command is received. ErrMalformedCmd // ErrUnknownCmd is returned when an unknown command is received. ErrUnknownCmd // ErrPayloadChecksum is returned when a message with an invalid checksum // is received. ErrPayloadChecksum // ErrTooManyAddrs is returned when an address list exceeds the maximum // allowed. ErrTooManyAddrs // ErrTooManyTxs is returned when a the number of transactions exceed the // maximum allowed. ErrTooManyTxs // ErrMsgInvalidForPVer is returned when a message is invalid for // the expected protocol version. ErrMsgInvalidForPVer // ErrFilterTooLarge is returned when a committed filter exceeds // the maximum size allowed. ErrFilterTooLarge // ErrTooManyProofs is returned when the number of proof hashes // exceeds the maximum allowed. ErrTooManyProofs // ErrTooManyFilterTypes is returned when the number of filter types // exceeds the maximum allowed. ErrTooManyFilterTypes // ErrTooManyLocators is returned when the number of block locators exceed // the maximum allowed. ErrTooManyLocators // ErrTooManyVectors is returned when the number of inventory vectors // exceed the maximum allowed. ErrTooManyVectors // ErrTooManyHeaders is returned when the number of block headers exceed // the maximum allowed. ErrTooManyHeaders // ErrHeaderContainsTxs is returned when a header's transactions // count is greater than zero. ErrHeaderContainsTxs // ErrTooManyVotes is returned when the number of vote hashes exceed the // maximum allowed. ErrTooManyVotes // ErrTooManyBlocks is returned when the number of block hashes exceed the // maximum allowed. ErrTooManyBlocks // ErrMismatchedWitnessCount returned when a transaction has unequal witness // and prefix txin quantities. ErrMismatchedWitnessCount // ErrUnknownTxType is returned when a transaction type is unknown. ErrUnknownTxType // ErrReadInPrefixFromWitnessOnlyTx is returned when attempting to read a // transaction input prefix from a witness only transaction. ErrReadInPrefixFromWitnessOnlyTx // ErrInvalidMsg is returned for an invalid message structure. ErrInvalidMsg // ErrUserAgentTooLong is returned when the provided user agent exceeds // the maximum allowed. ErrUserAgentTooLong // ErrTooManyFilterHeaders is returned when the number of committed filter // headers exceed the maximum allowed. ErrTooManyFilterHeaders // ErrMalformedStrictString is returned when a string that has strict // formatting requirements does not conform to the requirements. ErrMalformedStrictString // ErrTooManyInitialStateTypes is returned when the number of initial // state types is larger than the maximum allowed by the protocol. ErrTooManyInitStateTypes // ErrInitialStateTypeTooLong is returned when an individual initial // state type is longer than allowed by the protocol. ErrInitStateTypeTooLong // ErrTooManyTSpends is returned when the number of tspend hashes // exceeds the maximum allowed. ErrTooManyTSpends // ErrTooManyManyMixPairReqs is returned when the number of mix pair // request message hashes exceeds the maximum allowed. ErrTooManyManyMixPairReqs // ErrMixPairReqScriptClassTooLong is returned when a mixing script // class type string is longer than allowed by the protocol. ErrMixPairReqScriptClassTooLong // ErrTooManyMixPairReqUTXOs is returned when a MixPairReq message // contains more UTXOs than allowed by the protocol. ErrTooManyMixPairReqUTXOs // ErrTooManyPrevMixMsgs is returned when too many previous messages of // a mix run are referenced by a message. ErrTooManyPrevMixMsgs // ErrTooManyCFilters is returned when the number of committed filters // exceeds the maximum allowed in a batch. ErrTooManyCFilters )
These constants are used to identify a specific Error.
type FilterType ¶
type FilterType uint8
FilterType is used to represent a filter type.
const ( // GCSFilterRegular is the regular filter type. GCSFilterRegular FilterType = iota // GCSFilterExtended is the extended filter type. GCSFilterExtended )
type InvType ¶
type InvType uint32
InvType represents the allowed types of inventory vectors. See InvVect.
type InvVect ¶
InvVect defines a Decred inventory vector which is used to describe data, as specified by the Type field, that a peer wants, has, or does not have to another peer.
type Message ¶
type Message interface { BtcDecode(io.Reader, uint32) error BtcEncode(io.Writer, uint32) error Command() string MaxPayloadLength(uint32) uint32 }
Message is an interface that describes a Decred 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 Decred Message from r for the provided protocol version and Decred 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 Decred Message from r for the provided protocol version and Decred 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.
type MessageError ¶
type MessageError struct { Func string // Function name ErrorCode ErrorCode // Describes the kind of error 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 decred 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 (MessageError) Error ¶
func (m MessageError) Error() string
Error satisfies the error interface and prints human-readable errors.
func (*MessageError) Is ¶ added in v1.4.0
func (m *MessageError) Is(target error) bool
Is implements the interface to work with the standard library's errors.Is.
It returns true in the following cases: - The target is a *MessageError and the error codes match - The target is an ErrorCode and it the error codes match
func (*MessageError) Unwrap ¶ added in v1.4.0
func (m *MessageError) Unwrap() error
Unwrap returns the underlying wrapped error if it is not ErrOther. Unwrap returns the ErrorCode. Else, it returns nil.
type MixPairReqUTXO ¶ added in v1.7.0
type MixPairReqUTXO struct { OutPoint OutPoint Script []byte // Only used for P2SH PubKey []byte Signature []byte Opcode byte }
MixPairReqUTXO describes an unspent transaction output to be spent in a mix. It includes a proof that the output is able to be spent, by containing a signature and the necessary data needed to prove key possession.
The opcode defines the type of standard script. 0 is used for regular outputs, otherwise it may be one of OP_SSGEN/OP_SSRTX/OP_TGEN.
type MixVect ¶ added in v1.7.0
type MixVect [][MixMsgSize]byte
MixVect is vector of padded or unpadded DC-net messages.
type MsgAddr ¶
type MsgAddr struct {
AddrList []*NetAddress
}
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 peer 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 peer.
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 peer to the message.
func (*MsgAddr) AddAddresses ¶
func (msg *MsgAddr) AddAddresses(netAddrs ...*NetAddress) 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 MsgBlock ¶
type MsgBlock struct { Header BlockHeader Transactions []*MsgTx STransactions []*MsgTx }
MsgBlock implements the Message interface and represents a decred block message. It is used to deliver block and transaction information in response to a getdata message (MsgGetData) for a given block hash.
func NewMsgBlock ¶
func NewMsgBlock(blockHeader *BlockHeader) *MsgBlock
NewMsgBlock returns a new Decred block message that conforms to the Message interface. See MsgBlock for details.
func (*MsgBlock) AddSTransaction ¶
AddSTransaction adds a stake transaction to the message.
func (*MsgBlock) AddTransaction ¶
AddTransaction adds a transaction to the message.
func (*MsgBlock) BtcDecode ¶
BtcDecode decodes r using the Decred 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 Decred 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) ClearSTransactions ¶
func (msg *MsgBlock) ClearSTransactions()
ClearSTransactions removes all stake transactions from the message.
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) 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 Decred 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) 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) PowHashV1 ¶ added in v1.6.0
PowHashV1 calculates and returns the version 1 proof of work hash for the block.
NOTE: This is the original proof of work hash that was used at Decred launch and applies to all blocks prior to the activation of DCP0011.
func (*MsgBlock) PowHashV2 ¶ added in v1.6.0
PowHashV2 calculates and returns the version 2 proof of work hash as defined in DCP0011 for the block.
func (*MsgBlock) STxHashes ¶
STxHashes returns a slice of hashes of all of stake transactions in this block.
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 Decred 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) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the block.
type MsgCFHeaders
deprecated
type MsgCFHeaders struct { StopHash chainhash.Hash FilterType FilterType HeaderHashes []*chainhash.Hash }
MsgCFHeaders implements the Message interface and represents a 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.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func NewMsgCFHeaders
deprecated
func NewMsgCFHeaders() *MsgCFHeaders
NewMsgCFHeaders returns a new cfheaders message that conforms to the Message interface. See MsgCFHeaders for details.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func (*MsgCFHeaders) AddCFHeader ¶
func (msg *MsgCFHeaders) AddCFHeader(headerHash *chainhash.Hash) error
AddCFHeader adds a new committed filter header to the message.
func (*MsgCFHeaders) BtcDecode ¶
func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the wire 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) error
BtcEncode encodes the receiver to w using the wire 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 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 MsgCFTypes
deprecated
type MsgCFTypes struct {
SupportedFilters []FilterType
}
MsgCFTypes is the cftypes message.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func NewMsgCFTypes
deprecated
func NewMsgCFTypes(filterTypes []FilterType) *MsgCFTypes
NewMsgCFTypes returns a new cftypes message that conforms to the Message interface. See MsgCFTypes for details.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func (*MsgCFTypes) BtcDecode ¶
func (msg *MsgCFTypes) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the wire protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgCFTypes) BtcEncode ¶
func (msg *MsgCFTypes) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the wire protocol encoding. This is part of the Message interface implementation.
func (*MsgCFTypes) Command ¶
func (msg *MsgCFTypes) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCFTypes) Deserialize ¶
func (msg *MsgCFTypes) 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 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 (*MsgCFTypes) MaxPayloadLength ¶
func (msg *MsgCFTypes) 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
deprecated
type MsgCFilter struct { BlockHash chainhash.Hash FilterType FilterType Data []byte }
MsgCFilter implements the Message interface and represents a cfilter message. It is used to deliver a committed filter in response to a getcfilter (MsgGetCFilter) message.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func NewMsgCFilter
deprecated
func NewMsgCFilter(blockHash *chainhash.Hash, filterType FilterType, data []byte) *MsgCFilter
NewMsgCFilter returns a new cfilter message that conforms to the Message interface. See MsgCFilter for details.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func (*MsgCFilter) BtcDecode ¶
func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the wire 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) error
BtcEncode encodes the receiver to w using the wire 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 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 MsgCFilterV2 ¶ added in v1.3.0
type MsgCFilterV2 struct { BlockHash chainhash.Hash Data []byte ProofIndex uint32 ProofHashes []chainhash.Hash }
MsgCFilterV2 implements the Message interface and represents a cfilterv2 message. It is used to deliver a version 2 committed gcs filter for a given block along with a proof that can be used to prove the filter is committed to by the block header. Note that the proof is only useful once the vote to enable header commitments is active.
It is delivered in response to a getcfilterv2 message (MsgGetCFilterV2). Unknown blocks are ignored.
func NewMsgCFilterV2 ¶ added in v1.3.0
func NewMsgCFilterV2(blockHash *chainhash.Hash, filterData []byte, proofIndex uint32, proofHashes []chainhash.Hash) *MsgCFilterV2
NewMsgCFilterV2 returns a new cfilterv2 message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgCFilterV2) BtcDecode ¶ added in v1.3.0
func (msg *MsgCFilterV2) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgCFilterV2) BtcEncode ¶ added in v1.3.0
func (msg *MsgCFilterV2) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgCFilterV2) Command ¶ added in v1.3.0
func (msg *MsgCFilterV2) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCFilterV2) MaxPayloadLength ¶ added in v1.3.0
func (msg *MsgCFilterV2) 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 MsgCFiltersV2 ¶ added in v1.7.0
type MsgCFiltersV2 struct {
CFilters []MsgCFilterV2
}
MsgCFiltersV2 implements the Message interface and represents a cfiltersv2 message. It is used to deliver a batch of version 2 committed gcs filters for a given range of blocks, along with a proof that can be used to prove the filter is committed to by the block header.
It is delivered in response to a getcfsv2 message (MsgGetCFiltersV2).
func NewMsgCFiltersV2 ¶ added in v1.7.0
func NewMsgCFiltersV2(filters []MsgCFilterV2) *MsgCFiltersV2
NewMsgCFiltersV2 returns a new cfiltersv2 message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgCFiltersV2) BtcDecode ¶ added in v1.7.0
func (msg *MsgCFiltersV2) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgCFiltersV2) BtcEncode ¶ added in v1.7.0
func (msg *MsgCFiltersV2) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgCFiltersV2) Command ¶ added in v1.7.0
func (msg *MsgCFiltersV2) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCFiltersV2) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgCFiltersV2) 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 feefilter message. It is used to request the receiving peer 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 feefilter message that conforms to the Message interface. See MsgFeeFilter for details.
func (*MsgFeeFilter) BtcDecode ¶
func (msg *MsgFeeFilter) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the 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) error
BtcEncode encodes the receiver to w using the 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 MsgGetAddr ¶
type MsgGetAddr struct{}
MsgGetAddr implements the Message interface and represents a decred getaddr message. It is used to request a list of known active peers on the network from a peer 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 Decred getaddr message that conforms to the Message interface. See MsgGetAddr for details.
func (*MsgGetAddr) BtcDecode ¶
func (msg *MsgGetAddr) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 BlockLocatorHashes []*chainhash.Hash HashStop chainhash.Hash }
MsgGetBlocks implements the Message interface and represents a decred 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 AddBlockLocatorHash 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 Decred getblocks message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetBlocks) AddBlockLocatorHash ¶
func (msg *MsgGetBlocks) AddBlockLocatorHash(hash *chainhash.Hash) error
AddBlockLocatorHash adds a new block locator hash to the message.
func (*MsgGetBlocks) BtcDecode ¶
func (msg *MsgGetBlocks) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 MsgGetCFHeaders
deprecated
type MsgGetCFHeaders struct { BlockLocatorHashes []*chainhash.Hash HashStop chainhash.Hash FilterType FilterType }
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.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func NewMsgGetCFHeaders
deprecated
func NewMsgGetCFHeaders() *MsgGetCFHeaders
NewMsgGetCFHeaders returns a new getcfheader message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func (*MsgGetCFHeaders) AddBlockLocatorHash ¶
func (msg *MsgGetCFHeaders) AddBlockLocatorHash(hash *chainhash.Hash) error
AddBlockLocatorHash adds a new block locator hash to the message.
func (*MsgGetCFHeaders) BtcDecode ¶
func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the wire 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) error
BtcEncode encodes the receiver to w using the wire 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 MsgGetCFTypes
deprecated
type MsgGetCFTypes struct{}
MsgGetCFTypes is the getcftypes message.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func NewMsgGetCFTypes
deprecated
func NewMsgGetCFTypes() *MsgGetCFTypes
NewMsgGetCFTypes returns a new getcftypes message that conforms to the Message interface.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func (*MsgGetCFTypes) BtcDecode ¶
func (msg *MsgGetCFTypes) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes the receiver from w using the wire protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFTypes) BtcEncode ¶
func (msg *MsgGetCFTypes) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the wire protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFTypes) Command ¶
func (msg *MsgGetCFTypes) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFTypes) MaxPayloadLength ¶
func (msg *MsgGetCFTypes) 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 MsgGetCFilter
deprecated
type MsgGetCFilter struct { BlockHash chainhash.Hash FilterType FilterType }
MsgGetCFilter implements the Message interface and represents a getcfilter message. It is used to request a committed filter for a block.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func NewMsgGetCFilter
deprecated
func NewMsgGetCFilter(blockHash *chainhash.Hash, filterType FilterType) *MsgGetCFilter
NewMsgGetCFilter returns a new getcfilter message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
Deprecated: This message is no longer valid as of protocol version CFilterV2Version.
func (*MsgGetCFilter) BtcDecode ¶
func (msg *MsgGetCFilter) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the wire protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetCFilter) BtcEncode ¶
func (msg *MsgGetCFilter) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the wire protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFilter) Command ¶
func (msg *MsgGetCFilter) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFilter) MaxPayloadLength ¶
func (msg *MsgGetCFilter) 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 MsgGetCFilterV2 ¶ added in v1.3.0
MsgGetCFilterV2 implements the Message interface and represents a decred getcfilterv2 message. It is used to request a version 2 committed gcs filter for a given block along with a proof that can be used to prove the filter is committed to by the block header. Note that the proof is only useful once the vote to enable header commitments is active. The filter is returned via a cfilterv2 message (MsgCFilterV2). Unknown blocks are ignored.
func NewMsgGetCFilterV2 ¶ added in v1.3.0
func NewMsgGetCFilterV2(blockHash *chainhash.Hash) *MsgGetCFilterV2
NewMsgGetCFilterV2 returns a new Decred getcfilterv2 message that conforms to the Message interface using the passed parameters.
func (*MsgGetCFilterV2) BtcDecode ¶ added in v1.3.0
func (msg *MsgGetCFilterV2) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetCFilterV2) BtcEncode ¶ added in v1.3.0
func (msg *MsgGetCFilterV2) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFilterV2) Command ¶ added in v1.3.0
func (msg *MsgGetCFilterV2) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFilterV2) MaxPayloadLength ¶ added in v1.3.0
func (msg *MsgGetCFilterV2) 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 MsgGetCFsV2 ¶ added in v1.7.0
MsgGetCFsV2 implements the Message interface and represents a decred getcfsv2 message. It is used to request a batch of version 2 committed filters that span a subset of a chain, from StartHash up to (and including) EndHash. The response is sent in a MsgCFiltersV2 message.
At most MaxCFiltersV2PerBatch may be requested by each MsgGetCFsV2 message, which means the number of blocks between EndHash and StartHash must be lesser than or equal to that constant's value.
func NewMsgGetCFsV2 ¶ added in v1.7.0
func NewMsgGetCFsV2(startHash, endHash *chainhash.Hash) *MsgGetCFsV2
NewMsgGetCFsV2 returns a new Decred getcfiltersv2 message that conforms to the Message interface using the passed parameters.
func (*MsgGetCFsV2) BtcDecode ¶ added in v1.7.0
func (msg *MsgGetCFsV2) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetCFsV2) BtcEncode ¶ added in v1.7.0
func (msg *MsgGetCFsV2) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgGetCFsV2) Command ¶ added in v1.7.0
func (msg *MsgGetCFsV2) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetCFsV2) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgGetCFsV2) 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 decred getdata message. It is used to request data such as blocks and transactions from another peer. It should be used in response to the inv (MsgInv) message to request the actual data referenced by each inventory vector the receiving peer 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 peer.
func NewMsgGetData ¶
func NewMsgGetData() *MsgGetData
NewMsgGetData returns a new Decred getdata message that conforms to the Message interface. See MsgGetData for details.
func NewMsgGetDataSizeHint ¶
func NewMsgGetDataSizeHint(sizeHint uint) *MsgGetData
NewMsgGetDataSizeHint returns a new Decred 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) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 BlockLocatorHashes []*chainhash.Hash HashStop chainhash.Hash }
MsgGetHeaders implements the Message interface and represents a decred 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 AddBlockLocatorHash 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 NewMsgGetHeaders ¶
func NewMsgGetHeaders() *MsgGetHeaders
NewMsgGetHeaders returns a new Decred getheaders message that conforms to the Message interface. See MsgGetHeaders for details.
func (*MsgGetHeaders) AddBlockLocatorHash ¶
func (msg *MsgGetHeaders) AddBlockLocatorHash(hash *chainhash.Hash) error
AddBlockLocatorHash adds a new block locator hash to the message.
func (*MsgGetHeaders) BtcDecode ¶
func (msg *MsgGetHeaders) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 MsgGetInitState ¶ added in v1.4.0
type MsgGetInitState struct {
Types []string
}
MsgGetInitState implements the Message interface and represents a getinitstate message. It is used to request ephemeral, startup state from a peer.
The specific desired information is specified in individual entries in the Types member.
func NewMsgGetInitState ¶ added in v1.4.0
func NewMsgGetInitState() *MsgGetInitState
NewMsgGetInitState returns a new Decred getinitialstate message that conforms to the Message interface. See MsgGetInitState for details.
func (*MsgGetInitState) AddType ¶ added in v1.4.0
func (msg *MsgGetInitState) AddType(typ string) error
AddType adds the specified type to the list of types stored in the message. If an attempt to store more than MaxInitStateTypes is made, this function returns an error.
Only ascii strings up to MaxInitStateTypeLen may be stored.
func (*MsgGetInitState) AddTypes ¶ added in v1.4.0
func (msg *MsgGetInitState) AddTypes(types ...string) error
AddTypes adds all the specified types or returns the first error. See AddType for limitations on individual type strings.
func (*MsgGetInitState) BtcDecode ¶ added in v1.4.0
func (msg *MsgGetInitState) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetInitState) BtcEncode ¶ added in v1.4.0
func (msg *MsgGetInitState) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgGetInitState) Command ¶ added in v1.4.0
func (msg *MsgGetInitState) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetInitState) MaxPayloadLength ¶ added in v1.4.0
func (msg *MsgGetInitState) 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 MsgGetMiningState ¶
type MsgGetMiningState struct{}
MsgGetMiningState implements the Message interface and represents a getminingstate message. It is used to request the current mining state from a peer.
func NewMsgGetMiningState ¶
func NewMsgGetMiningState() *MsgGetMiningState
NewMsgGetMiningState returns a new Decred pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgGetMiningState) BtcDecode ¶
func (msg *MsgGetMiningState) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetMiningState) BtcEncode ¶
func (msg *MsgGetMiningState) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgGetMiningState) Command ¶
func (msg *MsgGetMiningState) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetMiningState) MaxPayloadLength ¶
func (msg *MsgGetMiningState) 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 []*BlockHeader
}
MsgHeaders implements the Message interface and represents a Decred 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 Decred headers message that conforms to the Message interface. See MsgHeaders for details.
func (*MsgHeaders) AddBlockHeader ¶
func (msg *MsgHeaders) AddBlockHeader(bh *BlockHeader) error
AddBlockHeader adds a new block header to the message.
func (*MsgHeaders) BtcDecode ¶
func (msg *MsgHeaders) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 MsgInitState ¶ added in v1.4.0
type MsgInitState struct { BlockHashes []chainhash.Hash VoteHashes []chainhash.Hash TSpendHashes []chainhash.Hash }
MsgInitState implements the Message interface and represents an initial state message. It is used to receive ephemeral startup information from a remote peer, such as blocks that can be mined upon, votes for such blocks and tspends.
The content of such a message depends upon what the local peer requested during a previous GetInitState msg.
func NewMsgInitState ¶ added in v1.4.0
func NewMsgInitState() *MsgInitState
NewMsgInitState returns a new Decred initstate message that conforms to the Message interface using the defaults for the fields.
func NewMsgInitStateFilled ¶ added in v1.4.0
func NewMsgInitStateFilled(blockHashes []chainhash.Hash, voteHashes []chainhash.Hash, tspendHashes []chainhash.Hash) (*MsgInitState, error)
NewMsgInitStateFilled returns a new Decred initstate message that conforms to the Message interface and fills the message with the provided data. This is useful in situations where the data slices are already built as it avoids performing a second allocation and data copy.
The provided slices are checked for their maximum length.
func (*MsgInitState) AddBlockHash ¶ added in v1.4.0
func (msg *MsgInitState) AddBlockHash(hash *chainhash.Hash) error
AddBlockHash adds a new block hash to the message. Up to MaxISBlocksAtHeadPerMsg may be added before this function errors out.
func (*MsgInitState) AddTSpendHash ¶ added in v1.4.0
func (msg *MsgInitState) AddTSpendHash(hash *chainhash.Hash) error
AddTSpendHash adds a new treasury spend hash to the message. Up to MaxISTSpendsAtHeadPerMsg may be added before this function errors out.
func (*MsgInitState) AddVoteHash ¶ added in v1.4.0
func (msg *MsgInitState) AddVoteHash(hash *chainhash.Hash) error
AddVoteHash adds a new vote hash to the message. Up to MaxISVotesAtHeadPerMsg may be added before this function errors out.
func (*MsgInitState) BtcDecode ¶ added in v1.4.0
func (msg *MsgInitState) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgInitState) BtcEncode ¶ added in v1.4.0
func (msg *MsgInitState) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the protocol encoding. This is part of the Message interface implementation.
func (*MsgInitState) Command ¶ added in v1.4.0
func (msg *MsgInitState) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgInitState) MaxPayloadLength ¶ added in v1.4.0
func (msg *MsgInitState) 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 Decred inv message. It is used to advertise a peer'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 peer.
func NewMsgInv ¶
func NewMsgInv() *MsgInv
NewMsgInv returns a new Decred inv message that conforms to the Message interface. See MsgInv for details.
func NewMsgInvSizeHint ¶
NewMsgInvSizeHint returns a new Decred 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 Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgInv) BtcEncode ¶
BtcEncode encodes the receiver to w using the Decred 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 Decred 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 Decred pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgMemPool) BtcDecode ¶
func (msg *MsgMemPool) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 MsgMiningState ¶
type MsgMiningState struct { Version uint32 Height uint32 BlockHashes []*chainhash.Hash VoteHashes []*chainhash.Hash }
MsgMiningState implements the Message interface and represents a mining state message. It is used to request a list of blocks located at the chain tip along with all votes for those blocks. The list is returned is limited by the maximum number of blocks per message and the maximum number of votes per message.
func NewMsgMiningState ¶
func NewMsgMiningState() *MsgMiningState
NewMsgMiningState returns a new Decred miningstate message that conforms to the Message interface using the defaults for the fields.
func (*MsgMiningState) AddBlockHash ¶
func (msg *MsgMiningState) AddBlockHash(hash *chainhash.Hash) error
AddBlockHash adds a new block hash to the message.
func (*MsgMiningState) AddVoteHash ¶
func (msg *MsgMiningState) AddVoteHash(hash *chainhash.Hash) error
AddVoteHash adds a new vote hash to the message.
func (*MsgMiningState) BtcDecode ¶
func (msg *MsgMiningState) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMiningState) BtcEncode ¶
func (msg *MsgMiningState) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the protocol encoding. This is part of the Message interface implementation.
func (*MsgMiningState) Command ¶
func (msg *MsgMiningState) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMiningState) MaxPayloadLength ¶
func (msg *MsgMiningState) 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 MsgMixCiphertexts ¶ added in v1.7.0
type MsgMixCiphertexts struct { Signature [64]byte Identity [33]byte SessionID [32]byte Run uint32 Ciphertexts [][1047]byte SeenKeyExchanges []chainhash.Hash // contains filtered or unexported fields }
MsgMixCiphertexts is used by mixing peers to share SNTRUP4591761 ciphertexts with other peers who have published their public keys. It implements the Message interface.
func NewMsgMixCiphertexts ¶ added in v1.7.0
func NewMsgMixCiphertexts(identity [33]byte, sid [32]byte, run uint32, ciphertexts [][1047]byte, seenKeyExchanges []chainhash.Hash) *MsgMixCiphertexts
NewMsgMixCiphertexts returns a new mixcphrtxt message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixCiphertexts) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixCiphertexts) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixCiphertexts) Command ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixCiphertexts) GetRun ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) GetRun() uint32
GetRun returns the run number.
func (*MsgMixCiphertexts) Hash ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixCiphertexts) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixCiphertexts) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) PrevMsgs() []chainhash.Hash
PrevMsgs returns the previous key exchange messages seen by the peer.
func (*MsgMixCiphertexts) Pub ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixCiphertexts) Sid ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) Sid() []byte
Sid returns the session ID.
func (*MsgMixCiphertexts) Sig ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) Sig() []byte
Sig returns the message signature.
func (*MsgMixCiphertexts) WriteHash ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixCiphertexts) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixCiphertexts) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixConfirm ¶ added in v1.7.0
type MsgMixConfirm struct { Signature [64]byte Identity [33]byte SessionID [32]byte Run uint32 Mix MsgTx SeenDCNets []chainhash.Hash // contains filtered or unexported fields }
MsgMixConfirm contains a partially-signed mix transaction, with signatures contributed from the peer identity. When all CM messages are received, signatures can be merged and the transaction may be published, ending a successful mix session.
It implements the Message interface.
func NewMsgMixConfirm ¶ added in v1.7.0
func NewMsgMixConfirm(identity [33]byte, sid [32]byte, run uint32, mix *MsgTx, seenDCNets []chainhash.Hash) *MsgMixConfirm
NewMsgMixConfirm returns a new mixconfirm message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixConfirm) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixConfirm) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixConfirm) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixConfirm) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixConfirm) Command ¶ added in v1.7.0
func (msg *MsgMixConfirm) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixConfirm) GetRun ¶ added in v1.7.0
func (msg *MsgMixConfirm) GetRun() uint32
GetRun returns the run number.
func (*MsgMixConfirm) Hash ¶ added in v1.7.0
func (msg *MsgMixConfirm) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixConfirm) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixConfirm) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixConfirm) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixConfirm) PrevMsgs() []chainhash.Hash
PrevMsgs returns the previous DC messages seen by the peer.
func (*MsgMixConfirm) Pub ¶ added in v1.7.0
func (msg *MsgMixConfirm) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixConfirm) Sid ¶ added in v1.7.0
func (msg *MsgMixConfirm) Sid() []byte
Sid returns the session ID.
func (*MsgMixConfirm) Sig ¶ added in v1.7.0
func (msg *MsgMixConfirm) Sig() []byte
Sig returns the message signature.
func (*MsgMixConfirm) WriteHash ¶ added in v1.7.0
func (msg *MsgMixConfirm) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixConfirm) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixConfirm) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixDCNet ¶ added in v1.7.0
type MsgMixDCNet struct { Signature [64]byte Identity [33]byte SessionID [32]byte Run uint32 DCNet []MixVect SeenSlotReserves []chainhash.Hash // contains filtered or unexported fields }
MsgMixDCNet is the DC-net broadcast. It implements the Message interface.
func NewMsgMixDCNet ¶ added in v1.7.0
func NewMsgMixDCNet(identity [33]byte, sid [32]byte, run uint32, dcnet []MixVect, seenSlotReserves []chainhash.Hash) *MsgMixDCNet
NewMsgMixDCNet returns a new mixdcnet message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixDCNet) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixDCNet) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixDCNet) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixDCNet) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixDCNet) Command ¶ added in v1.7.0
func (msg *MsgMixDCNet) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixDCNet) GetRun ¶ added in v1.7.0
func (msg *MsgMixDCNet) GetRun() uint32
GetRun returns the run number.
func (*MsgMixDCNet) Hash ¶ added in v1.7.0
func (msg *MsgMixDCNet) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixDCNet) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixDCNet) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixDCNet) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixDCNet) PrevMsgs() []chainhash.Hash
PrevMsgs returns the previous SR messages seen by the peer.
func (*MsgMixDCNet) Pub ¶ added in v1.7.0
func (msg *MsgMixDCNet) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixDCNet) Sid ¶ added in v1.7.0
func (msg *MsgMixDCNet) Sid() []byte
Sid returns the session ID.
func (*MsgMixDCNet) Sig ¶ added in v1.7.0
func (msg *MsgMixDCNet) Sig() []byte
Sig returns the message signature.
func (*MsgMixDCNet) WriteHash ¶ added in v1.7.0
func (msg *MsgMixDCNet) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixDCNet) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixDCNet) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixFactoredPoly ¶ added in v1.7.0
type MsgMixFactoredPoly struct { Signature [64]byte Identity [33]byte SessionID [32]byte Run uint32 Roots [][]byte SeenSlotReserves []chainhash.Hash // contains filtered or unexported fields }
MsgMixFactoredPoly encodes the solution of the factored slot reservation polynomial.
func NewMsgMixFactoredPoly ¶ added in v1.7.0
func NewMsgMixFactoredPoly(identity [33]byte, sid [32]byte, run uint32, roots [][]byte, seenSlotReserves []chainhash.Hash) *MsgMixFactoredPoly
NewMsgMixFactoredPoly returns a new mixpairreq message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixFactoredPoly) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixFactoredPoly) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixFactoredPoly) Command ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixFactoredPoly) GetRun ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) GetRun() uint32
GetRun returns the run number.
func (*MsgMixFactoredPoly) Hash ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixFactoredPoly) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixFactoredPoly) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) PrevMsgs() []chainhash.Hash
PrevMsgs returns the previous SR messages seen by the peer.
func (*MsgMixFactoredPoly) Pub ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixFactoredPoly) Sid ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) Sid() []byte
Sid returns the session ID.
func (*MsgMixFactoredPoly) Sig ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) Sig() []byte
Sig returns the message signature.
func (*MsgMixFactoredPoly) WriteHash ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixFactoredPoly) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixFactoredPoly) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixKeyExchange ¶ added in v1.7.0
type MsgMixKeyExchange struct { Signature [64]byte Identity [33]byte SessionID [32]byte Epoch uint64 Run uint32 Pos uint32 ECDH [33]byte // Secp256k1 public key PQPK [1218]byte // Sntrup4591761 public key Commitment [32]byte SeenPRs []chainhash.Hash // contains filtered or unexported fields }
MsgMixKeyExchange implements the Message interface and represents a mixing key exchange message. It includes a commitment to secrets (private keys and discarded mixed addresses) in case they must be revealed for blame assignment.
func NewMsgMixKeyExchange ¶ added in v1.7.0
func NewMsgMixKeyExchange(identity [33]byte, sid [32]byte, epoch uint64, run uint32, pos uint32, ecdh [33]byte, pqpk [1218]byte, commitment [32]byte, seenPRs []chainhash.Hash) *MsgMixKeyExchange
NewMsgMixKeyExchange returns a new mixkeyxchg message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixKeyExchange) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixKeyExchange) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixKeyExchange) Command ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixKeyExchange) GetRun ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) GetRun() uint32
GetRun returns the run number.
func (*MsgMixKeyExchange) Hash ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixKeyExchange) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixKeyExchange) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) PrevMsgs() []chainhash.Hash
PrevMsgs returns the previous PR messages seen by the peer.
func (*MsgMixKeyExchange) Pub ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixKeyExchange) Sid ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) Sid() []byte
Sid returns the session ID.
func (*MsgMixKeyExchange) Sig ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) Sig() []byte
Sig returns the message signature.
func (*MsgMixKeyExchange) WriteHash ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixKeyExchange) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixKeyExchange) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixPairReq ¶ added in v1.7.0
type MsgMixPairReq struct { Signature [64]byte Identity [33]byte Expiry uint32 MixAmount int64 ScriptClass string TxVersion uint16 LockTime uint32 MessageCount uint32 InputValue int64 UTXOs []MixPairReqUTXO Change *TxOut Flags byte PairingFlags byte // contains filtered or unexported fields }
MsgMixPairReq implements the Message interface and represents a mixing pair request message. It describes a type of coinjoin to be created, unmixed data being contributed to the coinjoin, and proof of ability to sign the resulting coinjoin.
func NewMsgMixPairReq ¶ added in v1.7.0
func NewMsgMixPairReq(identity [33]byte, expiry uint32, mixAmount int64, scriptClass string, txVersion uint16, lockTime, messageCount uint32, inputValue int64, utxos []MixPairReqUTXO, change *TxOut, flags, pairingFlags byte) (*MsgMixPairReq, error)
NewMsgMixPairReq returns a new mixpairreq message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixPairReq) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixPairReq) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixPairReq) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixPairReq) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixPairReq) Command ¶ added in v1.7.0
func (msg *MsgMixPairReq) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixPairReq) Expires ¶ added in v1.7.0
func (msg *MsgMixPairReq) Expires() uint32
Expires returns the block height at which the message expires.
func (*MsgMixPairReq) GetRun ¶ added in v1.7.0
func (msg *MsgMixPairReq) GetRun() uint32
GetRun always returns 0. Pair request messages do not belong to a session.
func (*MsgMixPairReq) Hash ¶ added in v1.7.0
func (msg *MsgMixPairReq) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixPairReq) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixPairReq) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixPairReq) Pairing ¶ added in v1.7.0
func (msg *MsgMixPairReq) Pairing() ([]byte, error)
Pairing returns a description of the coinjoin transaction being created. Different mixpairreq messages are compatible to perform a mix together if their pairing descriptions are identical.
func (*MsgMixPairReq) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixPairReq) PrevMsgs() []chainhash.Hash
PrevMsgs always returns nil. Pair request messages are the initial message.
func (*MsgMixPairReq) Pub ¶ added in v1.7.0
func (msg *MsgMixPairReq) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixPairReq) Sid ¶ added in v1.7.0
func (msg *MsgMixPairReq) Sid() []byte
Sid always returns nil. Pair request messages do not belong to a session.
func (*MsgMixPairReq) Sig ¶ added in v1.7.0
func (msg *MsgMixPairReq) Sig() []byte
Sig returns the message signature.
func (*MsgMixPairReq) WriteHash ¶ added in v1.7.0
func (msg *MsgMixPairReq) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixPairReq) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixPairReq) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixSecrets ¶ added in v1.7.0
type MsgMixSecrets struct { Signature [64]byte Identity [33]byte SessionID [32]byte Run uint32 Seed [32]byte SlotReserveMsgs [][]byte DCNetMsgs MixVect SeenSecrets []chainhash.Hash // contains filtered or unexported fields }
MsgMixSecrets reveals secrets of a failed mix run. After secrets are exposed, peers can determine which peers (if any) misbehaved and remove them from the next run in the session.
It implements the Message interface.
func NewMsgMixSecrets ¶ added in v1.7.0
func NewMsgMixSecrets(identity [33]byte, sid [32]byte, run uint32, seed [32]byte, slotReserveMsgs [][]byte, dcNetMsgs MixVect) *MsgMixSecrets
NewMsgMixSecrets returns a new mixsecrets message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixSecrets) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixSecrets) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixSecrets) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixSecrets) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixSecrets) Command ¶ added in v1.7.0
func (msg *MsgMixSecrets) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixSecrets) Commitment ¶ added in v1.7.0
func (msg *MsgMixSecrets) Commitment(h hash.Hash) chainhash.Hash
Commitment returns a hash committing to the contents of the reveal secrets message without committing to any previous seen messages or the message signature. This is the hash that is referenced by peers' key exchange messages.
func (*MsgMixSecrets) GetRun ¶ added in v1.7.0
func (msg *MsgMixSecrets) GetRun() uint32
GetRun returns the run number.
func (*MsgMixSecrets) Hash ¶ added in v1.7.0
func (msg *MsgMixSecrets) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixSecrets) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixSecrets) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixSecrets) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixSecrets) PrevMsgs() []chainhash.Hash
PrevMsgs returns previously revealed secrets messages by other peers. An honest peer who needs to report blame assignment does not need to reference any previous secrets messages, and a secrets message with other referenced secrets is necessary to begin blame assignment. Dishonest peers who initially reveal their secrets without blame assignment being necessary are themselves removed in future runs.
func (*MsgMixSecrets) Pub ¶ added in v1.7.0
func (msg *MsgMixSecrets) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixSecrets) Sid ¶ added in v1.7.0
func (msg *MsgMixSecrets) Sid() []byte
Sid returns the session ID.
func (*MsgMixSecrets) Sig ¶ added in v1.7.0
func (msg *MsgMixSecrets) Sig() []byte
Sig returns the message signature.
func (*MsgMixSecrets) WriteHash ¶ added in v1.7.0
func (msg *MsgMixSecrets) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixSecrets) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixSecrets) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgMixSlotReserve ¶ added in v1.7.0
type MsgMixSlotReserve struct { Signature [64]byte Identity [33]byte SessionID [32]byte Run uint32 DCMix [][][]byte // mcount-by-peers matrix of field numbers SeenCiphertexts []chainhash.Hash // contains filtered or unexported fields }
MsgMixSlotReserve is the slot reservation broadcast. It implements the Message interface.
func NewMsgMixSlotReserve ¶ added in v1.7.0
func NewMsgMixSlotReserve(identity [33]byte, sid [32]byte, run uint32, dcmix [][][]byte, seenCTs []chainhash.Hash) *MsgMixSlotReserve
NewMsgMixSlotReserve returns a new mixslotres message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgMixSlotReserve) BtcDecode ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMixSlotReserve) BtcEncode ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgMixSlotReserve) Command ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMixSlotReserve) GetRun ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) GetRun() uint32
GetRun returns the run number.
func (*MsgMixSlotReserve) Hash ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) Hash() chainhash.Hash
Hash returns the message hash calculated by WriteHash.
Hash returns an invalid or zero hash if WriteHash has not been called yet.
This method is not safe while concurrently calling WriteHash.
func (*MsgMixSlotReserve) MaxPayloadLength ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgMixSlotReserve) PrevMsgs ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) PrevMsgs() []chainhash.Hash
PrevMsgs returns the previous CT messages seen by the peer.
func (*MsgMixSlotReserve) Pub ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) Pub() []byte
Pub returns the message sender's public key identity.
func (*MsgMixSlotReserve) Sid ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) Sid() []byte
Sid returns the session ID.
func (*MsgMixSlotReserve) Sig ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) Sig() []byte
Sig returns the message signature.
func (*MsgMixSlotReserve) WriteHash ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) WriteHash(h hash.Hash)
WriteHash serializes the message to a hasher and records the sum in the message's Hash field.
The hasher's Size() must equal chainhash.HashSize, or this method will panic. This method is designed to work only with hashers returned by blake256.New.
func (*MsgMixSlotReserve) WriteSignedData ¶ added in v1.7.0
func (msg *MsgMixSlotReserve) WriteSignedData(h hash.Hash)
WriteSignedData writes a tag identifying the message data, followed by all message fields excluding the signature. This is the data committed to when the message is signed.
type MsgNotFound ¶
type MsgNotFound struct {
InvList []*InvVect
}
MsgNotFound defines a Decred notfound message which is sent in response to a getdata message if any of the requested data in not available on the peer. 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 peer.
func NewMsgNotFound ¶
func NewMsgNotFound() *MsgNotFound
NewMsgNotFound returns a new Decred 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) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred 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 Decred 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 peer 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 Decred ping message that conforms to the Message interface. See MsgPing for details.
func (*MsgPing) BtcDecode ¶
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPing) BtcEncode ¶
BtcEncode encodes the receiver to w using the Decred 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 Decred pong message which is used primarily to confirm that a connection is still valid in response to a Decred ping message (MsgPing).
This message was not added until protocol versions AFTER BIP0031Version.
func NewMsgPong ¶
NewMsgPong returns a new Decred pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgPong) BtcDecode ¶
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPong) BtcEncode ¶
BtcEncode encodes the receiver to w using the Decred 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 MsgReject
deprecated
type MsgReject struct { // Cmd is the command for the message which was rejected such 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 Decred reject message.
Deprecated: This message is no longer valid as of protocol version RemoveRejectVersion.
func NewMsgReject ¶
func NewMsgReject(command string, code RejectCode, reason string) *MsgReject
NewMsgReject returns a new Decred reject message that conforms to the Message interface. See MsgReject for details.
func (*MsgReject) BtcDecode ¶
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgReject) BtcEncode ¶
BtcEncode encodes the receiver to w using the Decred 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 peer 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) 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) 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 ¶
type MsgTx struct { CachedHash *chainhash.Hash SerType TxSerializeType Version uint16 TxIn []*TxIn TxOut []*TxOut LockTime uint32 Expiry uint32 // In blocks }
MsgTx implements the Message interface and represents a Decred 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 ¶
func NewMsgTx() *MsgTx
NewMsgTx returns a new Decred 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 Decred 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 Decred 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) BytesPrefix ¶
BytesPrefix returns the serialized form of the transaction prefix in bytes.
func (*MsgTx) BytesWitness ¶
BytesWitness returns the serialized form of the transaction prefix in bytes.
func (*MsgTx) CachedTxHash ¶
CachedTxHash is equivalent to calling TxHash, however it caches the result so subsequent calls do not have to recalculate the hash. It can be recalculated later with RecacheTxHash.
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 Decred 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) 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. TODO: Make this work for all serialization types, not just the full serialization type.
func (*MsgTx) RecacheTxHash ¶
RecacheTxHash is equivalent to calling TxHash, however it replaces the cached result so future calls to CachedTxHash will return this newly calculated hash.
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 Decred 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) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the transaction.
func (*MsgTx) TxHash ¶
TxHash generates the hash for the transaction prefix. Since it does not contain any witness data, it is not malleable and therefore is stable for use in unconfirmed transaction chains.
func (*MsgTx) TxHashFull ¶
TxHashFull generates the hash for the transaction prefix || witness. It first obtains the hashes for both the transaction prefix and witness, then concatenates them and hashes the result.
func (*MsgTx) TxHashWitness ¶
TxHashWitness generates the hash for the transaction witness.
type MsgVerAck ¶
type MsgVerAck struct{}
MsgVerAck defines a Decred verack message which is used for a peer 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 Decred verack message that conforms to the Message interface.
func (*MsgVerAck) BtcDecode ¶
BtcDecode decodes r using the Decred protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgVerAck) BtcEncode ¶
BtcEncode encodes the receiver to w using the Decred 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 // 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 peer. AddrYou NetAddress // Address of the local peer. AddrMe NetAddress // Unique value associated with message that is used to detect self // connections. Nonce uint64 // The user agent that generated message. This is 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 // Don't announce transactions to peer. DisableRelayTx bool }
MsgVersion implements the Message interface and represents a Decred version message. It is used for a peer to advertise itself as soon as an outbound connection is made. The remote peer then uses this information along with its own to negotiate. The remote peer 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(me *NetAddress, you *NetAddress, nonce uint64, lastBlock int32) *MsgVersion
NewMsgVersion returns a new Decred version message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func NewMsgVersionFromConn ¶
NewMsgVersionFromConn is a convenience function that extracts the remote and local address from conn and returns a new Decred version message that conforms to the Message interface. See NewMsgVersion.
func (*MsgVersion) AddService ¶
func (msg *MsgVersion) AddService(service ServiceFlag)
AddService adds service as a supported service by the peer 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) error
BtcDecode decodes r using the Decred 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) error
BtcEncode encodes the receiver to w using the Decred protocol encoding. This is part of the Message interface implementation.
func (*MsgVersion) Command ¶
func (msg *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 peer 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 Decred 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 peer. IP net.IP // Port the peer is using. This is encoded in big endian on the wire // which differs from most everything else. Port uint16 }
NetAddress defines information about a peer 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.Addr, services ServiceFlag) (*NetAddress, error)
NewNetAddress returns a new NetAddress using the provided TCP address and supported services with defaults for the remaining fields.
Note that addr must be a net.TCPAddr. An ErrInvalidNetAddr is returned if it is not.
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 peer 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 Decred data type that is used to track previous transaction outputs.
func NewOutPoint ¶
NewOutPoint returns a new Decred transaction outpoint point with the provided hash and index.
type RejectCode ¶
type RejectCode uint8
RejectCode represents a numeric value by which a remote peer 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 Decred peer.
const ( // SFNodeNetwork is a flag used to indicate a peer is a full node. SFNodeNetwork ServiceFlag = 1 << iota // SFNodeBloom is a flag used to indicate a peer supports bloom // filtering. SFNodeBloom // SFNodeCF is a flag used to indicate a peer supports v1 gcs filters // (CFs). SFNodeCF )
func (ServiceFlag) String ¶
func (f ServiceFlag) String() string
String returns the ServiceFlag in human-readable form.
type TxIn ¶
type TxIn struct { // Non-witness PreviousOutPoint OutPoint Sequence uint32 // Witness ValueIn int64 BlockHeight uint32 BlockIndex uint32 SignatureScript []byte }
TxIn defines a Decred transaction input.
func NewTxIn ¶
NewTxIn returns a new Decred transaction input with the provided previous outpoint point and signature script with a default sequence of MaxTxInSequenceNum.
func (*TxIn) SerializeSizePrefix ¶
SerializeSizePrefix returns the number of bytes it would take to serialize the transaction input for a prefix.
func (*TxIn) SerializeSizeWitness ¶
SerializeSizeWitness returns the number of bytes it would take to serialize the transaction input for a witness.
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 Decred transaction output.
func NewTxOut ¶
NewTxOut returns a new Decred 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 transaction output.
type TxSerializeType ¶
type TxSerializeType uint16
TxSerializeType represents the serialized type of a transaction.
const ( // TxSerializeFull indicates a transaction be serialized with the prefix // and all witness data. TxSerializeFull TxSerializeType = iota // TxSerializeNoWitness indicates a transaction be serialized with only // the prefix. TxSerializeNoWitness // TxSerializeOnlyWitness indicates a transaction be serialized with // only the witness data. TxSerializeOnlyWitness )
Source Files ¶
- blockheader.go
- common.go
- doc.go
- error.go
- invvect.go
- message.go
- mixvect.go
- msgaddr.go
- msgblock.go
- msgcfheaders.go
- msgcfilter.go
- msgcfiltersv2.go
- msgcfilterv2.go
- msgcftypes.go
- msgfeefilter.go
- msggetaddr.go
- msggetblocks.go
- msggetcfheaders.go
- msggetcfilter.go
- msggetcfilterv2.go
- msggetcfsv2.go
- msggetcftypes.go
- msggetdata.go
- msggetheaders.go
- msggetinitstate.go
- msggetminingstate.go
- msgheaders.go
- msginitstate.go
- msginv.go
- msgmempool.go
- msgminingstate.go
- msgmixciphertexts.go
- msgmixconfirm.go
- msgmixdcnet.go
- msgmixfactoredpoly.go
- msgmixkeyexchange.go
- msgmixpairreq.go
- msgmixsecrets.go
- msgmixslotreserve.go
- msgnotfound.go
- msgping.go
- msgpong.go
- msgreject.go
- msgsendheaders.go
- msgtx.go
- msgverack.go
- msgversion.go
- netaddress.go
- protocol.go