public static BigInteger toBigInt(byte[] value, int offset, int length) { return toBigInt((Arrays.copyOfRange(value, offset, offset + length))); }
public static ECKeyPair deserialize(byte[] input) { if (input.length != PRIVATE_KEY_SIZE + PUBLIC_KEY_SIZE) { throw new RuntimeException("Invalid input key size"); } BigInteger privateKey = Numeric.toBigInt(input, 0, PRIVATE_KEY_SIZE); BigInteger publicKey = Numeric.toBigInt(input, PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE); return new ECKeyPair(privateKey, publicKey); } }
public void setV(Object v) { if (v instanceof String) { this.v = Numeric.toBigInt((String) v).longValueExact(); } else if (v instanceof Integer) { this.v = ((Integer) v).longValue(); } else { this.v = (Long) v; } }
static Bool decodeBool(String rawInput, int offset) { String input = rawInput.substring(offset, offset + MAX_BYTE_LENGTH_FOR_HEX_STRING); BigInteger numericValue = Numeric.toBigInt(input); boolean value = numericValue.equals(BigInteger.ONE); return new Bool(value); }
public static Bip32ECKeyPair create(byte[] privateKey, byte[] chainCode) { return create(Numeric.toBigInt(privateKey), chainCode); }
@Test public void testShhPost() throws Exception { //CHECKSTYLE:OFF web3j.shhPost(new ShhPost( "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1", "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1", Arrays.asList("0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"), "0x7b2274797065223a226d6", Numeric.toBigInt("0x64"), Numeric.toBigInt("0x64"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_post\",\"params\":[{\"from\":\"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1\",\"to\":\"0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1\",\"topics\":[\"0x776869737065722d636861742d636c69656e74\",\"0x4d5a695276454c39425154466b61693532\"],\"payload\":\"0x7b2274797065223a226d6\",\"priority\":\"0x64\",\"ttl\":\"0x64\"}],\"id\":1}"); //CHECKSTYLE:ON }
private void assertCorrectEntropy(String expected, String mnemonic, int size) { Assert.assertEquals(expected, Numeric.toHexStringNoPrefixZeroPadded( Numeric.toBigInt(MnemonicUtils.generateEntropy(mnemonic)), size)); } }
@Test public void testEthUninstallFilter() throws Exception { web3j.ethUninstallFilter(Numeric.toBigInt("0xb")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_uninstallFilter\"," + "\"params\":[\"0x0b\"],\"id\":1}"); }
@Test public void testEthGetFilterChanges() throws Exception { web3j.ethGetFilterChanges(Numeric.toBigInt("0x16")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getFilterChanges\"," + "\"params\":[\"0x16\"],\"id\":1}"); }
@Test public void testEthGetFilterLogs() throws Exception { web3j.ethGetFilterLogs(Numeric.toBigInt("0x16")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getFilterLogs\"," + "\"params\":[\"0x16\"],\"id\":1}"); }
@Test public void testShhGetFilterChanges() throws Exception { web3j.shhGetFilterChanges(Numeric.toBigInt("0x7")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getFilterChanges\"," + "\"params\":[\"0x07\"],\"id\":1}"); }
@Test public void testShhUninstallFilter() throws Exception { web3j.shhUninstallFilter(Numeric.toBigInt("0x7")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_uninstallFilter\"," + "\"params\":[\"0x07\"],\"id\":1}"); }
@Test public void testShhGetMessages() throws Exception { web3j.shhGetMessages(Numeric.toBigInt("0x7")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getMessages\"," + "\"params\":[\"0x07\"],\"id\":1}"); } }
@Test public void testEthGetCode() throws Exception { web3j.ethGetCode("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", DefaultBlockParameter.valueOf(Numeric.toBigInt("0x2"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\"," + "\"params\":[\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\",\"0x2\"],\"id\":1}"); }
@Test public void testEthGetTransactionByBlockNumberAndIndex() throws Exception { web3j.ethGetTransactionByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockNumberAndIndex\"," + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}"); }
@Test public void testEthGetBlockTransactionCountByNumber() throws Exception { web3j.ethGetBlockTransactionCountByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByNumber\"," + "\"params\":[\"0xe8\"],\"id\":1}"); }
@Test public void testEthGetUncleCountByBlockNumber() throws Exception { web3j.ethGetUncleCountByBlockNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleCountByBlockNumber\"," + "\"params\":[\"0xe8\"],\"id\":1}"); }
@Test public void testEthGetBlockByNumber() throws Exception { web3j.ethGetBlockByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x1b4")), true).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\"," + "\"params\":[\"0x1b4\",true],\"id\":1}"); }
@Test public void testEthGetUncleByBlockNumberAndIndex() throws Exception { web3j.ethGetUncleByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleByBlockNumberAndIndex\"," + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}"); }
@Test public void testEthGetLogsWithNumericBlockRange() throws Exception { web3j.ethGetLogs(new EthFilter( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8")), DefaultBlockParameter.valueOf("latest"), "")) .send(); verifyResult( "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getLogs\"," + "\"params\":[{\"topics\":[],\"fromBlock\":\"0xe8\"," + "\"toBlock\":\"latest\",\"address\":[\"\"]}],\"id\":1}"); }