Class TransactionOutput

  • public class TransactionOutput
    extends ChildMessage

    A TransactionOutput message contains a scriptPubKey that controls who is able to spend its value. It is a sub-part of the Transaction message.

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

    • Method Detail

      • getMessageSize

        public int getMessageSize()
        Description copied from class: Message
        Return the size of the serialized message. Note that if the message was deserialized from a payload, this size can differ from the size of the original payload.
        getMessageSize in class Message
        size of the serialized message in bytes
      • bitcoinSerializeToStream

        protected void bitcoinSerializeToStream​( stream)
        Description copied from class: Message
        Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().
        bitcoinSerializeToStream in class Message
      • getValue

        public Coin getValue()
        Returns the value of this output. This is the amount of currency that the destination address receives.
      • setValue

        public void setValue​(Coin value)
        Sets the value of this output.
      • getIndex

        public int getIndex()
        Gets the index of this output in the parent transaction, or throws if this output is free standing. Iterates over the parents list to discover this.
      • isDust

        public boolean isDust()
        Will this transaction be relayable and mined by default miners?
      • getMinNonDustValue

        public Coin getMinNonDustValue​(Coin feePerKb)

        Gets the minimum value for a txout of this size to be considered non-dust by Bitcoin Core (and thus relayed). See: CTxOut::IsDust() in Bitcoin Core.

        You probably should use getMinNonDustValue() which uses a safe fee-per-kb by default.

        feePerKb - The fee required per kilobyte. Note that this is the same as Bitcoin Core's -minrelaytxfee * 3
      • getMinNonDustValue

        public Coin getMinNonDustValue()
        Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable and mined by default miners.
      • markAsSpent

        public void markAsSpent​(TransactionInput input)
        Sets this objects availableForSpending flag to false and the spentBy pointer to the given input. If the input is null, it means this output was signed over to somebody else rather than one of our own keys.
        java.lang.IllegalStateException - if the transaction was already marked as spent.
      • markAsUnspent

        public void markAsUnspent()
        Resets the spent pointer / availableForSpending flag to null.
      • isAvailableForSpending

        public boolean isAvailableForSpending()
        Returns whether markAsSpent(TransactionInput) has been called on this class. A Wallet will mark a transaction output as spent once it sees a transaction input that is connected to it. Note that this flag can be false when an output has in fact been spent according to the rest of the network if the spending transaction wasn't downloaded yet, and it can be marked as spent when in reality the rest of the network believes it to be unspent if the signature or script connecting to it was not actually valid.
      • getScriptBytes

        public byte[] getScriptBytes()
        The backing script bytes which can be turned into a Script object.
        the scriptBytes
      • isMineOrWatched

        public boolean isMineOrWatched​(TransactionBag transactionBag)
        Returns true if this output is to a key in the wallet or to an address/script we are watching.
      • isWatched

        public boolean isWatched​(TransactionBag transactionBag)
        Returns true if this output is to a key, or an address we have the keys for, in the wallet.
      • isMine

        public boolean isMine​(TransactionBag transactionBag)
        Returns true if this output is to a key, or an address we have the keys for, in the wallet.
      • toString

        public java.lang.String toString()
        Returns a human readable debug string.
        toString in class java.lang.Object
      • getSpentBy

        public TransactionInput getSpentBy()
        Returns the connected input.
      • getParentTransaction

        public Transaction getParentTransaction()
        Returns the transaction that owns this output.
      • getParentTransactionHash

        public Sha256Hash getParentTransactionHash()
        Returns the transaction hash that owns this output.
      • getParentTransactionDepthInBlocks

        public int getParentTransactionDepthInBlocks()
        Returns the depth in blocks of the parent tx.

        If the transaction appears in the top block, the depth is one. If it's anything else (pending, dead, unknown) then -1.

        The tx depth or -1.
      • getOutPointFor

        public TransactionOutPoint getOutPointFor()
        Returns a new TransactionOutPoint, which is essentially a structure pointing to this output. Requires that this output is not detached.
      • duplicateDetached

        public TransactionOutput duplicateDetached()
        Returns a copy of the output detached from its containing transaction, if need be.
      • equals

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

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