Class TransactionOutPoint


  • public class TransactionOutPoint
    extends java.lang.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 Detail

      • UNCONNECTED

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

      • TransactionOutPoint

        public TransactionOutPoint​(long index,
                                   Transaction fromTx)
      • TransactionOutPoint

        public TransactionOutPoint​(long index,
                                   Sha256Hash hash)
      • TransactionOutPoint

        public TransactionOutPoint​(TransactionOutput connectedOutput)
    • Method Detail

      • read

        public static TransactionOutPoint read​(java.nio.ByteBuffer payload)
                                        throws java.nio.BufferUnderflowException,
                                               ProtocolException
        Deserialize this transaction outpoint from a given payload.
        Parameters:
        payload - payload to deserialize from
        Returns:
        read transaction outpoint
        Throws:
        java.nio.BufferUnderflowException - if the read message extends beyond the remaining bytes of the payload
        ProtocolException
      • write

        public java.nio.ByteBuffer write​(java.nio.ByteBuffer buf)
                                  throws java.nio.BufferOverflowException
        Write this transaction outpoint into the given buffer.
        Parameters:
        buf - buffer to write into
        Returns:
        the buffer
        Throws:
        java.nio.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:
        java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.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
      • getIndex

        @Deprecated
        public long getIndex()
        Deprecated.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object