Package ch.bitagent.bitcoin.lib.tx
Class Tx
- java.lang.Object
-
- ch.bitagent.bitcoin.lib.tx.Tx
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IntcoinbaseHeight()Returns the height of the block this coinbase transaction is in Returns None if this transaction is not a coinbase transactionIntfee()Returns the fee of this transaction in satoshibyte[]getCommand()getCommand.IntgetLocktime()Getter for the fieldlocktime.BooleangetSegwit()Getter for the fieldsegwit.BooleangetTestnet()Getter for the fieldtestnet.List<TxIn>getTxIns()Getter for the fieldtxIns.List<TxOut>getTxOuts()Getter for the fieldtxOuts.IntgetVersion()Getter for the fieldversion.byte[]hash()Binary hash of the legacy serializationStringid()Human-readable hexadecimal of the transaction hashbooleanisCoinbase()Returns whether this transaction is a coinbase transaction or notstatic Txparse(ByteArrayInputStream stream, Boolean testnet)parse.byte[]serialize()serialize.voidsetLocktime(Int locktime)Setter for the fieldlocktime.IntsigHash(int inputIndex, Script redeemScript)Returns the integer representation of the hash that needs to get signed for index input_indexIntsigHashBip143(int inputIndex, Script redeemScript, Script witnessScript)Returns the integer representation of the hash that needs to get signed for index input_indexbooleansignInput(int inputIndex, PrivateKey privateKey)Signs the input using the private keyStringtoString()booleanverify()Verify this transactionbooleanverifyInput(int inputIndex)Returns whether the input has a valid signature
-
-
-
Field Detail
-
COMMAND
public static final String COMMAND
ConstantCOMMAND="tx"- See Also:
- Constant Field Values
-
-
Method Detail
-
getCommand
public byte[] getCommand()
getCommand.
- Specified by:
getCommandin interfaceMessage- Returns:
- an array of
byteobjects
-
hash
public byte[] hash()
Binary hash of the legacy serialization- Returns:
- an array of
byteobjects
-
parse
public static Tx parse(ByteArrayInputStream stream, Boolean testnet)
parse.
- Parameters:
stream- aByteArrayInputStreamobjecttestnet- aBooleanobject- Returns:
- a
Txobject
-
serialize
public byte[] serialize()
serialize.
-
sigHash
public Int sigHash(int inputIndex, Script redeemScript)
Returns the integer representation of the hash that needs to get signed for index input_index
-
sigHashBip143
public Int sigHashBip143(int inputIndex, Script redeemScript, Script witnessScript)
Returns the integer representation of the hash that needs to get signed for index input_index
-
verifyInput
public boolean verifyInput(int inputIndex)
Returns whether the input has a valid signature- Parameters:
inputIndex- a int- Returns:
- a boolean
-
verify
public boolean verify()
Verify this transaction- Returns:
- a boolean
-
signInput
public boolean signInput(int inputIndex, PrivateKey privateKey)Signs the input using the private key- Parameters:
inputIndex- a intprivateKey- aPrivateKeyobject- Returns:
- a boolean
-
isCoinbase
public boolean isCoinbase()
Returns whether this transaction is a coinbase transaction or not- Returns:
- a boolean
-
coinbaseHeight
public Int coinbaseHeight()
Returns the height of the block this coinbase transaction is in Returns None if this transaction is not a coinbase transaction- Returns:
- a
Intobject
-
setLocktime
public void setLocktime(Int locktime)
Setter for the field
locktime.- Parameters:
locktime- aIntobject
-
-