@Test public void testRSize31() throws Exception { String hexTransaction = "0xf883370183419ce09433c98f20dd73d7bb1d533c4aa3371f2b30c6ebde80a45093dc7d00000000000000000000000000000000000000000000000000000000000000351c9fb90996c836fb34b782ee3d6efa9e2c79a75b277c014e353b51b23b00524d2da07435ebebca627a51a863bf590aff911c4746ab8386a0477c8221bb89671a5d58"; RawTransaction result = TransactionDecoder.decode(hexTransaction); SignedRawTransaction signedResult = (SignedRawTransaction) result; assertEquals("0x1b609b03e2e9b0275a61fa5c69a8f32550285536", signedResult.getFrom()); }
public static RawTransaction decode(String hexTransaction) { byte[] transaction = Numeric.hexStringToByteArray(hexTransaction); RlpList rlpList = RlpDecoder.decode(transaction); RlpList values = (RlpList) rlpList.getValues().get(0); BigInteger nonce = ((RlpString) values.getValues().get(0)).asBigInteger(); BigInteger gasPrice = ((RlpString) values.getValues().get(1)).asBigInteger(); BigInteger gasLimit = ((RlpString) values.getValues().get(2)).asBigInteger(); String to = ((RlpString) values.getValues().get(3)).asString(); BigInteger value = ((RlpString) values.getValues().get(4)).asBigInteger(); String data = ((RlpString) values.getValues().get(5)).asString(); if (values.getValues().size() > 6) { byte v = ((RlpString) values.getValues().get(6)).getBytes()[0]; byte[] r = zeroPadded(((RlpString) values.getValues().get(7)).getBytes(), 32); byte[] s = zeroPadded(((RlpString) values.getValues().get(8)).getBytes(), 32); Sign.SignatureData signatureData = new Sign.SignatureData(v, r, s); return new SignedRawTransaction(nonce, gasPrice, gasLimit, to, value, data, signatureData); } else { return RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); } }
TransactionDecoder { public static RawTransaction decode(String hexTransaction) { byte[] transaction = Numeric.hexStringToByteArray(hexTransaction); RlpList rlpList = RlpDecoder.decode(transaction); RlpList values = (RlpList) rlpList.getValues().get(0); BigInteger nonce = ((RlpString) values.getValues().get(0)).asBigInteger(); BigInteger gasPrice = ((RlpString) values.getValues().get(1)).asBigInteger(); BigInteger gasLimit = ((RlpString) values.getValues().get(2)).asBigInteger(); String to = ((RlpString) values.getValues().get(3)).asString(); BigInteger value = ((RlpString) values.getValues().get(4)).asBigInteger(); String data = ((RlpString) values.getValues().get(5)).asString(); if (values.getValues().size() > 6) { byte v = ((RlpString) values.getValues().get(6)).getBytes()[0]; byte[] r = zeroPadded(((RlpString) values.getValues().get(7)).getBytes(), 32); byte[] s = zeroPadded(((RlpString) values.getValues().get(8)).getBytes(), 32); Sign.SignatureData signatureData = new Sign.SignatureData(v, r, s); return new SignedRawTransaction(nonce, gasPrice, gasLimit, to, value, data, signatureData); } else { return RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); } } }
TransactionDecoder { public static RawTransaction decode(String hexTransaction) { byte[] transaction = Numeric.hexStringToByteArray(hexTransaction); RlpList rlpList = RlpDecoder.decode(transaction); RlpList values = (RlpList) rlpList.getValues().get(0); BigInteger nonce = ((RlpString) values.getValues().get(0)).asBigInteger(); BigInteger gasPrice = ((RlpString) values.getValues().get(1)).asBigInteger(); BigInteger gasLimit = ((RlpString) values.getValues().get(2)).asBigInteger(); String to = ((RlpString) values.getValues().get(3)).asString(); BigInteger value = ((RlpString) values.getValues().get(4)).asBigInteger(); String data = ((RlpString) values.getValues().get(5)).asString(); if (values.getValues().size() > 6) { byte v = ((RlpString) values.getValues().get(6)).getBytes()[0]; byte[] r = zeroPadded(((RlpString) values.getValues().get(7)).getBytes(), 32); byte[] s = zeroPadded(((RlpString) values.getValues().get(8)).getBytes(), 32); Sign.SignatureData signatureData = new Sign.SignatureData(v, r, s); return new SignedRawTransaction(nonce, gasPrice, gasLimit, to, value, data, signatureData); } else { return RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); } }  }
TransactionDecoder { public static RawTransaction decode(String hexTransaction) { byte[] transaction = Numeric.hexStringToByteArray(hexTransaction); RlpList rlpList = RlpDecoder.decode(transaction); RlpList values = (RlpList) rlpList.getValues().get(0); BigInteger nonce = ((RlpString) values.getValues().get(0)).asBigInteger(); BigInteger gasPrice = ((RlpString) values.getValues().get(1)).asBigInteger(); BigInteger gasLimit = ((RlpString) values.getValues().get(2)).asBigInteger(); String to = ((RlpString) values.getValues().get(3)).asString(); BigInteger value = ((RlpString) values.getValues().get(4)).asBigInteger(); String data = ((RlpString) values.getValues().get(5)).asString(); if (values.getValues().size() > 6) { byte v = ((RlpString) values.getValues().get(6)).getBytes()[0]; byte[] r = zeroPadded(((RlpString) values.getValues().get(7)).getBytes(), 32); byte[] s = zeroPadded(((RlpString) values.getValues().get(8)).getBytes(), 32); Sign.SignatureData signatureData = new Sign.SignatureData(v, r, s); return new SignedRawTransaction(nonce, gasPrice, gasLimit, to, value, data, signatureData); } else { return RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); } }  static RawTransaction decode(String hexTransaction); }
TransactionDecoder { public static RawTransaction decode(String hexTransaction) { byte[] transaction = Numeric.hexStringToByteArray(hexTransaction); RlpList rlpList = RlpDecoder.decode(transaction); RlpList values = (RlpList) rlpList.getValues().get(0); BigInteger nonce = ((RlpString) values.getValues().get(0)).asBigInteger(); BigInteger gasPrice = ((RlpString) values.getValues().get(1)).asBigInteger(); BigInteger gasLimit = ((RlpString) values.getValues().get(2)).asBigInteger(); String to = ((RlpString) values.getValues().get(3)).asString(); BigInteger value = ((RlpString) values.getValues().get(4)).asBigInteger(); String data = ((RlpString) values.getValues().get(5)).asString(); if (values.getValues().size() > 6) { byte v = ((RlpString) values.getValues().get(6)).getBytes()[0]; byte[] r = zeroPadded(((RlpString) values.getValues().get(7)).getBytes(), 32); byte[] s = zeroPadded(((RlpString) values.getValues().get(8)).getBytes(), 32); Sign.SignatureData signatureData = new Sign.SignatureData(v, r, s); return new SignedRawTransaction(nonce, gasPrice, gasLimit, to, value, data, signatureData); } else { return RawTransaction.createTransaction(nonce, gasPrice, gasLimit, to, value, data); } }  static RawTransaction decode(String hexTransaction);  }