Java Code Examples for org.ethereum.util.RLP#encodeBigInteger()
The following examples show how to use
org.ethereum.util.RLP#encodeBigInteger() .
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: BlockHeader.java From ethereumj with MIT License | 6 votes |
public byte[] getEncoded(boolean withNonce) { byte[] parentHash = RLP.encodeElement(this.parentHash); byte[] unclesHash = RLP.encodeElement(this.unclesHash); byte[] coinbase = RLP.encodeElement(this.coinbase); byte[] stateRoot = RLP.encodeElement(this.stateRoot); byte[] txTrieRoot = RLP.encodeElement(this.txTrieRoot); byte[] difficulty = RLP.encodeElement(this.difficulty); byte[] number = RLP.encodeBigInteger(BigInteger.valueOf(this.number)); byte[] minGasPrice = RLP.encodeBigInteger(BigInteger.valueOf(this.minGasPrice)); byte[] gasLimit = RLP.encodeBigInteger(BigInteger.valueOf(this.gasLimit)); byte[] gasUsed = RLP.encodeBigInteger(BigInteger.valueOf(this.gasUsed)); byte[] timestamp = RLP.encodeBigInteger(BigInteger.valueOf(this.timestamp)); byte[] extraData = RLP.encodeElement(this.extraData); if(withNonce) { byte[] nonce = RLP.encodeElement(this.nonce); return RLP.encodeList(parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp, extraData, nonce); } else { return RLP.encodeList(parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp, extraData); } }
Example 2
Source File: HashUtil.java From nuls-v2 with MIT License | 5 votes |
/** * The way to calculate new address inside ethereum * * @param addr - creating address * @param nonce - nonce of creating address * @return new address */ public static byte[] calcNewAddr(byte[] addr, byte[] nonce) { byte[] encSender = RLP.encodeElement(addr); byte[] encNonce = RLP.encodeBigInteger(new BigInteger(1, nonce)); return sha3omit12(RLP.encodeList(encSender, encNonce)); }
Example 3
Source File: AccountState.java From nuls-v2 with MIT License | 5 votes |
public byte[] getEncoded() { if (rlpEncoded == null) { byte[] nonce = RLP.encodeBigInteger(this.nonce); byte[] balance = RLP.encodeBigInteger(this.balance); byte[] stateRoot = RLP.encodeElement(this.stateRoot); byte[] codeHash = RLP.encodeElement(this.codeHash); byte[] owner = RLP.encodeElement(this.owner); this.rlpEncoded = RLP.encodeList(nonce, balance, stateRoot, codeHash, owner); } return rlpEncoded; }
Example 4
Source File: HashUtil.java From wkcwallet-java with Apache License 2.0 | 5 votes |
/** * The way to calculate new address inside ethereum * * @param addr - creating addres * @param nonce - nonce of creating address * @return new address */ public static byte[] calcNewAddr(byte[] addr, byte[] nonce) { byte[] encSender = RLP.encodeElement(addr); byte[] encNonce = RLP.encodeBigInteger(new BigInteger(1, nonce)); return sha3omit12(RLP.encodeList(encSender, encNonce)); }
Example 5
Source File: HashUtil.java From nuls with MIT License | 5 votes |
/** * The way to calculate new address inside ethereum * * @param addr - creating address * @param nonce - nonce of creating address * @return new address */ public static byte[] calcNewAddr(byte[] addr, byte[] nonce) { byte[] encSender = RLP.encodeElement(addr); byte[] encNonce = RLP.encodeBigInteger(new BigInteger(1, nonce)); return sha3omit12(RLP.encodeList(encSender, encNonce)); }
Example 6
Source File: AccountState.java From nuls with MIT License | 5 votes |
public byte[] getEncoded() { if (rlpEncoded == null) { byte[] nonce = RLP.encodeBigInteger(this.nonce); byte[] balance = RLP.encodeBigInteger(this.balance); byte[] stateRoot = RLP.encodeElement(this.stateRoot); byte[] codeHash = RLP.encodeElement(this.codeHash); byte[] owner = RLP.encodeElement(this.owner); this.rlpEncoded = RLP.encodeList(nonce, balance, stateRoot, codeHash, owner); } return rlpEncoded; }
Example 7
Source File: HashUtil.java From ethereumj with MIT License | 5 votes |
/** * The way to calculate new address inside ethereum * * @param addr - creating addres * @param nonce - nonce of creating address * @return new address */ public static byte[] calcNewAddr(byte[] addr, byte[] nonce) { byte[] encSender = RLP.encodeElement(addr); byte[] encNonce = RLP.encodeBigInteger(new BigInteger(1, nonce)); byte[] newAddress = sha3omit12(RLP.encodeList(encSender, encNonce)); return newAddress; }
Example 8
Source File: AccountState.java From ethereumj with MIT License | 5 votes |
public byte[] getEncoded() { if(rlpEncoded == null) { byte[] nonce = RLP.encodeBigInteger(this.nonce); byte[] balance = RLP.encodeBigInteger(this.balance); byte[] stateRoot = RLP.encodeElement(this.stateRoot); byte[] codeHash = RLP.encodeElement(this.codeHash); this.rlpEncoded = RLP.encodeList(nonce, balance, stateRoot, codeHash); } return rlpEncoded; }
Example 9
Source File: BlockHeader.java From nuls-v2 with MIT License | 4 votes |
public byte[] getEncoded(boolean withNonce) { byte[] parentHash = RLP.encodeElement(this.parentHash); byte[] hash = RLP.encodeElement(this.hash); byte[] number = RLP.encodeBigInteger(BigInteger.valueOf(this.number)); return RLP.encodeList(parentHash, hash, number); }
Example 10
Source File: BlockHeader.java From nuls with MIT License | 4 votes |
public byte[] getEncoded(boolean withNonce) { byte[] parentHash = RLP.encodeElement(this.parentHash); byte[] hash = RLP.encodeElement(this.hash); byte[] number = RLP.encodeBigInteger(BigInteger.valueOf(this.number)); return RLP.encodeList(parentHash, hash, number); }