@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 static Transaction create( String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit) { return new Transaction( BigIntegers.asUnsignedByteArray(nonce), BigIntegers.asUnsignedByteArray(gasPrice), BigIntegers.asUnsignedByteArray(gasLimit), Hex.decode(to), BigIntegers.asUnsignedByteArray(amount), null); }
public byte[] getEncoded() { if (rlpEncoded != null) return rlpEncoded; // 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); byte[] v, r, s; if (signature != null) { v = RLP.encodeByte(signature.v); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.r)); s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.s)); } else { v = RLP.encodeElement(EMPTY_BYTE_ARRAY); r = RLP.encodeElement(EMPTY_BYTE_ARRAY); s = RLP.encodeElement(EMPTY_BYTE_ARRAY); } this.rlpEncoded = RLP.encodeList(nonce, gasPrice, gasLimit, receiveAddress, value, data, v, r, s); this.hash = this.getHash(); return rlpEncoded; }