Documentation ¶
Overview ¶
Package wire implements the bitcoin wire protocol.
For the complete details of the bitcoin protocol, see the official wiki entry at https://en.bitcoin.it/wiki/Protocol_specification. The following only serves as a quick overview to provide information on how to use the package.
At a high level, this package provides support for marshalling and unmarshalling supported bitcoin messages to and from the wire. This package does not deal with the specifics of message handling such as what to do when a message is received. This provides the caller with a high level of flexibility.
Bitcoin Message Overview ¶
The bitcoin protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which bitcoin network it is a part of, its type, how big it is, and a checksum to verify validity. All encoding and decoding of message headers is handled by this package.
To accomplish this, there is a generic interface for bitcoin messages named Message which allows messages of any type to be read, written, or passed around through channels, functions, etc. In addition, concrete implementations of most of the currently supported bitcoin messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the wire using bitcoin encoding are handled so the caller doesn't have to concern themselves with the specifics.
Message Interaction ¶
The following provides a quick summary of how the bitcoin messages are intended to interact with one another. As stated above, these interactions are not directly handled by this package. For more in-depth details about the appropriate interactions, see the official bitcoin protocol wiki entry at https://en.bitcoin.it/wiki/Protocol_specification.
The initial handshake consists of two peers sending each other a version message (MsgVersion) followed by responding with a verack message (MsgVerAck). Both peers use the information in the version message (MsgVersion) to negotiate things such as protocol version and supported services with each other. Once the initial handshake is complete, the following chart indicates message interactions in no particular order.
Peer A Sends Peer B Responds ---------------------------------------------------------------------------- getaddr message (MsgGetAddr) addr message (MsgAddr) getblocks message (MsgGetBlocks) inv message (MsgInv) inv message (MsgInv) getdata message (MsgGetData) getdata message (MsgGetData) block message (MsgBlock) -or- tx message (MsgTx) -or- notfound message (MsgNotFound) getheaders message (MsgGetHeaders) headers message (MsgHeaders) ping message (MsgPing) pong message (MsgHeaders)* -or- (none -- Ability to send message is enough) NOTES: * The pong message was not added until later protocol versions as defined in BIP0031. The BIP0031Version constant can be used to detect a recent enough protocol version for this purpose (version > BIP0031Version).
Common Parameters ¶
There are several common parameters that arise when using this package to read and write bitcoin messages. The following sections provide a quick overview of these parameters so the next sections can build on them.
Protocol Version ¶
The protocol version should be negotiated with the remote 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.
Bitcoin Network ¶
The bitcoin network is a magic number which is used to identify the start of a message and which bitcoin network the message applies to. This package provides the following constants:
wire.MainNet wire.TestNet (Regression test network) wire.TestNet3 (Test network version 3) wire.SimNet (Simulation test network)
Determining Message Type ¶
As discussed in the bitcoin message overview section, this package reads and writes bitcoin messages using a generic interface named Message. In order to determine the actual concrete type of the message, use a type switch or type assertion. An example of a type switch follows:
// Assumes msg is already a valid concrete message such as one created // via NewMsgVersion or read via ReadMessage. switch msg := msg.(type) { case *wire.MsgVersion: // The message is a pointer to a MsgVersion struct. fmt.Printf("Protocol version: %v", msg.ProtocolVersion) case *wire.MsgBlock: // The message is a pointer to a MsgBlock struct. fmt.Printf("Number of tx in block: %v", msg.Header.TxnCount) }
Reading Messages ¶
In order to unmarshall bitcoin messages from the wire, use the ReadMessage function. It accepts any io.Reader, but typically this will be a net.Conn to a remote node running a bitcoin peer. Example syntax is:
// Reads and validates the next bitcoin message from conn using the // protocol version pver and the bitcoin network btcnet. The returns // are a wire.Message, a []byte which contains the unmarshalled // raw payload, and a possible error. msg, rawPayload, err := wire.ReadMessage(conn, pver, btcnet) if err != nil { // Log and handle the error }
Writing Messages ¶
In order to marshall bitcoin messages to the wire, use the WriteMessage function. It accepts any io.Writer, but typically this will be a net.Conn to a remote node running a bitcoin peer. Example syntax to request addresses from a remote peer is:
// Create a new getaddr bitcoin message. msg := wire.NewMsgGetAddr() // Writes a bitcoin message msg to conn using the protocol version // pver, and the bitcoin network btcnet. The return is a possible // error. err := wire.WriteMessage(conn, msg, pver, btcnet) if err != nil { // Log and handle the error }
Errors ¶
Errors returned by this package are either the raw errors provided by underlying calls to read/write from streams such as io.EOF, io.ErrUnexpectedEOF, and io.ErrShortWrite, or of type wire.MessageError. This allows the caller to differentiate between general IO errors and malformed messages through type assertions.
Bitcoin Improvement Proposals ¶
This package includes spec changes outlined by the following BIPs:
BIP0014 (https://en.bitcoin.it/wiki/BIP_0014) BIP0031 (https://en.bitcoin.it/wiki/BIP_0031) BIP0035 (https://en.bitcoin.it/wiki/BIP_0035) BIP0037 (https://en.bitcoin.it/wiki/BIP_0037)
Index ¶
- Constants
- Variables
- func DoubleSha256(b []byte) []byte
- func Init()
- func RandomUint64() (uint64, error)
- func Sha256(b []byte) []byte
- func VarIntSerializeSize(val uint64) int
- func WriteMessage(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) error
- func WriteMessageN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) (int, error)
- type Alert
- type BitcoinNet
- type BlockHeader
- type BloomUpdateType
- type ECPubKey
- type FtmInternalMsg
- type IMsgFactoidTX
- type InvType
- type InvVect
- type Message
- type MessageError
- type MsgABlock
- type MsgAcknowledgement
- func (msg *MsgAcknowledgement) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgAcknowledgement) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgAcknowledgement) Command() string
- func (msg *MsgAcknowledgement) GetBinaryForSignature() (data []byte, err error)
- func (msg *MsgAcknowledgement) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgAcknowledgement) Sha() (ShaHash, error)
- 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 MsgAlert
- type MsgBlock
- func (msg *MsgBlock) AddTransaction(tx *MsgTx) error
- func (msg *MsgBlock) BlockSha() (ShaHash, error)
- func (msg *MsgBlock) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgBlock) BtcEncode(w io.Writer, pver uint32) error
- 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, error)
- func (msg *MsgBlock) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgBlock) Serialize(w io.Writer) error
- func (msg *MsgBlock) SerializeSize() int
- func (msg *MsgBlock) TxShas() ([]ShaHash, error)
- type MsgCommitChain
- func (msg *MsgCommitChain) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgCommitChain) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgCommitChain) Command() string
- func (msg *MsgCommitChain) IsValid() bool
- func (msg *MsgCommitChain) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgCommitChain) Sha() (ShaHash, error)
- type MsgCommitEntry
- func (msg *MsgCommitEntry) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgCommitEntry) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgCommitEntry) Command() string
- func (msg *MsgCommitEntry) IsValid() bool
- func (msg *MsgCommitEntry) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgCommitEntry) Sha() (ShaHash, error)
- type MsgDirBlock
- type MsgDirInv
- type MsgEBlock
- type MsgECBlock
- type MsgEntry
- type MsgFBlock
- type MsgFactoidTX
- func (msg *MsgFactoidTX) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgFactoidTX) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgFactoidTX) Command() string
- func (msg *MsgFactoidTX) IsValid() bool
- func (msg *MsgFactoidTX) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgFactoidTX) SetTransaction(transaction fct.ITransaction)
- func (msg *MsgFactoidTX) Sha() (ShaHash, error)
- type MsgFilterAdd
- type MsgFilterClear
- type MsgFilterLoad
- type MsgGetAddr
- type MsgGetBlocks
- func (msg *MsgGetBlocks) AddBlockLocatorHash(hash *ShaHash) 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 MsgGetData
- type MsgGetDirBlocks
- func (msg *MsgGetDirBlocks) AddBlockLocatorHash(hash *ShaHash) error
- func (msg *MsgGetDirBlocks) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetDirBlocks) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetDirBlocks) Command() string
- func (msg *MsgGetDirBlocks) MaxPayloadLength(pver uint32) uint32
- type MsgGetDirData
- type MsgGetEntryData
- func (msg *MsgGetEntryData) AddInvVect(iv *InvVect) error
- func (msg *MsgGetEntryData) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetEntryData) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetEntryData) Command() string
- func (msg *MsgGetEntryData) MaxPayloadLength(pver uint32) uint32
- type MsgGetHeaders
- func (msg *MsgGetHeaders) AddBlockLocatorHash(hash *ShaHash) 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 MsgGetNonDirData
- func (msg *MsgGetNonDirData) AddInvVect(iv *InvVect) error
- func (msg *MsgGetNonDirData) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgGetNonDirData) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgGetNonDirData) Command() string
- func (msg *MsgGetNonDirData) MaxPayloadLength(pver uint32) uint32
- type MsgHeaders
- type MsgInt_DirBlock
- type MsgInt_EOM
- type MsgInt_FactoidBlock
- type MsgInv
- type MsgMemPool
- type MsgNotFound
- type MsgPing
- type MsgPong
- type MsgReject
- type MsgRevealChain
- type MsgRevealEntry
- func (msg *MsgRevealEntry) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgRevealEntry) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgRevealEntry) Command() string
- func (msg *MsgRevealEntry) IsValid() bool
- func (msg *MsgRevealEntry) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgRevealEntry) Sha() (ShaHash, error)
- type MsgTestCredit
- func (msg *MsgTestCredit) BtcDecode(r io.Reader, pver uint32) error
- func (msg *MsgTestCredit) BtcEncode(w io.Writer, pver uint32) error
- func (msg *MsgTestCredit) Command() string
- func (m *MsgTestCredit) MarshalBinary() ([]byte, error)
- func (msg *MsgTestCredit) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgTestCredit) Sha() (ShaHash, error)
- func (m *MsgTestCredit) UnmarshalBinary(data []byte) error
- type MsgTx
- func (msg *MsgTx) AddECOut(eco *TxEntryCreditOut)
- 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) Command() string
- func (msg *MsgTx) Deserialize(r io.Reader) error
- func (msg *MsgTx) MaxPayloadLength(pver uint32) uint32
- func (msg *MsgTx) Serialize(w io.Writer) error
- func (msg *MsgTx) SerializeSize() int
- func (msg *MsgTx) TxSha() (ShaHash, error)
- 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 PubKey
- type RCDHash
- type RCDreveal
- type RejectCode
- type ServiceFlag
- type Sha3Hash
- type ShaHash
- type TxEntryCreditOut
- type TxIn
- type TxLoc
- type TxOut
- type TxSig
Constants ¶
const ( // Factom internal messages: CmdInt_FactoidObj = "int_factoidobj" CmdInt_FactoidBlock = "int_fx_block" CmdInt_EOM = "int_eom" CmdInt_DirBlock = "int_dir_block" )
Commands used in bitcoin message headers which describe the type of message.
const ( BLOCK_QUERY_STATUS uint8 = iota BLOCK_BUILD_SUCCESS BLOCK_BUILD_FAILED BLOCK_NOT_FOUND BLOCK_NOT_VALID )
Block status code
const ( CmdVersion = "version" CmdVerAck = "verack" CmdGetAddr = "getaddr" CmdAddr = "addr" CmdGetBlocks = "getblocks" CmdInv = "inv" CmdGetData = "getdata" CmdNotFound = "notfound" CmdBlock = "block" // Factoid-0 Block CmdTx = "tx" // Factoid-0 Tx CmdFBlock = "FBlock" // Factoid-1 Block CmdFactoidTX = "factoidtx" // Factoid-1 Tx CmdGetHeaders = "getheaders" CmdHeaders = "headers" CmdPing = "ping" CmdPong = "pong" CmdAlert = "alert" CmdMemPool = "mempool" CmdFilterAdd = "filteradd" CmdFilterClear = "filterclear" CmdFilterLoad = "filterload" CmdReject = "reject" // TODO remove CmdTestCred before production CmdTestCredit = "testcredit" // Factom downloads: block & entry CmdGetDirBlocks = "getdirblocks" CmdDirInv = "dirInv" CmdGetDirData = "getdirdata" CmdDirBlock = "dirblock" CmdGetNonDirData = "getnodirdata" CmdABlock = "adminblock" // Admin Block CmdECBlock = "ecblock" // Entry Credit Block CmdEBlock = "entryblock" // Entry Block CmdGetEntryData = "getentrydata" CmdEntry = "entry" CmdCommitChain = "commitchain" CmdRevealChain = "revealchain" CmdCommitEntry = "commitentry" CmdRevealEntry = "revealentry" CmdAcknowledgement = "confirmation" CmdMHashReveal = "mhashreveal" )
Commands used in bitcoin message headers which describe the type of message.
const ( ACK_FACTOID_TX uint8 = iota END_MINUTE_1 END_MINUTE_2 END_MINUTE_3 END_MINUTE_4 END_MINUTE_5 END_MINUTE_6 END_MINUTE_7 END_MINUTE_8 END_MINUTE_9 END_MINUTE_10 ACK_REVEAL_ENTRY ACK_COMMIT_CHAIN ACK_REVEAL_CHAIN ACK_COMMIT_ENTRY FORCE_FACTOID_GENESIS_REBUILD // FORCE_FACTOID_VALIDATION // at a specific block height; everything higher will be discarded by btcd-side (possibly creating orphaned blocks) INFO_CURRENT_HEIGHT // info message to the wire-side to indicate the current known block height; a duplicate of FORCE_FACTOID_VALIDATION (???) )
Acknowledgement Type
const ( // MaxFilterLoadHashFuncs is the maximum number of hash functions to // load into the Bloom filter. MaxFilterLoadHashFuncs = 50 // MaxFilterLoadFilterSize is the maximum size in bytes a filter may be. MaxFilterLoadFilterSize = 36000 )
const ( // ProtocolVersion is the latest protocol version this package supports. ProtocolVersion uint32 = 70002 // MultipleAddressVersion is the protocol version which added multiple // addresses per message (pver >= MultipleAddressVersion). MultipleAddressVersion uint32 = 209 // NetAddressTimeVersion is the protocol version which added the // timestamp field (pver >= NetAddressTimeVersion). NetAddressTimeVersion uint32 = 31402 // BIP0031Version is the protocol version AFTER which a pong message // and nonce field in ping were added (pver > BIP0031Version). BIP0031Version uint32 = 60000 // BIP0035Version is the protocol version which added the mempool // message (pver >= BIP0035Version). BIP0035Version uint32 = 60002 // BIP0037Version is the protocol version which added new connection // bloom filtering related messages and extended the version message // with a relay flag (pver >= BIP0037Version). BIP0037Version uint32 = 70001 // RejectVersion is the protocol version which added a new reject // message. RejectVersion uint32 = 70002 )
const CommandSize = 12
CommandSize is the fixed size of all commands in the common bitcoin message header. Shorter commands must be zero padded.
const DefaultUserAgent = "/btcwire:0.2.0/"
DefaultUserAgent for wire in the stack
const Hash3Size = 32
Size of array used to store sha hashes. See Sha3Hash.
const HashSize = 32
Size of array used to store sha hashes. See ShaHash.
const Max3HashStringSize = Hash3Size * 2
MaxHashStringSize is the maximum length of a Sha3Hash hash string.
const MaxAddrPerMsg = 1000
MaxAddrPerMsg is the maximum number of addresses that can be in a single bitcoin addr message (MsgAddr).
const MaxAppMsgPayload = (20 * 1024) // 20Kib
MaxAppMsgPayload is the maximum bytes a factom app message can be in bytes.
const MaxBlockHeadersPerMsg = 2000
MaxBlockHeadersPerMsg is the maximum number of block headers that can be in a single bitcoin headers message.
const MaxBlockLocatorsPerMsg = 500
MaxBlockLocatorsPerMsg is the maximum number of block locator hashes allowed per message.
const MaxBlockMsgPayload = (1024 * 1024 * 32) // 32MB
const MaxBlockPayload = 1000000 // Not actually 1MB which would be 1024 * 1024
MaxBlockPayload is the maximum bytes a block message can be in bytes.
const MaxBlocksPerMsg = 500
MaxBlocksPerMsg is the maximum number of blocks allowed per message.
const ( // MaxFilterAddDataSize is the maximum byte size of a data // element to add to the Bloom filter. It is equal to the // maximum element size of a script. MaxFilterAddDataSize = 520 )
const MaxHashStringSize = HashSize * 2
MaxHashStringSize is the maximum length of a ShaHash hash string.
const ( // MaxInvPerMsg is the maximum number of inventory vectors that can be in a // single bitcoin inv message. MaxInvPerMsg = 50000 )
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 MaxUserAgentLen = 2000
MaxUserAgentLen is the maximum allowed length for the user agent field in a version message (MsgVersion).
const MaxVarIntPayload = 9
Maximum payload size for a variable length integer.
const MessageHeaderSize = 24
MessageHeaderSize is the number of bytes in a bitcoin message header. Bitcoin network (magic) 4 bytes + command 12 bytes + payload length 4 bytes + checksum 4 bytes.
const PubKeySize = 32
const RCDHashSize = 32
const (
TxVersion = 0
)
Variables ¶
var ( // Shared constants FChainID *common.Hash CreditsPerChain int32 // BTCD State Variables FactoshisPerCredit uint64 )
var Err3HashStrSize = fmt.Errorf("max hash string length for sha3 is %v bytes", Max3HashStringSize)
ErrHashStrSize describes an error that indicates the caller specified a hash string that has too many characters.
var ErrHashStrSize = fmt.Errorf("max hash string length is %v bytes", MaxHashStringSize)
ErrHashStrSize describes an error that indicates the caller specified a hash string that has too many characters.
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 DoubleSha256 ¶
DoubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
func RandomUint64 ¶
RandomUint64 returns a cryptographically random uint64 value.
func VarIntSerializeSize ¶
VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.
func WriteMessage ¶
WriteMessage writes a bitcoin Message to w including the necessary header information. This function is the same as WriteMessageN except it doesn't doesn't return the number of bytes written. This function is mainly provided for backwards compatibility with the original API, but it's also useful for callers that don't care about byte counts.
func WriteMessageN ¶
WriteMessageN writes a bitcoin Message to w including the necessary header information and returns the number of bytes written. This function is the same as WriteMessage except it also returns the number of bytes written.
Types ¶
type Alert ¶
type Alert struct { // Alert format version Version int32 // Timestamp beyond which nodes should stop relaying this alert RelayUntil int64 // Timestamp beyond which this alert is no longer in effect and // should be ignored Expiration int64 // A unique ID number for this alert ID int32 // All alerts with an ID less than or equal to this number should // cancelled, deleted and not accepted in the future Cancel int32 // All alert IDs contained in this set should be cancelled as above SetCancel []int32 // This alert only applies to versions greater than or equal to this // version. Other versions should still relay it. MinVer int32 // This alert only applies to versions less than or equal to this version. // Other versions should still relay it. MaxVer int32 // If this set contains any elements, then only nodes that have their // subVer contained in this set are affected by the alert. Other versions // should still relay it. SetSubVer []string // Relative priority compared to other alerts Priority int32 // A comment on the alert that is not displayed Comment string // The alert message that is displayed to the user StatusBar string // Reserved Reserved string }
Alert contains the data deserialized from the MsgAlert payload.
func NewAlert ¶
func NewAlert(version int32, relayUntil int64, expiration int64, id int32, cancel int32, setCancel []int32, minVer int32, maxVer int32, setSubVer []string, priority int32, comment string, statusBar string) *Alert
NewAlert returns an new Alert with values provided.
func NewAlertFromPayload ¶
NewAlertFromPayload returns an Alert with values deserialized from the serialized payload.
func (*Alert) Deserialize ¶
Deserialize decodes from r into the receiver using the alert protocol encoding format.
type BitcoinNet ¶
type BitcoinNet uint32
BitcoinNet represents which bitcoin network a message belongs to.
const ( // MainNet represents the main factom network, AKA the magic number // MainNet BitcoinNet = 0xd9b4bef9 MainNet BitcoinNet = 0xFA92E5A1 // TestNet represents the regression test network. TestNet BitcoinNet = 0xdab5bffa // TestNet3 represents the test network (version 3). TestNet3 BitcoinNet = 0x0709110b // SimNet represents the simulation test network. SimNet BitcoinNet = 0x12141c16 )
Constants used to indicate the message bitcoin network. They can also be used to seek to the next message when a stream's state is unknown, but this package does not provide that functionality since it's generally a better idea to simply disconnect clients that are misbehaving over TCP.
func (BitcoinNet) String ¶
func (n BitcoinNet) String() string
String returns the BitcoinNet in human-readable form.
type BlockHeader ¶
type BlockHeader struct { ChainID ShaHash // ChainID. But since this is a constant, we need not actually use space to store it. MerkleRoot ShaHash // Merkle root of the Factoid transactions which accompany this block. PrevBlock ShaHash // Key Merkle root of previous block. PrevHash3 Sha3Hash // Sha3 of the previous Factoid Block ExchRate uint64 // Factoshis per Entry Credit DBHeight uint32 // Directory Block height UTXOCommit ShaHash // This field will hold a Merkle root of an array containing all unspent transactions. // transaction count & body size are "read-only" (future) fields since serialization logic is handling both TransCnt uint64 // Count of transactions in this block BodySize uint64 // Bytes in the body of this block. }
BlockHeader defines information about a block and is used in the bitcoin block (MsgBlock) and headers (MsgHeaders) messages.
func NewBlockHeader ¶
func NewBlockHeader(prevHash *ShaHash, merkleRootHash *ShaHash) *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) BlockSha ¶
func (h *BlockHeader) BlockSha() (ShaHash, error)
BlockSha computes the block identifier hash for the given 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.
type BloomUpdateType ¶
type BloomUpdateType uint8
BloomUpdateType specifies how the filter is updated when a match is found
const ( // BloomUpdateNone indicates the filter is not adjusted when a match is // found. BloomUpdateNone BloomUpdateType = 0 // BloomUpdateAll indicates if the filter matches any data element in a // public key script, the outpoint is serialized and inserted into the // filter. BloomUpdateAll BloomUpdateType = 1 // BloomUpdateP2PubkeyOnly indicates if the filter matches a data // element in a public key script and the script is of the standard // pay-to-pubkey or multisig, the outpoint is serialized and inserted // into the filter. BloomUpdateP2PubkeyOnly BloomUpdateType = 2 )
type ECPubKey ¶
type ECPubKey [PubKeySize]byte
type FtmInternalMsg ¶
type FtmInternalMsg interface {
Command() string
}
FtmInternalMsg is an interface that describes an internal factom message. The message is used for communication between two modules
type IMsgFactoidTX ¶
type IMsgFactoidTX interface { // Set the Transaction to be carried by this message. SetTransaction(fct.ITransaction) // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. // This is part of the Message interface implementation. BtcEncode(w io.Writer, pver uint32) error // BtcDecode decodes r using the bitcoin protocol encoding into the receiver. // This is part of the Message interface implementation. BtcDecode(r io.Reader, pver uint32) error // Command returns the protocol command string for the message. This is part // of the Message interface implementation. Command() string // MaxPayloadLength returns the maximum length the payload can be for the // receiver. This is part of the Message interface implementation. MaxPayloadLength(pver uint32) uint32 // NewMsgCommitEntry returns a new bitcoin Commit Entry message that conforms to // the Message interface. NewMsgFactoidTX() IMsgFactoidTX // Check whether the msg can pass the message level validations // such as timestamp, signiture and etc IsValid() bool // Create a sha hash from the message binary (output of BtcEncode) Sha() (ShaHash, error) }
func NewMsgFactoidTX ¶
func NewMsgFactoidTX() IMsgFactoidTX
NewMsgCommitEntry returns a new bitcoin Commit Entry message that conforms to the Message interface.
type InvType ¶
type InvType uint32
InvType represents the allowed types of inventory vectors. See InvVect.
const ( InvTypeError InvType = 0 InvTypeTx InvType = 1 // Factoid tx InvTypeBlock InvType = 2 // Factoid block InvTypeFactomDirBlock InvType = 14 InvTypeFactomEntryBlock InvType = 15 InvTypeFactomEntry InvType = 16 InvTypeFactomEntryCreditBlock InvType = 17 InvTypeFactomNonDirBlock InvType = 18 InvTypeFactomAdminBlock InvType = 19 InvTypeFactomFBlock InvType = 20 InvTypeFactomControl InvType = 50 // Factom control messages InvTypeFactomRaw InvType = 99 // Factom raw )
These constants define the various supported inventory vector types.
type InvVect ¶
InvVect defines a bitcoin 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.
func NewInvVect ¶
NewInvVect returns a new InvVect using the provided type and hash.
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 bitcoin message. A type that implements Message has complete control over the representation of its data and may therefore contain additional or fewer fields than those which are used directly in the protocol encoded message.
func ReadMessage ¶
ReadMessage reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the parsed Message and raw bytes which comprise the message. This function only differs from ReadMessageN in that it doesn't return the number of bytes read. This function is mainly provided for backwards compatibility with the original API, but it's also useful for callers that don't care about byte counts.
func ReadMessageN ¶
ReadMessageN reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the number of bytes read in addition to the parsed Message and raw bytes which comprise the message. This function is the same as ReadMessage except it also returns the number of bytes read.
type MessageError ¶
type MessageError struct { Func string // Function name Description string // Human readable description of the issue // contains filtered or unexported fields }
MessageError describes an issue with a message. An example of some potential issues are messages from the wrong bitcoin network, invalid commands, mismatched checksums, and exceeding max payloads.
This provides a mechanism for the caller to type assert the error to differentiate between general io errors such as io.EOF and issues that resulted from malformed messages.
func (*MessageError) Error ¶
func (e *MessageError) Error() string
Error satisfies the error interface and prints human-readable errors.
type MsgABlock ¶
type MsgABlock struct {
ABlk *common.AdminBlock
}
MsgABlock implements the Message interface and represents a factom Admin Block message. It is used by client to download Admin Block.
func NewMsgABlock ¶
func NewMsgABlock() *MsgABlock
NewMsgABlock returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgABlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgABlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgABlock) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgABlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgAcknowledgement ¶
type MsgAcknowledgement struct { Height uint32 ChainID *common.Hash Index uint32 Type byte Affirmation *ShaHash // affirmation value -- hash of the message/object in question SerialHash [32]byte Signature [64]byte }
func NewMsgAcknowledgement ¶
func NewMsgAcknowledgement(height uint32, index uint32, affirm *ShaHash, ackType byte) *MsgAcknowledgement
NewMsgAcknowledgement returns a new bitcoin ping message that conforms to the Message interface. See MsgAcknowledgement for details.
func (*MsgAcknowledgement) BtcDecode ¶
func (msg *MsgAcknowledgement) 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 (*MsgAcknowledgement) BtcEncode ¶
func (msg *MsgAcknowledgement) 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 (*MsgAcknowledgement) Command ¶
func (msg *MsgAcknowledgement) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAcknowledgement) GetBinaryForSignature ¶
func (msg *MsgAcknowledgement) GetBinaryForSignature() (data []byte, err error)
Write out the MsgAcknowledgement (excluding Signature) to binary.
func (*MsgAcknowledgement) MaxPayloadLength ¶
func (msg *MsgAcknowledgement) 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 (*MsgAcknowledgement) Sha ¶
func (msg *MsgAcknowledgement) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
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 MsgAlert ¶
type MsgAlert struct { // SerializedPayload is the alert payload serialized as a string so that the // version can change but the Alert can still be passed on by older // clients. SerializedPayload []byte // Signature is the ECDSA signature of the message. Signature []byte // Deserialized Payload Payload *Alert }
MsgAlert implements the Message interface and defines a bitcoin alert message.
This is a signed message that provides notifications that the client should display if the signature matches the key. bitcoind/bitcoin-qt only checks against a signature from the core developers.
func NewMsgAlert ¶
NewMsgAlert returns a new bitcoin alert message that conforms to the Message interface. See MsgAlert for details.
func (*MsgAlert) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgAlert) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgAlert) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAlert) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgBlock ¶
type MsgBlock struct { Header BlockHeader Transactions []*MsgTx }
MsgBlock implements the Message interface and represents a bitcoin block message. It is used to deliver block and transaction information in response to a getdata message (MsgGetData) for a given block hash.
func NewMsgBlock ¶
func NewMsgBlock(blockHeader *BlockHeader) *MsgBlock
NewMsgBlock returns a new bitcoin block message that conforms to the Message interface. See MsgBlock for details.
func (*MsgBlock) AddTransaction ¶
AddTransaction adds a transaction to the message.
func (*MsgBlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding blocks stored to disk, such as in a database, as opposed to decoding blocks from the wire.
func (*MsgBlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the wire.
func (*MsgBlock) ClearTransactions ¶
func (msg *MsgBlock) ClearTransactions()
ClearTransactions removes all transactions from the message.
func (*MsgBlock) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgBlock) Deserialize ¶
Deserialize decodes a block from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) DeserializeTxLoc ¶
DeserializeTxLoc decodes r in the same manner Deserialize does, but it takes a byte buffer instead of a generic reader and returns a slice containing the start and length of each transaction within the raw data that is being deserialized.
func (*MsgBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgBlock) Serialize ¶
Serialize encodes the block to w using a format that suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from BtcEncode in that BtcEncode encodes the block to the bitcoin wire protocol in order to be sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the block.
type MsgCommitChain ¶
type MsgCommitChain struct {
CommitChain *common.CommitChain
}
MsgCommitEntry implements the Message interface and represents a factom Commit-Entry message. It is used by client to commit the entry before revealing it.
func NewMsgCommitChain ¶
func NewMsgCommitChain() *MsgCommitChain
NewMsgCommitChain returns a new Commit Chain message that conforms to the Message interface. See MsgInv for details.
func (*MsgCommitChain) BtcDecode ¶
func (msg *MsgCommitChain) 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 (*MsgCommitChain) BtcEncode ¶
func (msg *MsgCommitChain) 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 (*MsgCommitChain) Command ¶
func (msg *MsgCommitChain) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCommitChain) IsValid ¶
func (msg *MsgCommitChain) IsValid() bool
Check whether the msg can pass the message level validations such as timestamp, signiture and etc
func (*MsgCommitChain) MaxPayloadLength ¶
func (msg *MsgCommitChain) 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 (*MsgCommitChain) Sha ¶
func (msg *MsgCommitChain) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
type MsgCommitEntry ¶
type MsgCommitEntry struct {
CommitEntry *common.CommitEntry
}
MsgCommitEntry implements the Message interface and represents a factom Commit-Entry message. It is used by client to commit the entry before revealing it.
func NewMsgCommitEntry ¶
func NewMsgCommitEntry() *MsgCommitEntry
NewMsgCommitEntry returns a new Commit Entry message that conforms to the Message interface.
func (*MsgCommitEntry) BtcDecode ¶
func (msg *MsgCommitEntry) 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 (*MsgCommitEntry) BtcEncode ¶
func (msg *MsgCommitEntry) 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 (*MsgCommitEntry) Command ¶
func (msg *MsgCommitEntry) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgCommitEntry) IsValid ¶
func (msg *MsgCommitEntry) IsValid() bool
Check whether the msg can pass the message level validations such as timestamp, signiture and etc
func (*MsgCommitEntry) MaxPayloadLength ¶
func (msg *MsgCommitEntry) 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 (*MsgCommitEntry) Sha ¶
func (msg *MsgCommitEntry) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
type MsgDirBlock ¶
type MsgDirBlock struct {
DBlk *common.DirectoryBlock
}
MsgDirBlock implements the Message interface and represents a factom DBlock message. It is used by client to reveal the entry.
func NewMsgDirBlock ¶
func NewMsgDirBlock() *MsgDirBlock
NewMsgDirBlock returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgDirBlock) BtcDecode ¶
func (msg *MsgDirBlock) 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 (*MsgDirBlock) BtcEncode ¶
func (msg *MsgDirBlock) 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 (*MsgDirBlock) Command ¶
func (msg *MsgDirBlock) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgDirBlock) MaxPayloadLength ¶
func (msg *MsgDirBlock) 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 MsgDirInv ¶
type MsgDirInv struct {
InvList []*InvVect
}
MsgDirInv implements the Message interface and represents a bitcoin 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 getDirblocks message (MsgGetDirBlocks). 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 NewMsgDirInv ¶
func NewMsgDirInv() *MsgDirInv
NewMsgDirInv returns a new bitcoin inv message that conforms to the Message interface. See MsgDirInv for details.
func NewMsgDirInvSizeHint ¶
NewMsgDirInvSizeHint returns a new bitcoin inv message that conforms to the Message interface. See MsgDirInv for details. This function differs from NewMsgDirInv 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 (*MsgDirInv) AddInvVect ¶
AddInvVect adds an inventory vector to the message.
func (*MsgDirInv) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgDirInv) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgDirInv) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgDirInv) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgEBlock ¶
MsgEBlock implements the Message interface and represents a factom EBlock message. It is used by client to download the EBlock.
func NewMsgEBlock ¶
func NewMsgEBlock() *MsgEBlock
NewMsgEBlock returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgEBlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgEBlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgEBlock) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgEBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgECBlock ¶
MsgECBlock implements the Message interface and represents a factom ECBlock message. It is used by client to download ECBlock.
func NewMsgECBlock ¶
func NewMsgECBlock() *MsgECBlock
NewMsgECBlock returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgECBlock) BtcDecode ¶
func (msg *MsgECBlock) 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 (*MsgECBlock) BtcEncode ¶
func (msg *MsgECBlock) 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 (*MsgECBlock) Command ¶
func (msg *MsgECBlock) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgECBlock) MaxPayloadLength ¶
func (msg *MsgECBlock) 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 MsgEntry ¶
MsgEntry implements the Message interface and represents a factom Entry message. It is used by client to reveal the entry.
func NewMsgEntry ¶
func NewMsgEntry() *MsgEntry
NewMsgEntry returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgEntry) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgEntry) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgEntry) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgEntry) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFBlock ¶
factoid block
func NewMsgFBlock ¶
func NewMsgFBlock() *MsgFBlock
NewMsgABlock returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgFBlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFBlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFBlock) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFactoidTX ¶
type MsgFactoidTX struct { IMsgFactoidTX Transaction fct.ITransaction }
MsgCommitEntry implements the Message interface and represents a factom Commit-Entry message. It is used by client to commit the entry before revealing it.
func (*MsgFactoidTX) BtcDecode ¶
func (msg *MsgFactoidTX) 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 (*MsgFactoidTX) BtcEncode ¶
func (msg *MsgFactoidTX) 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 (*MsgFactoidTX) Command ¶
func (msg *MsgFactoidTX) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFactoidTX) IsValid ¶
func (msg *MsgFactoidTX) IsValid() bool
Check whether the msg can pass the message level validations such as timestamp, signiture and etc
func (*MsgFactoidTX) MaxPayloadLength ¶
func (msg *MsgFactoidTX) 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 (*MsgFactoidTX) SetTransaction ¶
func (msg *MsgFactoidTX) SetTransaction(transaction fct.ITransaction)
Accessor to set the Transaction for a message.
func (*MsgFactoidTX) Sha ¶
func (msg *MsgFactoidTX) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
type MsgFilterAdd ¶
type MsgFilterAdd struct {
Data []byte
}
MsgFilterAdd implements the Message interface and represents a bitcoin filteradd message. It is used to add a data element to an existing Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgFilterAdd ¶
func NewMsgFilterAdd(data []byte) *MsgFilterAdd
NewMsgFilterAdd returns a new bitcoin filteradd message that conforms to the Message interface. See MsgFilterAdd for details.
func (*MsgFilterAdd) BtcDecode ¶
func (msg *MsgFilterAdd) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterAdd) BtcEncode ¶
func (msg *MsgFilterAdd) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterAdd) Command ¶
func (msg *MsgFilterAdd) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterAdd) MaxPayloadLength ¶
func (msg *MsgFilterAdd) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterClear ¶
type MsgFilterClear struct{}
MsgFilterClear implements the Message interface and represents a bitcoin filterclear message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version and has no payload.
func NewMsgFilterClear ¶
func NewMsgFilterClear() *MsgFilterClear
NewMsgFilterClear returns a new bitcoin filterclear message that conforms to the Message interface. See MsgFilterClear for details.
func (*MsgFilterClear) BtcDecode ¶
func (msg *MsgFilterClear) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterClear) BtcEncode ¶
func (msg *MsgFilterClear) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterClear) Command ¶
func (msg *MsgFilterClear) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterClear) MaxPayloadLength ¶
func (msg *MsgFilterClear) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterLoad ¶
type MsgFilterLoad struct { Filter []byte HashFuncs uint32 Tweak uint32 Flags BloomUpdateType }
MsgFilterLoad implements the Message interface and represents a bitcoin filterload message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgFilterLoad ¶
func NewMsgFilterLoad(filter []byte, hashFuncs uint32, tweak uint32, flags BloomUpdateType) *MsgFilterLoad
NewMsgFilterLoad returns a new bitcoin filterload message that conforms to the Message interface. See MsgFilterLoad for details.
func (*MsgFilterLoad) BtcDecode ¶
func (msg *MsgFilterLoad) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterLoad) BtcEncode ¶
func (msg *MsgFilterLoad) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterLoad) Command ¶
func (msg *MsgFilterLoad) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterLoad) MaxPayloadLength ¶
func (msg *MsgFilterLoad) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetAddr ¶
type MsgGetAddr struct{}
MsgGetAddr implements the Message interface and represents a bitcoin getaddr message. It is used to request a list of known active peers on the network from a 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 bitcoin getaddr message that conforms to the Message interface. See MsgGetAddr for details.
func (*MsgGetAddr) BtcDecode ¶
func (msg *MsgGetAddr) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetAddr) BtcEncode ¶
func (msg *MsgGetAddr) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetAddr) Command ¶
func (msg *MsgGetAddr) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetAddr) MaxPayloadLength ¶
func (msg *MsgGetAddr) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetBlocks ¶
MsgGetBlocks implements the Message interface and represents a bitcoin getblocks message. It is used to request a list of blocks starting after the last known hash in the slice of block locator hashes. The list is returned via an inv message (MsgInv) and is limited by a specific hash to stop at or the maximum number of blocks per message, which is currently 500.
Set the HashStop field to the hash at which to stop and use 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 *ShaHash) *MsgGetBlocks
NewMsgGetBlocks returns a new bitcoin getblocks message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetBlocks) AddBlockLocatorHash ¶
func (msg *MsgGetBlocks) AddBlockLocatorHash(hash *ShaHash) 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 bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetBlocks) BtcEncode ¶
func (msg *MsgGetBlocks) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetBlocks) Command ¶
func (msg *MsgGetBlocks) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetBlocks) MaxPayloadLength ¶
func (msg *MsgGetBlocks) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetData ¶
type MsgGetData struct {
InvList []*InvVect
}
MsgGetData implements the Message interface and represents a bitcoin getdata message. It is used to request data such as blocks and transactions from another 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 bitcoin getdata message that conforms to the Message interface. See MsgGetData for details.
func NewMsgGetDataSizeHint ¶
func NewMsgGetDataSizeHint(sizeHint uint) *MsgGetData
NewMsgGetDataSizeHint returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetData for details. This function differs from NewMsgGetData in that it allows a default allocation size for the backing array which houses the inventory vector list. This allows callers who know in advance how large the inventory list will grow to avoid the overhead of growing the internal backing array several times when appending large amounts of inventory vectors with AddInvVect. Note that the specified hint is just that - a hint that is used for the default allocation size. Adding more (or less) inventory vectors will still work properly. The size hint is limited to MaxInvPerMsg.
func (*MsgGetData) AddInvVect ¶
func (msg *MsgGetData) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgGetData) BtcDecode ¶
func (msg *MsgGetData) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetData) BtcEncode ¶
func (msg *MsgGetData) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetData) Command ¶
func (msg *MsgGetData) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetData) MaxPayloadLength ¶
func (msg *MsgGetData) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetDirBlocks ¶
type MsgGetDirBlocks struct { ProtocolVersion uint32 BlockLocatorHashes []*ShaHash HashStop ShaHash }
MsgGetDirBlocks implements the Message interface and represents a factom getdirblocks 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 NewMsgGetDirBlocks ¶
func NewMsgGetDirBlocks(hashStop *ShaHash) *MsgGetDirBlocks
NewMsgGetDirBlocks returns a new bitcoin getdirblocks message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgGetDirBlocks) AddBlockLocatorHash ¶
func (msg *MsgGetDirBlocks) AddBlockLocatorHash(hash *ShaHash) error
AddBlockLocatorHash adds a new block locator hash to the message.
func (*MsgGetDirBlocks) BtcDecode ¶
func (msg *MsgGetDirBlocks) 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 (*MsgGetDirBlocks) BtcEncode ¶
func (msg *MsgGetDirBlocks) 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 (*MsgGetDirBlocks) Command ¶
func (msg *MsgGetDirBlocks) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetDirBlocks) MaxPayloadLength ¶
func (msg *MsgGetDirBlocks) 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 MsgGetDirData ¶
type MsgGetDirData struct {
InvList []*InvVect
}
MsgGetDirData implements the Message interface and represents a factom getdirdata message. It is used to request data such as blocks and transactions from another peer. It should be used in response to the inv (MsgDirInv) 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 NewMsgGetDirData ¶
func NewMsgGetDirData() *MsgGetDirData
NewMsgGetDirData returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetDirData for details.
func NewMsgGetDirDataSizeHint ¶
func NewMsgGetDirDataSizeHint(sizeHint uint) *MsgGetDirData
NewMsgGetDirDataSizeHint returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetDirData for details. This function differs from NewMsgGetDirData 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 (*MsgGetDirData) AddInvVect ¶
func (msg *MsgGetDirData) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgGetDirData) BtcDecode ¶
func (msg *MsgGetDirData) 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 (*MsgGetDirData) BtcEncode ¶
func (msg *MsgGetDirData) 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 (*MsgGetDirData) Command ¶
func (msg *MsgGetDirData) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetDirData) MaxPayloadLength ¶
func (msg *MsgGetDirData) 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 MsgGetEntryData ¶
type MsgGetEntryData struct {
InvList []*InvVect
}
MsgGetEntryData implements the Message interface and represents a factom get entry data message. It is used to request data such as blocks and transactions from another peer. It should be used in response to the inv (MsgDirInv) 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 NewMsgGetEntryData ¶
func NewMsgGetEntryData() *MsgGetEntryData
NewMsgGetEntryData returns a new factom get non dir data message that conforms to the Message interface. See MsgGetEntryData for details.
func NewMsgGetEntryDataSizeHint ¶
func NewMsgGetEntryDataSizeHint(sizeHint uint) *MsgGetEntryData
NewMsgGetEntryDataSizeHint returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetEntryData for details. This function differs from NewMsgGetDirData 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 (*MsgGetEntryData) AddInvVect ¶
func (msg *MsgGetEntryData) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgGetEntryData) BtcDecode ¶
func (msg *MsgGetEntryData) 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 (*MsgGetEntryData) BtcEncode ¶
func (msg *MsgGetEntryData) 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 (*MsgGetEntryData) Command ¶
func (msg *MsgGetEntryData) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetEntryData) MaxPayloadLength ¶
func (msg *MsgGetEntryData) 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 ¶
MsgGetHeaders implements the Message interface and represents a bitcoin getheaders message. It is used to request a list of block headers for blocks starting after the last known hash in the slice of block locator hashes. The list is returned via a headers message (MsgHeaders) and is limited by a specific hash to stop at or the maximum number of block headers per message, which is currently 2000.
Set the HashStop field to the hash at which to stop and use 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 resonable number of entries, first add the most recent 10 block hashes, then double the step each loop iteration to exponentially decrease the number of hashes the further away from head and closer to the genesis block you get.
func NewMsgGetHeaders ¶
func NewMsgGetHeaders() *MsgGetHeaders
NewMsgGetHeaders returns a new bitcoin getheaders message that conforms to the Message interface. See MsgGetHeaders for details.
func (*MsgGetHeaders) AddBlockLocatorHash ¶
func (msg *MsgGetHeaders) AddBlockLocatorHash(hash *ShaHash) 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 bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetHeaders) BtcEncode ¶
func (msg *MsgGetHeaders) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetHeaders) Command ¶
func (msg *MsgGetHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetHeaders) MaxPayloadLength ¶
func (msg *MsgGetHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetNonDirData ¶
type MsgGetNonDirData struct {
InvList []*InvVect
}
MsgGetNonDirData implements the Message interface and represents a factom get non dir block data message. It is used to request data such as blocks and transactions from another peer. It should be used in response to the inv (MsgDirInv) 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 NewMsgGetNonDirData ¶
func NewMsgGetNonDirData() *MsgGetNonDirData
NewMsgGetNonDirData returns a new factom get non dir data message that conforms to the Message interface. See MsgGetNonDirData for details.
func NewMsgGetNonDirDataSizeHint ¶
func NewMsgGetNonDirDataSizeHint(sizeHint uint) *MsgGetNonDirData
NewMsgGetNonDirDataSizeHint returns a new bitcoin getdata message that conforms to the Message interface. See MsgGetNonDirData for details. This function differs from NewMsgGetDirData 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 (*MsgGetNonDirData) AddInvVect ¶
func (msg *MsgGetNonDirData) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgGetNonDirData) BtcDecode ¶
func (msg *MsgGetNonDirData) 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 (*MsgGetNonDirData) BtcEncode ¶
func (msg *MsgGetNonDirData) 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 (*MsgGetNonDirData) Command ¶
func (msg *MsgGetNonDirData) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetNonDirData) MaxPayloadLength ¶
func (msg *MsgGetNonDirData) 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 bitcoin headers message. It is used to deliver block header information in response to a getheaders message (MsgGetHeaders). The maximum number of block headers per message is currently 2000. See MsgGetHeaders for details on requesting the headers.
func NewMsgHeaders ¶
func NewMsgHeaders() *MsgHeaders
NewMsgHeaders returns a new bitcoin headers message that conforms to the Message interface. See MsgHeaders for details.
func (*MsgHeaders) AddBlockHeader ¶
func (msg *MsgHeaders) AddBlockHeader(bh *BlockHeader) 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 bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgHeaders) BtcEncode ¶
func (msg *MsgHeaders) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgHeaders) Command ¶
func (msg *MsgHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgHeaders) MaxPayloadLength ¶
func (msg *MsgHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgInt_DirBlock ¶
type MsgInt_DirBlock struct {
ShaHash *ShaHash
}
Dir block message for internal communication
func (*MsgInt_DirBlock) Command ¶
func (msg *MsgInt_DirBlock) Command() string
Dir block available: internal message for time commnunications between Goroutines
type MsgInt_EOM ¶
End-of-Minute internal message for time commnunications between Goroutines
func (*MsgInt_EOM) Command ¶
func (msg *MsgInt_EOM) Command() string
End-of-Minute internal message for time commnunications between Goroutines
type MsgInt_FactoidBlock ¶
Factoid block message for internal communication
func (*MsgInt_FactoidBlock) Command ¶
func (msg *MsgInt_FactoidBlock) Command() string
Factoid block available: internal message for time commnunications between Goroutines
type MsgInv ¶
type MsgInv struct {
InvList []*InvVect
}
MsgInv implements the Message interface and represents a bitcoin 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 bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func NewMsgInvSizeHint ¶
NewMsgInvSizeHint returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details. This function differs from NewMsgInv in that it allows a default allocation size for the backing array which houses the inventory vector list. This allows callers who know in advance how large the inventory list will grow to avoid the overhead of growing the internal backing array several times when appending large amounts of inventory vectors with AddInvVect. Note that the specified hint is just that - a hint that is used for the default allocation size. Adding more (or less) inventory vectors will still work properly. The size hint is limited to MaxInvPerMsg.
func (*MsgInv) AddInvVect ¶
AddInvVect adds an inventory vector to the message.
func (*MsgInv) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgInv) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgInv) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgInv) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgMemPool ¶
type MsgMemPool struct{}
MsgMemPool implements the Message interface and represents a bitcoin mempool message. It is used to request a list of transactions still in the active memory pool of a relay.
This message has no payload and was not added until protocol versions starting with BIP0035Version.
func NewMsgMemPool ¶
func NewMsgMemPool() *MsgMemPool
NewMsgMemPool returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgMemPool) BtcDecode ¶
func (msg *MsgMemPool) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgMemPool) BtcEncode ¶
func (msg *MsgMemPool) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgMemPool) Command ¶
func (msg *MsgMemPool) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgMemPool) MaxPayloadLength ¶
func (msg *MsgMemPool) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgNotFound ¶
type MsgNotFound struct {
InvList []*InvVect
}
MsgNotFound defines a bitcoin notfound message which is sent in response to a getdata message if any of the requested data in not available on the 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 bitcoin notfound message that conforms to the Message interface. See MsgNotFound for details.
func (*MsgNotFound) AddInvVect ¶
func (msg *MsgNotFound) AddInvVect(iv *InvVect) error
AddInvVect adds an inventory vector to the message.
func (*MsgNotFound) BtcDecode ¶
func (msg *MsgNotFound) BtcDecode(r io.Reader, pver uint32) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgNotFound) BtcEncode ¶
func (msg *MsgNotFound) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgNotFound) Command ¶
func (msg *MsgNotFound) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgNotFound) MaxPayloadLength ¶
func (msg *MsgNotFound) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgPing ¶
type MsgPing struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 }
MsgPing implements the Message interface and represents a bitcoin ping message.
For versions BIP0031Version and earlier, it is used primarily to confirm that a connection is still valid. A transmission error is typically interpreted as a closed connection and that the 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 bitcoin ping message that conforms to the Message interface. See MsgPing for details.
func (*MsgPing) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPing) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgPing) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPing) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgPong ¶
type MsgPong struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 }
MsgPong implements the Message interface and represents a bitcoin pong message which is used primarily to confirm that a connection is still valid in response to a bitcoin ping message (MsgPing).
This message was not added until protocol versions AFTER BIP0031Version.
func NewMsgPong ¶
NewMsgPong returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgPong) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPong) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgPong) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPong) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgReject ¶
type MsgReject struct { // Cmd is the command for the message which was rejected such as // as CmdBlock or CmdTx. This can be obtained from the Command function // of a Message. Cmd string // RejectCode is a code indicating why the command was rejected. It // is encoded as a uint8 on the wire. Code RejectCode // Reason is a human-readable string with specific details (over and // above the reject code) about why the command was rejected. Reason string // Hash identifies a specific block or transaction that was rejected // and therefore only applies the MsgBlock and MsgTx messages. Hash ShaHash }
MsgReject implements the Message interface and represents a bitcoin reject message.
This message was not added until protocol version RejectVersion.
func NewMsgReject ¶
func NewMsgReject(command string, code RejectCode, reason string) *MsgReject
NewMsgReject returns a new bitcoin reject message that conforms to the Message interface. See MsgReject for details.
func (*MsgReject) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgReject) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgReject) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgReject) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgRevealChain ¶
MsgRevealChain implements the Message interface and represents a factom Reveal-Chain message. It is used by client to reveal the chain.
func NewMsgRevealChain ¶
func NewMsgRevealChain() *MsgRevealChain
NewMsgInv returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgRevealChain) BtcDecode ¶
func (msg *MsgRevealChain) 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 (*MsgRevealChain) BtcEncode ¶
func (msg *MsgRevealChain) 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 (*MsgRevealChain) Command ¶
func (msg *MsgRevealChain) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRevealChain) MaxPayloadLength ¶
func (msg *MsgRevealChain) 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 (*MsgRevealChain) Sha ¶
func (msg *MsgRevealChain) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
type MsgRevealEntry ¶
MsgRevealEntry implements the Message interface and represents a factom Reveal-Entry message. It is used by client to reveal the entry.
func NewMsgRevealEntry ¶
func NewMsgRevealEntry() *MsgRevealEntry
NewMsgInv returns a new bitcoin inv message that conforms to the Message interface. See MsgInv for details.
func (*MsgRevealEntry) BtcDecode ¶
func (msg *MsgRevealEntry) 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 (*MsgRevealEntry) BtcEncode ¶
func (msg *MsgRevealEntry) 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 (*MsgRevealEntry) Command ¶
func (msg *MsgRevealEntry) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRevealEntry) IsValid ¶
func (msg *MsgRevealEntry) IsValid() bool
Check whether the msg can pass the message level validations
func (*MsgRevealEntry) MaxPayloadLength ¶
func (msg *MsgRevealEntry) 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 (*MsgRevealEntry) Sha ¶
func (msg *MsgRevealEntry) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
type MsgTestCredit ¶
func NewMsgTestCredit ¶
func NewMsgTestCredit() *MsgTestCredit
func (*MsgTestCredit) BtcDecode ¶
func (msg *MsgTestCredit) 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 (*MsgTestCredit) BtcEncode ¶
func (msg *MsgTestCredit) 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 (*MsgTestCredit) Command ¶
func (msg *MsgTestCredit) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgTestCredit) MarshalBinary ¶
func (m *MsgTestCredit) MarshalBinary() ([]byte, error)
func (*MsgTestCredit) MaxPayloadLength ¶
func (msg *MsgTestCredit) 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 (*MsgTestCredit) Sha ¶
func (msg *MsgTestCredit) Sha() (ShaHash, error)
Create a sha hash from the message binary (output of BtcEncode)
func (*MsgTestCredit) UnmarshalBinary ¶
func (m *MsgTestCredit) UnmarshalBinary(data []byte) error
type MsgTx ¶
type MsgTx struct { Version uint8 LockTime int64 // 5 bytes on the wire // FactoidOut []*TxFactoidOut TxOut []*TxOut ECOut []*TxEntryCreditOut TxIn []*TxIn }
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 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) AddECOut ¶
func (msg *MsgTx) AddECOut(eco *TxEntryCreditOut)
AddECOut adds a transaction output to the message.
func (*MsgTx) BtcDecode ¶
BtcDecode decodes r using the 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 ¶
FactoidEncode encodes the receiver to w using the 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) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgTx) MaxPayloadLength ¶
10KiB is the limit for entries, per Brian we apply the same here
func (*MsgTx) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction.
type MsgVerAck ¶
type MsgVerAck struct{}
MsgVerAck defines a bitcoin 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 bitcoin verack message that conforms to the Message interface.
func (*MsgVerAck) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgVerAck) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgVerAck) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVerAck) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgVersion ¶
type MsgVersion struct { // Version of the protocol the node is using. ProtocolVersion int32 // 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 messsage. This is a encoded as a varString // on the wire. This has a max length of MaxUserAgentLen. UserAgent string // Last block seen by the generator of the version message. LastBlock int32 // Don't announce transactions to peer. DisableRelayTx bool }
MsgVersion implements the Message interface and represents a bitcoin 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 bitcoin 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 bitcoin 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 bitcoin protocol encoding into the receiver. The version message is special in that the protocol version hasn't been negotiated yet. As a result, the pver field is ignored and any fields which are added in new versions are optional. This also mean that r must be a *bytes.Buffer so the number of remaining bytes can be ascertained.
This is part of the Message interface implementation.
func (*MsgVersion) BtcEncode ¶
func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32) error
BtcEncode encodes the receiver to w using the bitcoin 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 bitcoin version message (MsgVersion) nor was it // added until protocol version >= NetAddressTimeVersion. Timestamp time.Time // Bitfield which identifies the services supported by the address. Services ServiceFlag // IP address of the 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 (*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.
func (*NetAddress) SetAddress ¶
func (na *NetAddress) SetAddress(ip net.IP, port uint16)
SetAddress is a convenience function to set the IP address and port in one call.
type OutPoint ¶
OutPoint defines a bitcoin data type that is used to track previous transaction outputs.
func NewOutPoint ¶
NewOutPoint returns a new bitcoin transaction outpoint point with the provided hash and index.
type PubKey ¶
type PubKey [PubKeySize]byte
type RCDHash ¶
type RCDHash [RCDHashSize]byte // this is out factoid address
type RCDreveal ¶
type RCDreveal struct { Version uint8 Type uint8 PubKey []PubKey MinRequired uint64 // minimum number of keys required for validity }
Redeem Condition Datastructure (reveal)
func (*RCDreveal) SerializeSize ¶
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 bitcoin peer.
const ( // SFNodeNetwork is a flag used to indicate a peer is a full node. SFNodeNetwork ServiceFlag = 1 << iota )
func (ServiceFlag) String ¶
func (f ServiceFlag) String() string
String returns the ServiceFlag in human-readable form.
type Sha3Hash ¶
Sha3Hash is used in several of the bitcoin messages and common structures. It typically represents the double sha256 of data.
func NewSha3Hash ¶
NewSha3Hash returns a new Sha3Hash from a byte slice. An error is returned if the number of bytes passed in is not Hash3Size.
func NewSha3HashFromStr ¶
NewSha3HashFromStr creates a Sha3Hash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the Sha3Hash.
type ShaHash ¶
ShaHash is used in several of the bitcoin messages and common structures. It typically represents the double sha256 of data.
func FactomHashToShaHash ¶
Convert factom.common.hash into a wire.ShaHash
func NewShaHash ¶
NewShaHash returns a new ShaHash from a byte slice. An error is returned if the number of bytes passed in is not HashSize.
func NewShaHashFromStr ¶
NewShaHashFromStr creates a ShaHash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the ShaHash.
func NewShaHashFromStruct ¶
func (*ShaHash) SetBytes ¶
SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not HashSize.
func (*ShaHash) ToFactomHash ¶
Convert wire.ShaHash into factom.common.Hash
type TxEntryCreditOut ¶
func (*TxEntryCreditOut) SerializeSize ¶
func (t *TxEntryCreditOut) SerializeSize() int
type TxIn ¶
type TxIn struct { PreviousOutPoint OutPoint // contains filtered or unexported fields }
func NewTxIn ¶
NewTxIn returns a new bitcoin transaction input with the provided previous outpoint point and signature script with a default sequence of MaxTxInSequenceNum.
func (*TxIn) SerializeSize ¶
we are using the OutPoint here; thus the total transaction input size is: txid (32) + index (4) + sighash (1)
type TxLoc ¶
TxLoc holds locator data for the offset and length of where a transaction is located within a MsgBlock data buffer.
Source Files ¶
- blockheader.go
- common.go
- doc.go
- error.go
- fact-methods.go
- fact-types.go
- internalmsg.go
- invvect.go
- message.go
- msgablock.go
- msgack.go
- msgaddr.go
- msgalert.go
- msgblock.go
- msgcommitchain.go
- msgcommitentry.go
- msgdirblock.go
- msgdirinv.go
- msgeblock.go
- msgecblock.go
- msgentry.go
- msgfactoidtx.go
- msgfblock.go
- msgfilteradd.go
- msgfilterclear.go
- msgfilterload.go
- msggetaddr.go
- msggetblocks.go
- msggetdata.go
- msggetdirblocks.go
- msggetdirdata.go
- msggetentrydata.go
- msggetheaders.go
- msggetnondirdata.go
- msgheaders.go
- msginv.go
- msgmempool.go
- msgnotfound.go
- msgping.go
- msgpong.go
- msgreject.go
- msgrevealchain.go
- msgrevealentry.go
- msgtestcredit.go
- msgverack.go
- msgversion.go
- netaddress.go
- protocol.go
- sha3hash.go
- shahash.go
- shahash_factom.go