Package org.bitcoinj.core
Class RejectMessage
java.lang.Object
org.bitcoinj.core.BaseMessage
org.bitcoinj.core.RejectMessage
- All Implemented Interfaces:
Message
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
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRejectMessage
(RejectMessage.RejectCode code, Sha256Hash rejectedMessageHash, String rejectedMessage, String reason) Constructs a reject message that fingers the object with the given hash as rejected for the given reason. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bitcoinSerializeToStream
(OutputStream stream) Serializes this message to the provided stream.code()
The reason code given for why the peer rejected the message.boolean
Deprecated.Deprecated.usereason()
Deprecated.Deprecated.int
hashCode()
static RejectMessage
read
(ByteBuffer payload) Deserialize this message from a given payload.reason()
The reason message given for rejection.Provides the type of message which was rejected by the peer.Provides the hash of the rejected object (if getRejectedMessage() is either "tx" or "block"), otherwise null.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 Details
-
RejectMessage
public RejectMessage(RejectMessage.RejectCode code, @Nullable Sha256Hash rejectedMessageHash, String rejectedMessage, String reason) Constructs a reject message that fingers the object with the given hash as rejected for the given reason.
-
-
Method Details
-
read
public static RejectMessage read(ByteBuffer payload) throws BufferUnderflowException, ProtocolException Deserialize this message from a given payload.- Parameters:
payload
- payload to deserialize from- Returns:
- read message
- Throws:
BufferUnderflowException
- if the read message extends beyond the remaining bytes of the payloadProtocolException
-
bitcoinSerializeToStream
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:
IOException
-
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. -
rejectedMessageHash
Provides the hash of the rejected object (if getRejectedMessage() is either "tx" or "block"), otherwise null.- Returns:
- hash of rejected object
-
getRejectedObjectHash
Deprecated. -
code
The reason code given for why the peer rejected the message.- Returns:
- reject reason code
-
getReasonCode
Deprecated.usecode()
-
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.usereason()
-
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. -
equals
-
hashCode
public int hashCode()
-
code()