Class TransactionOutPoint

java.lang.Object
org.bitcoinj.core.TransactionOutPoint

public class TransactionOutPoint extends Object

This message is a reference or pointer to an output of a different transaction.

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

  • Field Details

    • BYTES

      public static final int BYTES
      See Also:
    • UNCONNECTED

      public static final TransactionOutPoint UNCONNECTED
      Special outpoint that normally marks a coinbase input. It's also used as a test dummy.
  • Constructor Details

    • TransactionOutPoint

      public TransactionOutPoint(long index, Transaction fromTx)
    • TransactionOutPoint

      public TransactionOutPoint(long index, Sha256Hash hash)
    • TransactionOutPoint

      public TransactionOutPoint(TransactionOutput connectedOutput)
  • Method Details

    • read

      Deserialize this transaction outpoint from a given payload.
      Parameters:
      payload - payload to deserialize from
      Returns:
      read transaction outpoint
      Throws:
      BufferUnderflowException - if the read message extends beyond the remaining bytes of the payload
      ProtocolException
    • write

      public ByteBuffer write(ByteBuffer buf) throws BufferOverflowException
      Write this transaction outpoint into the given buffer.
      Parameters:
      buf - buffer to write into
      Returns:
      the buffer
      Throws:
      BufferOverflowException - if the outpoint doesn't fit the remaining buffer
    • serialize

      public byte[] serialize()
      Allocates a byte array and writes this transaction outpoint into it.
      Returns:
      byte array containing the transaction outpoint
    • bitcoinSerialize

      @Deprecated public byte[] bitcoinSerialize()
      Deprecated.
    • getMessageSize

      @Deprecated public int getMessageSize()
      Deprecated.
      use BYTES
    • getConnectedOutput

      @Nullable public TransactionOutput getConnectedOutput()
      An outpoint is a part of a transaction input that points to the output of another transaction. If we have both sides in memory, and they have been linked together, this returns a pointer to the connected output, or null if there is no such connection.
    • getConnectedPubKeyScript

      public byte[] getConnectedPubKeyScript()
      Returns the pubkey script from the connected output.
      Throws:
      NullPointerException - if there is no connected output.
    • getConnectedKey

      @Nullable public ECKey getConnectedKey(KeyBag keyBag) throws ScriptException
      Returns the ECKey identified in the connected output, for either P2PKH, P2WPKH or P2PK scripts. For P2SH scripts you can use getConnectedRedeemData(KeyBag) and then get the key from RedeemData. If the script form cannot be understood, throws ScriptException.
      Returns:
      an ECKey or null if the connected key cannot be found in the wallet.
      Throws:
      ScriptException
    • getConnectedRedeemData

      @Nullable public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException
      Returns the RedeemData identified in the connected output, for either P2PKH, P2WPKH, P2PK or P2SH scripts. If the script forms cannot be understood, throws ScriptException.
      Returns:
      a RedeemData or null if the connected data cannot be found in the wallet.
      Throws:
      ScriptException
    • disconnectOutput

      public TransactionOutPoint disconnectOutput()
      Returns a copy of this outpoint, but with the connectedOutput removed.
      Returns:
      outpoint with removed connectedOutput
    • connectTransaction

      public TransactionOutPoint connectTransaction(Transaction transaction)
      Returns a copy of this outpoint, but with the provided transaction as fromTx.
      Parameters:
      transaction - transaction to set as fromTx
      Returns:
      outpoint with fromTx set
    • disconnectTransaction

      public TransactionOutPoint disconnectTransaction()
      Returns a copy of this outpoint, but with fromTx removed.
      Returns:
      outpoint with removed fromTx
    • toString

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

      public Sha256Hash hash()
      Returns the hash of the transaction this outpoint references/spends/is connected to.
    • index

      public long index()
      Returns:
      the index of this outpoint
    • getHash

      @Deprecated public Sha256Hash getHash()
      Deprecated.
      Use hash()
    • getIndex

      @Deprecated public long getIndex()
      Deprecated.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object