private void setBTCClient(String serverID) { try { this.serverID = serverID; if (!btcClientMap.containsKey(serverID)) { // get the details from bitcoin object from datastore WalletData walletData = Utility.getWalletData(); if (walletData == null) { System.out.println("setBTCClient - walletData returns null"); return; } for (int i = 0; i < walletData.GetBitcoinServerCount(); i++) { BitcoinServer btcServer = walletData.GetBitcoinServer(i); if (btcServer == null) { continue; } System.out.println( "serverID:" + serverID + " btcServer.getServer_id():" + btcServer.getServer_id()); if (serverID.equals(btcServer.getServer_id())) { int port = 8332; try { port = Integer.parseInt(btcServer.getServer_port()); } catch (NumberFormatException nfe) { } System.out.println( "btcServer.getServer_host():" + btcServer.getServer_host() + " btcServer.getBitcoin_username():" + btcServer.getBitcoin_username() + " btcServer.getBitcoin_password():" + btcServer.getBitcoin_password() + " port:" + port); // btcClient = new BitcoinClient(Configuration.getHostBitcoin(), // Configuration.getUserBitcoin(), Configuration.getPwdBitcoin(), // Configuration.getPortBitcoin()); btcClient = new BitcoinClient( btcServer.getServer_host(), btcServer.getBitcoin_username(), btcServer.getBitcoin_password(), port); btcClientMap.put(serverID, btcClient); break; } } } } catch (Exception e) { e.printStackTrace(); return; } }