Skip to content

Commit

Permalink
modify rawtransaction decode.use Numeric.
Browse files Browse the repository at this point in the history
  • Loading branch information
TOTOROYang authored Jun 28, 2018
1 parent 8e682c0 commit 37c2588
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions crypto/src/main/java/org/web3j/crypto/TransactionDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public static RawTransaction decode(String hexTransaction) {
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);
byte[] r = Numeric.toBytesPadded(Numeric.toBigInt(((RlpString) values.getValues().get(7)).getBytes()), 32);
byte[] s = Numeric.toBytesPadded(Numeric.toBigInt(((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);
Expand All @@ -31,14 +31,4 @@ public static RawTransaction decode(String hexTransaction) {
gasPrice, gasLimit, to, value, data);
}
}

private static byte[] zeroPadded(byte[] value, int size) {
if (value.length == size) {
return value;
}
int diff = size - value.length;
byte[] paddedValue = new byte[size];
System.arraycopy(value, 0, paddedValue, diff, value.length);
return paddedValue;
}
}

0 comments on commit 37c2588

Please sign in to comment.