Package org.bitcoinj.core
Class TransactionOutPoint
- java.lang.Object
-
- org.bitcoinj.core.Message
-
- org.bitcoinj.core.ChildMessage
-
- org.bitcoinj.core.TransactionOutPoint
-
public class TransactionOutPoint extends ChildMessage
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 inherited from class org.bitcoinj.core.ChildMessage
parent
-
Fields inherited from class org.bitcoinj.core.Message
cursor, length, MAX_SIZE, offset, params, payload, recached, serializer, UNKNOWN_LENGTH
-
-
Constructor Summary
Constructors Constructor Description TransactionOutPoint(NetworkParameters params, byte[] payload, int offset)
/** Deserializes the message.TransactionOutPoint(NetworkParameters params, byte[] payload, int offset, Message parent, MessageSerializer serializer)
Deserializes the message.TransactionOutPoint(NetworkParameters params, long index, Sha256Hash hash)
TransactionOutPoint(NetworkParameters params, long index, Transaction fromTx)
TransactionOutPoint(NetworkParameters params, TransactionOutput connectedOutput)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
bitcoinSerializeToStream(java.io.OutputStream stream)
Serializes this message to the provided stream.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()
Returns the hash of the transaction this outpoint references/spends/is connected to.long
getIndex()
int
hashCode()
protected void
parse()
void
setIndex(long index)
java.lang.String
toString()
-
Methods inherited from class org.bitcoinj.core.ChildMessage
adjustLength, adjustLength, setParent, unCache
-
Methods inherited from class org.bitcoinj.core.Message
bitcoinSerialize, bitcoinSerialize, getMessageSize, getParams, hasMoreBytes, isCached, isRecached, readByte, readByteArray, readBytes, readHash, readInt64, readStr, readUint32, readUint64, readVarInt, readVarInt, setSerializer, unsafeBitcoinSerialize
-
-
-
-
Constructor Detail
-
TransactionOutPoint
public TransactionOutPoint(NetworkParameters params, long index, @Nullable Transaction fromTx)
-
TransactionOutPoint
public TransactionOutPoint(NetworkParameters params, long index, Sha256Hash hash)
-
TransactionOutPoint
public TransactionOutPoint(NetworkParameters params, TransactionOutput connectedOutput)
-
TransactionOutPoint
public TransactionOutPoint(NetworkParameters params, byte[] payload, int offset) throws ProtocolException
/** Deserializes the message. This is usually part of a transaction message.- Throws:
ProtocolException
-
TransactionOutPoint
public TransactionOutPoint(NetworkParameters params, byte[] payload, int offset, Message parent, MessageSerializer serializer) throws ProtocolException
Deserializes the message. This is usually part of a transaction message.- Parameters:
params
- NetworkParameters object.offset
- The location of the first payload byte within the array.serializer
- the serializer to use for this message.- Throws:
ProtocolException
-
-
Method Detail
-
parse
protected void parse() throws ProtocolException
- Specified by:
parse
in classMessage
- Throws:
ProtocolException
-
bitcoinSerializeToStream
protected void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Description copied from class:Message
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Overrides:
bitcoinSerializeToStream
in classMessage
- Throws:
java.io.IOException
-
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getHash
public Sha256Hash getHash()
Returns the hash of the transaction this outpoint references/spends/is connected to.
-
getIndex
public long getIndex()
-
setIndex
public void setIndex(long index)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-