From 71e185d9eb8b88753c2986d828cdebc401542118 Mon Sep 17 00:00:00 2001 From: romanman Date: Wed, 28 May 2014 19:34:05 +0300 Subject: [PATCH] Fixing bug in RLP --- ethereumj-core/src/main/java/org/ethereum/util/RLP.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java index d0c37148..6a55cc92 100644 --- a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java +++ b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java @@ -813,7 +813,7 @@ public class RLP { } byte[] lenBytes = new byte[byteNum]; for (int i = 0; i < byteNum; ++i) { - lenBytes[0] = (byte) ((srcData.length >> (8 * i)) & 0xFF); + lenBytes[byteNum - 1 - i] = (byte) ((srcData.length >> (8 * i)) & 0xFF); } // first byte = F7 + bytes.length byte[] data = Arrays.copyOf(srcData, srcData.length + 1 + byteNum); @@ -851,7 +851,7 @@ public class RLP { tmpLength = totalLength; byte[] lenBytes = new byte[byteNum]; for (int i = 0; i < byteNum; ++i) { - lenBytes[i] = (byte) ((tmpLength >> (8 * i)) & 0xFF); + lenBytes[byteNum - 1 - i] = (byte) ((tmpLength >> (8 * i)) & 0xFF); } // first byte = F7 + bytes.length data = new byte[1 + lenBytes.length + totalLength];