Package org.bitcoinj.core
Class BaseMessage
java.lang.Object
org.bitcoinj.core.BaseMessage
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
AddressMessage
,Block
,BloomFilter
,EmptyMessage
,FeeFilterMessage
,FilteredBlock
,GetBlocksMessage
,HeadersMessage
,ListMessage
,Ping
,Pong
,RejectMessage
,Transaction
,VersionMessage
A Message is a data structure that can be serialized/deserialized using the Bitcoin serialization format.
Specific types of messages that are used both in the blockchain, and on the wire, are derived from this
class.
Instances of this class are not safe for use by multiple threads.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
bitcoinSerializeToStream
(OutputStream stream) Serializes this message to the provided stream.int
Return the size of the serialized message.final byte[]
Serialize this message to a byte array that conforms to the bitcoin wire protocol.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bitcoinj.core.Message
bitcoinSerialize, getMessageSize, unsafeBitcoinSerialize
-
Constructor Details
-
BaseMessage
public BaseMessage()
-
-
Method Details
-
serialize
public final byte[] serialize()Serialize this message to a byte array that conforms to the bitcoin wire protocol.
-
bitcoinSerializeToStream
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Throws:
IOException
-
messageSize
public int messageSize()Return the size of the serialized message. Note that if the message was deserialized from a payload, this size can differ from the size of the original payload.- Specified by:
messageSize
in interfaceMessage
- Returns:
- size of this object when serialized (in bytes)
-