public List<String> getAccounts() { return getResult(); } }
@Test public void testEthAccounts() { buildResponse( "{\n" + " \"id\":1,\n" + " \"jsonrpc\": \"2.0\",\n" + " \"result\": [\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\"]\n" + "}" ); EthAccounts ethAccounts = deserialiseResponse(EthAccounts.class); assertThat(ethAccounts.getAccounts(), equalTo(Arrays.asList("0x407d73d8a49eeb85d32cf465507dd71d507100c1"))); }
@Test public void testClicqueGetSigners() { buildResponse("{\n" + " \"jsonrpc\": \"2.0\",\n" + " \"id\": 1,\n" + " \"result\": [\"0x42eb768f2244c8811c63729a21a3569731535f06\"," + "\"0x7ffc57839b00206d1ad20c69a1981b489f772031\"," + "\"0xb279182d99e65703f0076e4812653aab85fca0f0\"]\n" + "}"); EthAccounts ethAccounts = deserialiseResponse( EthAccounts.class); assertThat(ethAccounts.getAccounts().toString(), is("[0x42eb768f2244c8811c63729a21a3569731535f06, " + "0x7ffc57839b00206d1ad20c69a1981b489f772031, " + "0xb279182d99e65703f0076e4812653aab85fca0f0]")); }
@Test public void testEthAccounts() throws Exception { EthAccounts ethAccounts = web3j.ethAccounts().send(); assertNotNull(ethAccounts.getAccounts()); }
/** * Transfers 0.123 Ethers from the coinbase account to the client's second account. */ @Override public void run() throws Exception { super.run(); // get basic info EthMining mining = web3j.ethMining().sendAsync().get(); EthCoinbase coinbase = web3j.ethCoinbase().sendAsync().get(); EthAccounts accounts = web3j.ethAccounts().sendAsync().get(); System.out.println("Client is mining: " + mining.getResult()); System.out.println("Coinbase address: " + coinbase.getAddress()); System.out.println("Coinbase balance: " + Web3jUtils.getBalanceEther(web3j, coinbase.getAddress()) + "\n"); // get addresses and amount to transfer String fromAddress = coinbase.getAddress(); String toAddress = accounts.getResult().get(1); BigInteger amountWei = Convert.toWei("0.123", Convert.Unit.ETHER).toBigInteger(); // do the transfer demoTransfer(fromAddress, toAddress, amountWei); }
@InvokeOnHeader(Web3jConstants.ETH_ACCOUNTS) void ethAccounts(Message message) throws IOException { Request<?, EthAccounts> request = web3j.ethAccounts(); setRequestId(message, request); EthAccounts response = request.send(); message.setBody(response.getAccounts()); boolean hasError = checkForError(message, response); if (!hasError) { message.setBody(response.getAccounts()); } }
@Override public List<String> execute(final JsonRequestFactories node) { try { final EthAccounts result = node.eth().ethAccounts().send(); assertThat(result).isNotNull(); return result.getAccounts(); } catch (final IOException e) { throw new RuntimeException(e); } } }