@Test public void decodeRLPElementInt15() { ByteBuffer wrapper = ByteBuffer.wrap(EthereumUtilTest.TEST_RLP_ELEMENT_INT_15); RLPObject elementObject = EthereumUtil.rlpDecodeNextItem(wrapper); RLPElement element = (RLPElement)elementObject; byte[] expectedIndicator = new byte[] {(byte) 0x0f}; assertArrayEquals( expectedIndicator, element.getIndicator(),"Indicator is correct"); assertEquals( 1,element.getRawData().length,"Raw data has length 1"); assertEquals( 15,element.getRawData()[0],"Raw data contains the element 15"); }
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; }