@Test public void decodeRLPListString() { ByteBuffer wrapper = ByteBuffer.wrap(EthereumUtilTest.TEST_RLP_LIST_STRING); RLPObject elementObject = EthereumUtil.rlpDecodeNextItem(wrapper); RLPList list = (RLPList)elementObject; assertEquals(2,list.getRlpList().size(),"List of size 2"); RLPElement firstElement = (RLPElement) list.getRlpList().get(0); byte[] expectedIndicator = new byte[]{(byte) 0x83}; assertArrayEquals(expectedIndicator,firstElement.getIndicator(),"First element indicator is correct"); byte[] expectedRawData=new byte[]{'c','a','t'}; assertArrayEquals(expectedRawData,firstElement.getRawData(),"First element raw data is correct"); RLPElement secondElement = (RLPElement) list.getRlpList().get(1); expectedIndicator=new byte[]{(byte) 0x83}; assertArrayEquals(expectedIndicator,secondElement.getIndicator(),"Second element indicator is correct"); expectedRawData=new byte[]{'d','o','g'}; assertArrayEquals(expectedRawData,secondElement.getRawData(),"Second element raw data is correct"); }
public static RLPObject rlpDecodeNextItem(ByteBuffer bb) { RLPObject result=null; int objType = detectRLPObjectType(bb); switch (objType) { case EthereumUtil.RLP_OBJECTTYPE_ELEMENT: result=EthereumUtil.decodeRLPElement(bb); break; case EthereumUtil.RLP_OBJECTTYPE_LIST: result=EthereumUtil.decodeRLPList(bb); break; default: LOG.error("Unknown object type"); } return result; }
EthereumUtil { public static RLPObject rlpDecodeNextItem(ByteBuffer bb) { RLPObject result=null; int objType = detectRLPObjectType(bb); switch (objType) { case EthereumUtil.RLP_OBJECTTYPE_ELEMENT: result=EthereumUtil.decodeRLPElement(bb); break; case EthereumUtil.RLP_OBJECTTYPE_LIST: result=EthereumUtil.decodeRLPList(bb); break; default: LOG.error("Unknown object type"); } return result; } }
EthereumUtil { public static RLPObject rlpDecodeNextItem(ByteBuffer bb) { RLPObject result=null; int objType = detectRLPObjectType(bb); switch (objType) { case EthereumUtil.RLP_OBJECTTYPE_ELEMENT: result=EthereumUtil.decodeRLPElement(bb); break; case EthereumUtil.RLP_OBJECTTYPE_LIST: result=EthereumUtil.decodeRLPList(bb); break; default: LOG.error("Unknown object type"); } return result; }  }
EthereumUtil { public static RLPObject rlpDecodeNextItem(ByteBuffer bb) { RLPObject result=null; int objType = detectRLPObjectType(bb); switch (objType) { case EthereumUtil.RLP_OBJECTTYPE_ELEMENT: result=EthereumUtil.decodeRLPElement(bb); break; case EthereumUtil.RLP_OBJECTTYPE_LIST: result=EthereumUtil.decodeRLPList(bb); break; default: LOG.error("Unknown object type"); } return result; }  static RLPObject rlpDecodeNextItem(ByteBuffer bb); static int detectRLPObjectType(ByteBuffer bb); static byte[] encodeRLPElement(byte[] rawData); static long getRLPListSize(ByteBuffer bb); static Long calculateChainId(EthereumTransaction eTrans); static byte[] getTransactionHash(EthereumTransaction eTrans); static byte[] getTransactionHashWithoutSignature(EthereumTransaction eTrans); static byte[] getTransactionHashWithDummySignatureEIP155(EthereumTransaction eTrans); static byte[] getSendAddress(EthereumTransaction eTrans, int chainId); static BigInteger convertVarNumberToBigInteger(RLPElement rpe); static BigInteger convertVarNumberToBigInteger(byte[] rawData); static Long convertVarNumberToLong(RLPElement rpe); static Short convertToByte(RLPElement rpe); static Integer convertToShort(RLPElement rpe); static Long convertToInt(RLPElement rpe); static Long convertToLong(RLPElement rpe); @Deprecated static byte[] convertLongToVarInt(long value); static String convertToString(RLPElement rpe); static String convertToString(RLPElement rpe, String encoding); static byte[] convertHexStringToByteArray(String hexString); static String convertByteArrayToHexString(byte[] byteArray); static byte[] reverseByteArray(byte[] inputByteArray); }
EthereumUtil { public static RLPObject rlpDecodeNextItem(ByteBuffer bb) { RLPObject result=null; int objType = detectRLPObjectType(bb); switch (objType) { case EthereumUtil.RLP_OBJECTTYPE_ELEMENT: result=EthereumUtil.decodeRLPElement(bb); break; case EthereumUtil.RLP_OBJECTTYPE_LIST: result=EthereumUtil.decodeRLPList(bb); break; default: LOG.error("Unknown object type"); } return result; }  static RLPObject rlpDecodeNextItem(ByteBuffer bb); static int detectRLPObjectType(ByteBuffer bb); static byte[] encodeRLPElement(byte[] rawData); static long getRLPListSize(ByteBuffer bb); static Long calculateChainId(EthereumTransaction eTrans); static byte[] getTransactionHash(EthereumTransaction eTrans); static byte[] getTransactionHashWithoutSignature(EthereumTransaction eTrans); static byte[] getTransactionHashWithDummySignatureEIP155(EthereumTransaction eTrans); static byte[] getSendAddress(EthereumTransaction eTrans, int chainId); static BigInteger convertVarNumberToBigInteger(RLPElement rpe); static BigInteger convertVarNumberToBigInteger(byte[] rawData); static Long convertVarNumberToLong(RLPElement rpe); static Short convertToByte(RLPElement rpe); static Integer convertToShort(RLPElement rpe); static Long convertToInt(RLPElement rpe); static Long convertToLong(RLPElement rpe); @Deprecated static byte[] convertLongToVarInt(long value); static String convertToString(RLPElement rpe); static String convertToString(RLPElement rpe, String encoding); static byte[] convertHexStringToByteArray(String hexString); static String convertByteArrayToHexString(byte[] byteArray); static byte[] reverseByteArray(byte[] inputByteArray); static final int RLP_OBJECTTYPE_INVALID; static final int RLP_OBJECTTYPE_ELEMENT; static final int RLP_OBJECTTYPE_LIST; static final int CHAIN_ID_INC; static final int LOWER_REAL_V; static final int HASH_SIZE; static final int LONG_SIZE; static final int INT_SIZE; static final int WORD_SIZE; static final byte[] EMPTY_BYTE_ARRAY; }