Class LegacyTransaction
- java.lang.Object
-
- com.klaytn.caver.transaction.AbstractTransaction
-
- com.klaytn.caver.transaction.type.LegacyTransaction
-
- All Implemented Interfaces:
ITransactionWithGasPriceField
public class LegacyTransaction extends AbstractTransaction implements ITransactionWithGasPriceField
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LegacyTransaction.Builder
LegacyTransaction Builder class
-
Constructor Summary
Constructors Constructor Description LegacyTransaction(Klay klaytnCall, java.lang.String from, java.lang.String nonce, java.lang.String gas, java.lang.String gasPrice, java.lang.String chainId, java.util.List<SignatureData> signatures, java.lang.String to, java.lang.String input, java.lang.String value)
Create a LegacyTransaction instance.LegacyTransaction(LegacyTransaction.Builder builder)
Creates a LegacyTransaction instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendSignatures(SignatureData signatureData)
Appends signatures array to transaction.void
appendSignatures(java.util.List<SignatureData> signatureData)
Appends signatures array to transaction.java.lang.String
combineSignedRawTransactions(java.util.List<java.lang.String> rlpEncoded)
Combines signatures to the transaction from RLP-encoded transaction strings and returns a single transaction with all signatures combined.boolean
compareTxField(AbstractTransaction obj, boolean checkSig)
Check equals txObj passed parameter and Current instance.static LegacyTransaction
create(Klay klaytnCall, java.lang.String from, java.lang.String nonce, java.lang.String gas, java.lang.String gasPrice, java.lang.String chainId, java.util.List<SignatureData> signatures, java.lang.String to, java.lang.String input, java.lang.String value)
Create a LegacyTransaction instance.static LegacyTransaction
create(LegacyTransaction.Builder builder)
Creates a LegacyTransaction instance.static LegacyTransaction
decode(byte[] rlpEncoded)
Decodes a RLP-encoded LegacyTransaction byte array.static LegacyTransaction
decode(java.lang.String rlpEncoded)
Decodes a RLP-encoded LegacyTransaction string.void
fillTransaction()
Fills empty optional transaction field.(gasPrice)java.lang.String
getCommonRLPEncodingForSignature()
Returns the RLP-encoded string to make the signature of this transaction.java.lang.String
getGasPrice()
Getter function for gas pricejava.lang.String
getInput()
Getter function for inputjava.lang.String
getRLPEncoding()
Returns the RLP-encoded string of this transaction (i.e., rawTransaction).java.lang.String
getRLPEncodingForSignature()
Returns the RLP-encoded string to make the signature of this transaction.java.lang.String
getTo()
Getter function for tojava.lang.String
getValue()
Getter function for valuevoid
setGasPrice(java.lang.String gasPrice)
Setter function for gas price.void
setGasPrice(java.math.BigInteger gasPrice)
Setter function for gas price.void
setInput(java.lang.String input)
Setter function for inputvoid
setTo(java.lang.String to)
Setter function for tovoid
setValue(java.lang.String value)
Setter function for valuevoid
setValue(java.math.BigInteger value)
Setter function for valuevoid
validateOptionalValues(boolean checkChainID)
Checks that member variables that can be defined by the user are defined.-
Methods inherited from class com.klaytn.caver.transaction.AbstractTransaction
getChainId, getFrom, getGas, getKeyType, getKlaytnCall, getNonce, getRawTransaction, getSenderTxHash, getSignatures, getTransactionHash, getType, recoverPublicKeys, refineSignature, setChainId, setChainId, setFrom, setGas, setGas, setKlaytnCall, setNonce, setNonce, setSignatures, setType, sign, sign, sign, sign, sign, sign, suggestGasPrice
-
-
-
-
Constructor Detail
-
LegacyTransaction
public LegacyTransaction(LegacyTransaction.Builder builder)
Creates a LegacyTransaction instance.- Parameters:
builder
- LegacyTransaction.Builder instance.
-
LegacyTransaction
public LegacyTransaction(Klay klaytnCall, java.lang.String from, java.lang.String nonce, java.lang.String gas, java.lang.String gasPrice, java.lang.String chainId, java.util.List<SignatureData> signatures, java.lang.String to, java.lang.String input, java.lang.String value)
Create a LegacyTransaction instance.- Parameters:
klaytnCall
- Klay RPC instancefrom
- The address of the sender.nonce
- A value used to uniquely identify a sender’s transaction.gas
- The maximum amount of gas the transaction is allowed to use.gasPrice
- A unit price of gas in peb the sender will pay for a transaction fee.chainId
- Network IDsignatures
- A Signature listto
- The account address that will receive the transferred value.input
- Data attached to the transaction, used for transaction execution.value
- The amount of KLAY in peb to be transferred.
-
-
Method Detail
-
create
public static LegacyTransaction create(LegacyTransaction.Builder builder)
Creates a LegacyTransaction instance.- Parameters:
builder
- LegacyTransaction.Builder instance.- Returns:
- LegacyTransaction
-
create
public static LegacyTransaction create(Klay klaytnCall, java.lang.String from, java.lang.String nonce, java.lang.String gas, java.lang.String gasPrice, java.lang.String chainId, java.util.List<SignatureData> signatures, java.lang.String to, java.lang.String input, java.lang.String value)
Create a LegacyTransaction instance.- Parameters:
klaytnCall
- Klay RPC instancefrom
- The address of the sender.nonce
- A value used to uniquely identify a sender’s transaction.gas
- The maximum amount of gas the transaction is allowed to use.gasPrice
- A unit price of gas in peb the sender will pay for a transaction fee.chainId
- Network IDsignatures
- A Signature listto
- The account address that will receive the transferred value.input
- Data attached to the transaction, used for transaction execution.value
- The amount of KLAY in peb to be transferred.- Returns:
- LegacyTransaction
-
getGasPrice
public java.lang.String getGasPrice()
Getter function for gas price- Specified by:
getGasPrice
in interfaceITransactionWithGasPriceField
- Returns:
- String
-
setGasPrice
public void setGasPrice(java.lang.String gasPrice)
Setter function for gas price.- Parameters:
gasPrice
- A unit price of gas in peb the sender will pay for a transaction fee.
-
setGasPrice
public void setGasPrice(java.math.BigInteger gasPrice)
Setter function for gas price.- Parameters:
gasPrice
- A unit price of gas in peb the sender will pay for a transaction fee.
-
decode
public static LegacyTransaction decode(java.lang.String rlpEncoded)
Decodes a RLP-encoded LegacyTransaction string.- Parameters:
rlpEncoded
- RLP-encoded LegacyTransaction string- Returns:
- LegacyTransaction
-
decode
public static LegacyTransaction decode(byte[] rlpEncoded)
Decodes a RLP-encoded LegacyTransaction byte array.- Parameters:
rlpEncoded
- RLP-encoded LegacyTransaction byte array.- Returns:
- LegacyTransaction
-
appendSignatures
public void appendSignatures(SignatureData signatureData)
Appends signatures array to transaction. Legacy transaction cannot have more than one signature, so an error occurs if the transaction already has a signature.- Overrides:
appendSignatures
in classAbstractTransaction
- Parameters:
signatureData
- SignatureData instance contains ECDSA signature data
-
appendSignatures
public void appendSignatures(java.util.List<SignatureData> signatureData)
Appends signatures array to transaction. Legacy transaction cannot have more than one signature, so an error occurs if the transaction already has a signature.- Overrides:
appendSignatures
in classAbstractTransaction
- Parameters:
signatureData
- List of SignatureData contains ECDSA signature data
-
getRLPEncoding
public java.lang.String getRLPEncoding()
Returns the RLP-encoded string of this transaction (i.e., rawTransaction).- Specified by:
getRLPEncoding
in classAbstractTransaction
- Returns:
- String
-
getCommonRLPEncodingForSignature
public java.lang.String getCommonRLPEncodingForSignature()
Description copied from class:AbstractTransaction
Returns the RLP-encoded string to make the signature of this transaction.- Specified by:
getCommonRLPEncodingForSignature
in classAbstractTransaction
- Returns:
- String
-
getRLPEncodingForSignature
public java.lang.String getRLPEncodingForSignature()
Returns the RLP-encoded string to make the signature of this transaction.- Overrides:
getRLPEncodingForSignature
in classAbstractTransaction
- Returns:
- String
-
compareTxField
public boolean compareTxField(AbstractTransaction obj, boolean checkSig)
Check equals txObj passed parameter and Current instance.- Overrides:
compareTxField
in classAbstractTransaction
- Parameters:
obj
- The AbstractTransaction Object to comparecheckSig
- Check whether signatures field is equal.- Returns:
- boolean
-
combineSignedRawTransactions
public java.lang.String combineSignedRawTransactions(java.util.List<java.lang.String> rlpEncoded)
Description copied from class:AbstractTransaction
Combines signatures to the transaction from RLP-encoded transaction strings and returns a single transaction with all signatures combined. When combining the signatures into a transaction instance, an error is thrown if the decoded transaction contains different value except signatures.- Specified by:
combineSignedRawTransactions
in classAbstractTransaction
- Parameters:
rlpEncoded
- A List of RLP-encoded transaction strings.- Returns:
- String
-
fillTransaction
public void fillTransaction() throws java.io.IOException
Fills empty optional transaction field.(gasPrice)- Overrides:
fillTransaction
in classAbstractTransaction
- Throws:
java.io.IOException
-
validateOptionalValues
public void validateOptionalValues(boolean checkChainID)
Checks that member variables that can be defined by the user are defined. If there is an undefined variable, an error occurs.- Overrides:
validateOptionalValues
in classAbstractTransaction
-
getTo
public java.lang.String getTo()
Getter function for to- Returns:
- String
-
getInput
public java.lang.String getInput()
Getter function for input- Returns:
- String
-
getValue
public java.lang.String getValue()
Getter function for value- Returns:
- String
-
setTo
public void setTo(java.lang.String to)
Setter function for to- Parameters:
to
- The account address that will receive the transferred value.
-
setInput
public void setInput(java.lang.String input)
Setter function for input- Parameters:
input
- Data attached to the transaction.
-
setValue
public void setValue(java.lang.String value)
Setter function for value- Parameters:
value
- The amount of KLAY in peb to be transferred.
-
setValue
public void setValue(java.math.BigInteger value)
Setter function for value- Parameters:
value
- The amount of KLAY in peb to be transferred.
-
-