Class FilteredBlock

java.lang.Object
org.bitcoinj.core.BaseMessage
org.bitcoinj.core.FilteredBlock
All Implemented Interfaces:
Message

public class FilteredBlock extends BaseMessage

A FilteredBlock is used to relay a block with its transactions filtered using a BloomFilter. It consists of the block header and a PartialMerkleTree which contains the transactions which matched the filter.

Instances of this class are not safe for use by multiple threads.

  • Constructor Details

  • Method Details

    • read

      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 payload
      ProtocolException
    • bitcoinSerializeToStream

      public void bitcoinSerializeToStream(OutputStream stream) throws 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 class BaseMessage
      Throws:
      IOException
    • getTransactionHashes

      public List<Sha256Hash> getTransactionHashes() throws VerificationException
      Gets a list of leaf hashes which are contained in the partial merkle tree in this filtered block
      Throws:
      ProtocolException - If the partial merkle block is invalid or the merkle root of the partial merkle block doesn't match the block header
      VerificationException
    • getBlockHeader

      public Block getBlockHeader()
      Gets a copy of the block header
    • getHash

      public Sha256Hash getHash()
      Gets the hash of the block represented in this Filtered Block
    • provideTransaction

      public boolean provideTransaction(Transaction tx) throws VerificationException
      Provide this FilteredBlock with a transaction which is in its Merkle tree.
      Returns:
      false if the tx is not relevant to this FilteredBlock
      Throws:
      VerificationException
    • getPartialMerkleTree

      public PartialMerkleTree getPartialMerkleTree()
      Returns the PartialMerkleTree object that provides the mathematical proof of transaction inclusion in the block.
    • getAssociatedTransactions

      public Map<Sha256Hash,Transaction> getAssociatedTransactions()
      Gets the set of transactions which were provided using provideTransaction() which match in getTransactionHashes()
    • getTransactionCount

      public int getTransactionCount()
      Number of transactions in this block, before it was filtered
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object