@Override public BigDecimal getCryptoBalance(String cryptoCurrency) { if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { log.error("Maxcoind wallet error: unknown cryptocurrency: " + cryptoCurrency); return null; } try { double balance = getClient(rpcURL).getBalance(accountName); return new BigDecimal(balance); } catch (BitcoinException e) { e.printStackTrace(); return null; } }
@Override public String getCryptoAddress(String cryptoCurrency) { if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { log.error("Maxcoind wallet error: unknown cryptocurrency."); return null; } try { List<String> addressesByAccount = getClient(rpcURL).getAddressesByAccount(accountName); if (addressesByAccount == null || addressesByAccount.size() == 0) { return null; } else { return addressesByAccount.get(0); } } catch (BitcoinException e) { e.printStackTrace(); return null; } }
@Override public String sendCoins( String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) { if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { log.error("Maxcoind wallet error: unknown cryptocurrency."); return null; } log.info( "Maxcoind sending coins from " + accountName + " to: " + destinationAddress + " " + amount); try { String result = getClient(rpcURL).sendFrom(accountName, destinationAddress, amount.doubleValue()); log.debug("result = " + result); return result; } catch (BitcoinException e) { e.printStackTrace(); return null; } }