Package org.bitcoinj.core
Class TransactionOutPoint
- java.lang.Object
-
- org.bitcoinj.core.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 Summary
Fields Modifier and Type Field Description static int
BYTES
static TransactionOutPoint
UNCONNECTED
Special outpoint that normally marks a coinbase input.
-
Constructor Summary
Constructors Constructor Description TransactionOutPoint(long index, Sha256Hash hash)
TransactionOutPoint(long index, Transaction fromTx)
TransactionOutPoint(TransactionOutput connectedOutput)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]
bitcoinSerialize()
Deprecated.useserialize()
TransactionOutPoint
connectTransaction(Transaction transaction)
Returns a copy of this outpoint, but with the provided transaction as fromTx.TransactionOutPoint
disconnectOutput()
Returns a copy of this outpoint, but with the connectedOutput removed.TransactionOutPoint
disconnectTransaction()
Returns a copy of this outpoint, but with fromTx removed.boolean
equals(java.lang.Object o)
ECKey
getConnectedKey(KeyBag keyBag)
Returns the ECKey identified in the connected output, for either P2PKH, P2WPKH or P2PK scripts.TransactionOutput
getConnectedOutput()
An outpoint is a part of a transaction input that points to the output of another transaction.byte[]
getConnectedPubKeyScript()
Returns the pubkey script from the connected output.RedeemData
getConnectedRedeemData(KeyBag keyBag)
Returns the RedeemData identified in the connected output, for either P2PKH, P2WPKH, P2PK or P2SH scripts.Sha256Hash
getHash()
Deprecated.Usehash()
long
getIndex()
Deprecated.Useindex()
int
getMessageSize()
Deprecated.useBYTES
Sha256Hash
hash()
Returns the hash of the transaction this outpoint references/spends/is connected to.int
hashCode()
long
index()
static TransactionOutPoint
read(java.nio.ByteBuffer payload)
Deserialize this transaction outpoint from a given payload.byte[]
serialize()
Allocates a byte array and writes this transaction outpoint into it.java.lang.String
toString()
java.nio.ByteBuffer
write(java.nio.ByteBuffer buf)
Write this transaction outpoint into the given buffer.
-
-
-
Field Detail
-
BYTES
public static final int BYTES
- See Also:
- Constant Field Values
-
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 payloadProtocolException
-
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.useserialize()
-
getMessageSize
@Deprecated public int getMessageSize()
Deprecated.useBYTES
-
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 usegetConnectedRedeemData(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 classjava.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
-
getHash
@Deprecated public Sha256Hash getHash()
Deprecated.Usehash()
-
getIndex
@Deprecated public long getIndex()
Deprecated.Useindex()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-