Class UTXO

java.lang.Object
org.bitcoinj.core.UTXO

public class UTXO extends Object
A UTXO message contains the information necessary to check a spending transaction. It avoids having to store the entire parentTransaction just to get the hash and index. Useful when working with free standing outputs.
  • Constructor Details

    • UTXO

      public UTXO(Sha256Hash hash, long index, Coin value, int height, boolean coinbase, Script script)
      Creates a stored transaction output.
      Parameters:
      hash - The hash of the containing transaction.
      index - The outpoint.
      value - The value available.
      height - The height this output was created in.
      coinbase - The coinbase flag.
    • UTXO

      public UTXO(Sha256Hash hash, long index, Coin value, int height, boolean coinbase, Script script, String address)
      Creates a stored transaction output.
      Parameters:
      hash - The hash of the containing transaction.
      index - The outpoint.
      value - The value available.
      height - The height this output was created in.
      coinbase - The coinbase flag.
      address - The address.
  • Method Details

    • getValue

      public Coin getValue()
      The value which this Transaction output holds.
    • getScript

      public Script getScript()
      The Script object which you can use to get address, script bytes or script type.
    • getHash

      public Sha256Hash getHash()
      The hash of the transaction which holds this output.
    • getIndex

      public long getIndex()
      The index of this output in the transaction which holds it.
    • getHeight

      public int getHeight()
      Gets the height of the block that created this output.
    • isCoinbase

      public boolean isCoinbase()
      Gets the flag of whether this was created by a coinbase tx.
    • getAddress

      public String getAddress()
      The address of this output, can be the empty string if none was provided at construction time or was deserialized
    • toString

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

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

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

      public void serializeToStream(OutputStream bos) throws IOException
      Throws:
      IOException
    • fromStream

      public static UTXO fromStream(InputStream in) throws IOException
      Throws:
      IOException