@Override public void parse(byte[] data) { RLPList list = (RLPList) RLP.decode2OneItem(data, 0); this.token = list.get(0).getRLPData(); RLPItem expires = (RLPItem) list.get(1); this.expires = ByteUtil.byteArrayToLong(expires.getRLPData()); }
public TransactionInfo(byte[] rlp) { RLPList params = RLP.decode2(rlp); RLPList txInfo = (RLPList) params.get(0); RLPList receiptRLP = (RLPList) txInfo.get(0); RLPItem blockHashRLP = (RLPItem) txInfo.get(1); RLPItem indexRLP = (RLPItem) txInfo.get(2); receipt = new TransactionReceipt(receiptRLP.getRLPData()); blockHash = blockHashRLP.getRLPData(); if (indexRLP.getRLPData() == null) index = 0; else index = new BigInteger(1, indexRLP.getRLPData()).intValue(); }
static AuthResponseMessageV4 decode(byte[] wire) { AuthResponseMessageV4 message = new AuthResponseMessageV4(); RLPList params = (RLPList) RLP.decode2OneItem(wire, 0); byte[] pubKeyBytes = params.get(0).getRLPData(); byte[] bytes = new byte[65]; System.arraycopy(pubKeyBytes, 0, bytes, 1, 64); bytes[0] = 0x04; // uncompressed message.ephemeralPublicKey = ECKey.CURVE.getCurve().decodePoint(bytes); message.nonce = params.get(1).getRLPData(); byte[] versionBytes = params.get(2).getRLPData(); message.version = ByteUtil.byteArrayToInt(versionBytes); return message; }
public AccountState(byte[] rlpData) { this.rlpEncoded = rlpData; RLPList items = (RLPList) RLP.decode2(rlpEncoded).get(0); this.nonce = items.get(0).getRLPData() == null ? BigInteger.ZERO : new BigInteger(1, items.get(0).getRLPData()); this.balance = items.get(1).getRLPData() == null ? BigInteger.ZERO : new BigInteger(1, items.get(1).getRLPData()); this.stateRoot = items.get(2).getRLPData(); this.codeHash = items.get(3).getRLPData(); }
public void rlpParse() { RLPList decodedTxList = RLP.decode2(rlpEncoded); RLPList transaction = (RLPList) decodedTxList.get(0); this.nonce = transaction.get(0).getRLPData(); this.gasPrice = transaction.get(1).getRLPData(); this.gasLimit = transaction.get(2).getRLPData(); this.receiveAddress = transaction.get(3).getRLPData(); this.value = transaction.get(4).getRLPData(); this.data = transaction.get(5).getRLPData(); // only parse signature in case tx is signed if (transaction.get(6).getRLPData() != null) { byte v = transaction.get(6).getRLPData()[0]; byte[] r = transaction.get(7).getRLPData(); byte[] s = transaction.get(8).getRLPData(); this.signature = ECDSASignature.fromComponents(r, s, v); } else { logger.debug("RLP encoded tx is not signed!"); } this.parsed = true; this.hash = getHash(); }
@Override public void decode(byte[] rlpCode) { RLPList data = RLP.decode2(rlpCode); RLPList rlpList = (RLPList) data.get(0); RLPList keys = (RLPList) rlpList.get(0); RLPList values = (RLPList) rlpList.get(1); RLPElement code = rlpList.get(2); for (int i = 0; i < keys.size(); ++i) { RLPItem key = (RLPItem) keys.get(i); RLPItem value = (RLPItem) values.get(i); storage.put(new DataWord(key.getRLPData()), new DataWord(value.getRLPData())); } this.code = (code.getRLPData() == null) ? ByteUtil.EMPTY_BYTE_ARRAY : code.getRLPData(); }