Package org.bitcoinj.core
Class RejectMessage
- java.lang.Object
-
- org.bitcoinj.core.Message
-
- org.bitcoinj.core.RejectMessage
-
public class RejectMessage extends Message
A message sent by nodes when a message we sent was rejected (ie a transaction had too little fee/was invalid/etc).
Instances of this class are not safe for use by multiple threads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RejectMessage.RejectCode
-
Field Summary
-
Fields inherited from class org.bitcoinj.core.Message
MAX_SIZE, params, payload, serializer
-
-
Constructor Summary
Constructors Constructor Description RejectMessage(NetworkParameters params, java.nio.ByteBuffer payload)
RejectMessage(NetworkParameters params, RejectMessage.RejectCode code, Sha256Hash hash, java.lang.String message, java.lang.String reason)
Constructs a reject message that fingers the object with the given hash as rejected for the given reason.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bitcoinSerializeToStream(java.io.OutputStream stream)
Serializes this message to the provided stream.boolean
equals(java.lang.Object o)
RejectMessage.RejectCode
getReasonCode()
The reason code given for why the peer rejected the message.java.lang.String
getReasonString()
The reason message given for rejection.java.lang.String
getRejectedMessage()
Provides the type of message which was rejected by the peer.Sha256Hash
getRejectedObjectHash()
Provides the hash of the rejected object (if getRejectedMessage() is either "tx" or "block"), otherwise null.int
hashCode()
protected void
parse()
java.lang.String
toString()
A String representation of the relevant details of this reject message.-
Methods inherited from class org.bitcoinj.core.Message
bitcoinSerialize, getHash, getMessageSize, getParams, readByte, readByteArray, readBytes, readHash, readInt32, readInt64, readStr, readUint32, readUint64, readVarInt, skipBytes, unCache, unsafeBitcoinSerialize
-
-
-
-
Constructor Detail
-
RejectMessage
public RejectMessage(NetworkParameters params, java.nio.ByteBuffer payload) throws ProtocolException
- Throws:
ProtocolException
-
RejectMessage
public RejectMessage(NetworkParameters params, RejectMessage.RejectCode code, Sha256Hash hash, java.lang.String message, java.lang.String reason) throws ProtocolException
Constructs a reject message that fingers the object with the given hash as rejected for the given reason.- Throws:
ProtocolException
-
-
Method Detail
-
parse
protected void parse() throws java.nio.BufferUnderflowException, ProtocolException
- Specified by:
parse
in classMessage
- Throws:
java.nio.BufferUnderflowException
ProtocolException
-
bitcoinSerializeToStream
public void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Description copied from class:Message
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Overrides:
bitcoinSerializeToStream
in classMessage
- Throws:
java.io.IOException
-
getRejectedMessage
public java.lang.String getRejectedMessage()
Provides the type of message which was rejected by the peer. Note that this is ENTIRELY UNTRUSTED and should be sanity-checked before it is printed or processed.
-
getRejectedObjectHash
public Sha256Hash getRejectedObjectHash()
Provides the hash of the rejected object (if getRejectedMessage() is either "tx" or "block"), otherwise null.
-
getReasonCode
public RejectMessage.RejectCode getReasonCode()
The reason code given for why the peer rejected the message.
-
getReasonString
public java.lang.String getReasonString()
The reason message given for rejection. Note that this is ENTIRELY UNTRUSTED and should be sanity-checked before it is printed or processed.
-
toString
public java.lang.String toString()
A String representation of the relevant details of this reject message. Be aware that the value returned by this method includes the value returned bygetReasonString
, which is taken from the reject message unchecked. Through malice or otherwise, it might contain control characters or other harmful content.- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-