示例#1
0
 @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)))
       + "]";
 }
示例#2
0
  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;
  }
示例#3
0
  /** 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;
  }
示例#4
0
 public boolean isContractCreation() {
   if (!parsed) rlpParse();
   return this.receiveAddress == null
       || Arrays.equals(this.receiveAddress, ByteUtil.EMPTY_BYTE_ARRAY);
 }
示例#5
0
 public ECDSASignature getSignature() {
   if (!parsed) rlpParse();
   return signature;
 }
示例#6
0
 public byte[] getData() {
   if (!parsed) rlpParse();
   return data;
 }
示例#7
0
 public byte[] getGasLimit() {
   if (!parsed) rlpParse();
   return gasLimit;
 }
示例#8
0
 public byte[] getGasPrice() {
   if (!parsed) rlpParse();
   return gasPrice == null ? ZERO_BYTE_ARRAY : gasPrice;
 }
示例#9
0
 public byte[] getReceiveAddress() {
   if (!parsed) rlpParse();
   return receiveAddress;
 }
示例#10
0
 public byte[] getValue() {
   if (!parsed) rlpParse();
   return value == null ? ZERO_BYTE_ARRAY : value;
 }
示例#11
0
 public boolean isValueTx() {
   if (!parsed) rlpParse();
   return value != null;
 }
示例#12
0
  public byte[] getNonce() {
    if (!parsed) rlpParse();

    return nonce == null ? ZERO_BYTE_ARRAY : nonce;
  }
示例#13
0
 public byte[] getRawHash() {
   if (!parsed) rlpParse();
   byte[] plainMsg = this.getEncodedRaw();
   return HashUtil.sha3(plainMsg);
 }