Package org.bitcoinj.core
Class RejectMessage
- java.lang.Object
-
- org.bitcoinj.core.BaseMessage
-
- org.bitcoinj.core.RejectMessage
-
- All Implemented Interfaces:
Message
public class RejectMessage extends BaseMessage
A message sent by nodes when a message we sent was rejected (ie a transaction had too little fee/was invalid/etc). See BIP61 for details.Instances of this class are immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RejectMessage.RejectCode
-
Constructor Summary
Constructors Constructor Description RejectMessage(RejectMessage.RejectCode code, Sha256Hash rejectedMessageHash, java.lang.String rejectedMessage, 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 Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
bitcoinSerializeToStream(java.io.OutputStream stream)
Serializes this message to the provided stream.RejectMessage.RejectCode
code()
The reason code given for why the peer rejected the message.boolean
equals(java.lang.Object o)
RejectMessage.RejectCode
getReasonCode()
Deprecated.usecode()
java.lang.String
getReasonString()
Deprecated.usereason()
java.lang.String
getRejectedMessage()
Deprecated.Sha256Hash
getRejectedObjectHash()
Deprecated.int
hashCode()
static RejectMessage
read(java.nio.ByteBuffer payload)
Deserialize this message from a given payload.java.lang.String
reason()
The reason message given for rejection.java.lang.String
rejectedMessage()
Provides the type of message which was rejected by the peer.Sha256Hash
rejectedMessageHash()
Provides the hash of the rejected object (if getRejectedMessage() is either "tx" or "block"), otherwise null.java.lang.String
toString()
A String representation of the relevant details of this reject message.-
Methods inherited from class org.bitcoinj.core.BaseMessage
messageSize, serialize
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.bitcoinj.core.Message
bitcoinSerialize, getMessageSize, unsafeBitcoinSerialize
-
-
-
-
Constructor Detail
-
RejectMessage
public RejectMessage(RejectMessage.RejectCode code, @Nullable Sha256Hash rejectedMessageHash, java.lang.String rejectedMessage, java.lang.String reason)
Constructs a reject message that fingers the object with the given hash as rejected for the given reason.
-
-
Method Detail
-
read
public static RejectMessage read(java.nio.ByteBuffer payload) throws java.nio.BufferUnderflowException, ProtocolException
Deserialize this message from a given payload.- Parameters:
payload
- payload to deserialize from- Returns:
- read message
- Throws:
java.nio.BufferUnderflowException
- if the read message extends beyond the remaining bytes of the payloadProtocolException
-
bitcoinSerializeToStream
public void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Description copied from class:BaseMessage
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Specified by:
bitcoinSerializeToStream
in classBaseMessage
- Throws:
java.io.IOException
-
rejectedMessage
public java.lang.String rejectedMessage()
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.- Returns:
- rejected message type
-
getRejectedMessage
@Deprecated public java.lang.String getRejectedMessage()
Deprecated.
-
rejectedMessageHash
public Sha256Hash rejectedMessageHash()
Provides the hash of the rejected object (if getRejectedMessage() is either "tx" or "block"), otherwise null.- Returns:
- hash of rejected object
-
getRejectedObjectHash
@Deprecated public Sha256Hash getRejectedObjectHash()
Deprecated.
-
code
public RejectMessage.RejectCode code()
The reason code given for why the peer rejected the message.- Returns:
- reject reason code
-
getReasonCode
@Deprecated public RejectMessage.RejectCode getReasonCode()
Deprecated.usecode()
-
reason
public java.lang.String reason()
The reason message given for rejection. Note that this is ENTIRELY UNTRUSTED and should be sanity-checked before it is printed or processed.- Returns:
- reject reason
-
getReasonString
@Deprecated public java.lang.String getReasonString()
Deprecated.usereason()
-
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
-
-