org.ethereum.util.RLPElement Java Examples
The following examples show how to use
org.ethereum.util.RLPElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Transaction.java From wkcwallet-java with Apache License 2.0 | 6 votes |
public void rlpParse() { RLPList decodedTxList = RLP.decode2(this.rlpEncoded); RLPList transaction = (RLPList)decodedTxList.get(0); this.nonce = ((RLPElement)transaction.get(0)).getRLPData(); this.gasPrice = ((RLPElement)transaction.get(1)).getRLPData(); this.gasLimit = ((RLPElement)transaction.get(2)).getRLPData(); this.receiveAddress = ((RLPElement)transaction.get(3)).getRLPData(); this.value = ((RLPElement)transaction.get(4)).getRLPData(); this.data = ((RLPElement)transaction.get(5)).getRLPData(); if(((RLPElement)transaction.get(6)).getRLPData() != null) { byte v = ((RLPElement)transaction.get(6)).getRLPData()[0]; byte[] r = ((RLPElement)transaction.get(7)).getRLPData(); byte[] s = ((RLPElement)transaction.get(8)).getRLPData(); this.signature = ECKey.ECDSASignature.fromComponents(r, s, v); } else { } this.parsed = true; this.hash = this.getHash(); }
Example #2
Source File: Block.java From ethereumj with MIT License | 6 votes |
private void parseRLP() { RLPList params = RLP.decode2(rlpEncoded); RLPList block = (RLPList) params.get(0); // Parse Header RLPList header = (RLPList) block.get(0); this.header = new BlockHeader(header); // Parse Transactions RLPList txReceipts = (RLPList) block.get(1); this.parseTxs(this.header.getTxTrieRoot(), txReceipts); // Parse Uncles RLPList uncleBlocks = (RLPList) block.get(2); for (RLPElement rawUncle : uncleBlocks) { RLPList uncleHeader = (RLPList) rawUncle; BlockHeader blockData = new BlockHeader(uncleHeader); this.uncleList.add(blockData); } this.parsed = true; }
Example #3
Source File: Block.java From ethereumj with MIT License | 6 votes |
private void parseTxs(byte[] expectedRoot, RLPList txReceipts) { this.txsState = new TrieImpl(null); for (int i = 0; i < txReceipts.size(); i++) { RLPElement rlpTxReceipt = txReceipts.get(i); RLPElement txData = ((RLPList)rlpTxReceipt).get(0); // YP 4.3.1 RLPElement pstTxState = ((RLPList)rlpTxReceipt).get(1); RLPElement cummGas = ((RLPList)rlpTxReceipt).get(2); Transaction tx = new Transaction(txData.getRLPData()); this.transactionsList.add(tx); TransactionReceipt txReceipt = new TransactionReceipt(tx, pstTxState.getRLPData(), cummGas.getRLPData()); this.addTxReceipt(i, txReceipt); } String calculatedRoot = Hex.toHexString(txsState.getRootHash()); if(!calculatedRoot.equals(Hex.toHexString(expectedRoot))) logger.error("Added tx receipts don't match the given txsStateRoot"); }
Example #4
Source File: JournalSource.java From nuls-v2 with MIT License | 5 votes |
private void parse(byte[] encoded) { RLPList l = (RLPList) RLP.decode2(encoded).get(0); updateHash = l.get(0).getRLPData(); for (RLPElement aRInserted : (RLPList) l.get(1)) { insertedKeys.add(aRInserted.getRLPData()); } for (RLPElement aRDeleted : (RLPList) l.get(2)) { deletedKeys.add(aRDeleted.getRLPData()); } }
Example #5
Source File: JournalSource.java From nuls with MIT License | 5 votes |
private void parse(byte[] encoded) { RLPList l = (RLPList) RLP.decode2(encoded).get(0); updateHash = l.get(0).getRLPData(); for (RLPElement aRInserted : (RLPList) l.get(1)) { insertedKeys.add(aRInserted.getRLPData()); } for (RLPElement aRDeleted : (RLPList) l.get(2)) { deletedKeys.add(aRDeleted.getRLPData()); } }