@Override public String toString() { if (!parsed) rlpParse(); return "TransactionData [" + "hash=" + ByteUtil.toHexString(hash) + " nonce=" + ByteUtil.toHexString(nonce) + ", gasPrice=" + ByteUtil.toHexString(gasPrice) + ", gas=" + ByteUtil.toHexString(gasLimit) + ", receiveAddress=" + ByteUtil.toHexString(receiveAddress) + ", value=" + ByteUtil.toHexString(value) + ", data=" + ByteUtil.toHexString(data) + ", signatureV=" + (signature == null ? "" : signature.v) + ", signatureR=" + (signature == null ? "" : ByteUtil.toHexString(BigIntegers.asUnsignedByteArray(signature.r))) + ", signatureS=" + (signature == null ? "" : ByteUtil.toHexString(BigIntegers.asUnsignedByteArray(signature.s))) + "]"; }
public long transactionCost() { if (!parsed) rlpParse(); long nonZeroes = nonZeroDataBytes(); long zeroVals = data.length - nonZeroes; return GasCost.TRANSACTION + zeroVals * GasCost.TX_ZERO_DATA + nonZeroes * GasCost.TX_NO_ZERO_DATA; }
/** For signatures you have to keep also RLP of the transaction without any signature data */ public byte[] getEncodedRaw() { if (!parsed) rlpParse(); if (rlpRaw != null) return rlpRaw; // parse null as 0 for nonce byte[] nonce = null; if (this.nonce == null || this.nonce.length == 1 && this.nonce[0] == 0) { nonce = RLP.encodeElement(null); } else { nonce = RLP.encodeElement(this.nonce); } byte[] gasPrice = RLP.encodeElement(this.gasPrice); byte[] gasLimit = RLP.encodeElement(this.gasLimit); byte[] receiveAddress = RLP.encodeElement(this.receiveAddress); byte[] value = RLP.encodeElement(this.value); byte[] data = RLP.encodeElement(this.data); rlpRaw = RLP.encodeList(nonce, gasPrice, gasLimit, receiveAddress, value, data); return rlpRaw; }
public boolean isContractCreation() { if (!parsed) rlpParse(); return this.receiveAddress == null || Arrays.equals(this.receiveAddress, ByteUtil.EMPTY_BYTE_ARRAY); }
public ECDSASignature getSignature() { if (!parsed) rlpParse(); return signature; }
public byte[] getData() { if (!parsed) rlpParse(); return data; }
public byte[] getGasLimit() { if (!parsed) rlpParse(); return gasLimit; }
public byte[] getGasPrice() { if (!parsed) rlpParse(); return gasPrice == null ? ZERO_BYTE_ARRAY : gasPrice; }
public byte[] getReceiveAddress() { if (!parsed) rlpParse(); return receiveAddress; }
public byte[] getValue() { if (!parsed) rlpParse(); return value == null ? ZERO_BYTE_ARRAY : value; }
public boolean isValueTx() { if (!parsed) rlpParse(); return value != null; }
public byte[] getNonce() { if (!parsed) rlpParse(); return nonce == null ? ZERO_BYTE_ARRAY : nonce; }
public byte[] getRawHash() { if (!parsed) rlpParse(); byte[] plainMsg = this.getEncodedRaw(); return HashUtil.sha3(plainMsg); }