diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coingecko/CoinGeckoRateSource.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coingecko/CoinGeckoRateSource.java index 5bda11773..ee3b5557d 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coingecko/CoinGeckoRateSource.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coingecko/CoinGeckoRateSource.java @@ -94,6 +94,7 @@ public class CoinGeckoRateSource implements IRateSource { CRYPTOCURRENCIES.put(CryptoCurrency.USDTTRON.getCode(), "tether"); // using USDT for rate source CRYPTOCURRENCIES.put(CryptoCurrency.USDS.getCode(), "stableusd"); CRYPTOCURRENCIES.put(CryptoCurrency.VIA.getCode(), "viacoin"); + CRYPTOCURRENCIES.put(CryptoCurrency.VERUM.getCode(), "verum-coin"); CRYPTOCURRENCIES.put(CryptoCurrency.VOLTZ.getCode(), "voltz"); CRYPTOCURRENCIES.put(CryptoCurrency.WDC.getCode(), "worldcoin"); CRYPTOCURRENCIES.put(CryptoCurrency.XMR.getCode(), "monero"); diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coinpaprika/CoinPaprikaRateSource.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coinpaprika/CoinPaprikaRateSource.java index ae3540ac8..9be7fc5a9 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coinpaprika/CoinPaprikaRateSource.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/sources/coinpaprika/CoinPaprikaRateSource.java @@ -95,6 +95,7 @@ public class CoinPaprikaRateSource implements IRateSource { CRYPTOCURRENCIES.put(CryptoCurrency.USDT.getCode(), "usdt-tether"); CRYPTOCURRENCIES.put(CryptoCurrency.USDTTRON.getCode(), "usdt-tether"); // using USDT for rate source CRYPTOCURRENCIES.put(CryptoCurrency.VIA.getCode(), "via-viacoin"); + CRYPTOCURRENCIES.put(CryptoCurrency.VERUM.getCode(), "verum-verum-coin"); CRYPTOCURRENCIES.put(CryptoCurrency.VOLTZ.getCode(), "voltz-voltz"); CRYPTOCURRENCIES.put(CryptoCurrency.WDC.getCode(), "wdc-worldcoin"); CRYPTOCURRENCIES.put(CryptoCurrency.XMR.getCode(), "xmr-monero"); diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinDefinition.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinDefinition.java new file mode 100644 index 000000000..99d7f5dc9 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinDefinition.java @@ -0,0 +1,35 @@ +/************************************************************************************* + * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.verumcoin; + +import com.generalbytes.batm.server.extensions.CryptoCurrencyDefinition; +import com.generalbytes.batm.common.currencies.CryptoCurrency; +import com.generalbytes.batm.server.extensions.payment.IPaymentSupport; + +public class VerumcoinDefinition extends CryptoCurrencyDefinition{ + private IPaymentSupport paymentSupport = new VerumcoinPaymentSupport(); + + public VerumcoinDefinition() { + super(CryptoCurrency.VERUM.getCode(), "Verumcoin", "verumcoin","https://verumchain.info"); + } + + @Override + public IPaymentSupport getPaymentSupport() { + return paymentSupport; + } +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinExtension.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinExtension.java index 79a142abd..c14f8e96f 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinExtension.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinExtension.java @@ -18,6 +18,7 @@ package com.generalbytes.batm.server.extensions.extra.verumcoin; import com.generalbytes.batm.common.currencies.CryptoCurrency; +import com.generalbytes.batm.server.extensions.ICryptoCurrencyDefinition; import com.generalbytes.batm.common.currencies.FiatCurrency; import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.FixPriceRateSource; @@ -31,6 +32,8 @@ public class VerumcoinExtension extends AbstractExtension{ + private static final ICryptoCurrencyDefinition DEFINITION = new VerumcoinDefinition(); + @Override public String getName() { return "BATM Verumcoin extension"; @@ -52,21 +55,21 @@ public IWallet createWallet(String walletLogin, String tunnelPassword) { String password = st.nextToken(); String hostname = st.nextToken(); int port = Integer.parseInt(st.nextToken()); - String label = ""; + String accountName = ""; if (st.hasMoreTokens()) { - label = st.nextToken(); + accountName = st.nextToken(); } InetSocketAddress tunnelAddress = ctx.getTunnelManager().connectIfNeeded(walletLogin, tunnelPassword, InetSocketAddress.createUnresolved(hostname, port)); hostname = tunnelAddress.getHostString(); port = tunnelAddress.getPort(); - if (protocol != null && username != null && password != null && hostname !=null && label != null) { + if (protocol != null && username != null && password != null && hostname !=null && accountName != null) { String rpcURL = protocol +"://" + username +":" + password + "@" + hostname +":" + port; if ("verumcoindnoforward".equalsIgnoreCase(walletType)) { - return new VerumcoindUniqueAddressRPCWallet(rpcURL); + return new VerumcoindUniqueAddressRPCWallet(rpcURL, accountName); } - return new VerumcoindRPCWallet(rpcURL, label); + return new VerumcoindRPCWallet(rpcURL, accountName); } } } @@ -118,4 +121,12 @@ public Set getSupportedCryptoCurrencies() { result.add(CryptoCurrency.VERUM.getCode()); return result; } + + @Override + public Set getCryptoCurrencyDefinitions() { + Set result = new HashSet<>(); + result.add(DEFINITION); + return result; + } + } diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinPaymentSupport.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinPaymentSupport.java new file mode 100644 index 000000000..1a23be154 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/VerumcoinPaymentSupport.java @@ -0,0 +1,92 @@ +/************************************************************************************* + * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.verumcoin; + +import com.generalbytes.batm.common.currencies.CryptoCurrency; +import com.generalbytes.batm.server.extensions.ICryptoAddressValidator; +import com.generalbytes.batm.server.extensions.extra.common.AbstractRPCPaymentSupport; +import com.generalbytes.batm.server.extensions.extra.common.RPCClient; +import com.generalbytes.batm.server.extensions.payment.PaymentRequest; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VerumcoinPaymentSupport extends AbstractRPCPaymentSupport { + private static final Logger log = LoggerFactory.getLogger(VerumcoinPaymentSupport.class); + + private VerumcoinAddressValidator addressValidator = new VerumcoinAddressValidator(); + + private static final long MAXIMUM_WAIT_FOR_POSSIBLE_REFUND_MILLIS = TimeUnit.DAYS.toMillis(3); // 3 days + private static final long MAXIMUM_WATCHING_TIME_MILLIS = TimeUnit.DAYS.toMillis(3); // 3 days (exactly plus Sell Offer Expiration 5-120 minutes) + + @Override + public String getCurrency() { + return CryptoCurrency.VERUM.getCode(); + } + + @Override + public long getMaximumWatchingTimeMillis() { + return MAXIMUM_WATCHING_TIME_MILLIS; + } + + @Override + public long getMaximumWaitForPossibleRefundInMillis() { + return MAXIMUM_WAIT_FOR_POSSIBLE_REFUND_MILLIS; + } + + @Override + public BigDecimal getMinimumNetworkFee(RPCClient client) { + return client.getNetworkInfo().relayFee(); + } + + @Override + public ICryptoAddressValidator getAddressValidator() { + return addressValidator; + } + + @Override + public int calculateTransactionSize(int numberOfInputs, int numberOfOutputs) { + return (numberOfInputs * 149) + (numberOfOutputs * 34) + 10; + } + + @Override + public BigDecimal calculateTxFee(int numberOfInputs, int numberOfOutputs, RPCClient client) { + final int transactionSize = calculateTransactionSize(numberOfInputs, numberOfOutputs); + try { + BigDecimal estimate = new BigDecimal(client.getEstimateFee()); + if (BigDecimal.ZERO.compareTo(estimate) == 0 || estimate.compareTo(new BigDecimal("-1")) == 0 ) { + //bitcoind is clueless + return getMinimumNetworkFee(client); + } + return estimate.divide(new BigDecimal("1000"), RoundingMode.UP).multiply(new BigDecimal(transactionSize)); + } catch (Exception e) { + log.error("CUSTOM VERUM LOG", e); + return getMinimumNetworkFee(client); + } + } + + @Override + public String getSigHashType() { + return "ALL"; + } + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/MapWrapper.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/MapWrapper.java new file mode 100644 index 000000000..6608379aa --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/MapWrapper.java @@ -0,0 +1,102 @@ +/* + * Bitcoin-JSON-RPC-Client License + * + * Copyright (c) 2013, Mikhail Yevchenko. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the + * Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH + * THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.generalbytes.batm.server.extensions.extra.verumcoin.wallets; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.Map; + +import wf.bitcoin.krotjson.HexCoder; + +class MapWrapper { + + public final Map m; + + public MapWrapper(Map m) { + this.m = m; + } + + public Boolean mapBool(String key) { + return mapBool(m, key); + } + + public Integer mapInt(String key) { + return mapInt(m, key); + } + + public Long mapLong(String key) { + return mapLong(m, key); + } + + public String mapStr(String key) { + return mapStr(m, key); + } + + public Date mapCTime(String key) { + return mapCTime(m, key); + } + + public BigDecimal mapBigDecimal(String key) { + return mapBigDecimal(m, key); + } + + public byte[] mapHex(String key) { + return mapHex(m, key); + } + + public static Boolean mapBool(Map m, String key) { + Object val = m.get(key); + return val instanceof Boolean ? (Boolean) val : Boolean.FALSE; + } + + public static BigDecimal mapBigDecimal(Map m, String key) { + Object val = m.get(key); + return val instanceof BigDecimal ? (BigDecimal) val : new BigDecimal((String) val); + } + + public static Integer mapInt(Map m, String key) { + Object val = m.get(key); + return val instanceof Number ? ((Number) val).intValue() : null; + } + + public static Long mapLong(Map m, String key) { + Object val = m.get(key); + return val instanceof Number ? ((Number) val).longValue() : null; + } + + public static String mapStr(Map m, String key) { + Object v = m.get(key); + return v == null ? null : String.valueOf(v); + } + + public static Date mapCTime(Map m, String key) { + Object v = m.get(key); + return v == null ? null : new Date(mapLong(m, key) * 1000); + } + + public static byte[] mapHex(Map m, String key) { + Object v = m.get(key); + return v == null ? null : HexCoder.decode((String) v); + } + + @Override + public String toString() { + return String.valueOf(m); + } + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/VerumcoinTransaction.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/VerumcoinTransaction.java new file mode 100644 index 000000000..52dfae8a0 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/VerumcoinTransaction.java @@ -0,0 +1,25 @@ +/************************************************************************************* + * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.verumcoin.wallets; + +import wf.bitcoin.javabitcoindrpcclient.BitcoindRpcClient.Transaction; + +public interface VerumcoinTransaction extends Transaction { + boolean instantlock(); + boolean instantlock_internal(); +} \ No newline at end of file diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/VerumcoindRPCClient.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/VerumcoindRPCClient.java new file mode 100644 index 000000000..390601aa0 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/VerumcoindRPCClient.java @@ -0,0 +1,178 @@ +/************************************************************************************* + * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.verumcoin.wallets; + +import java.net.MalformedURLException; +import java.util.Map; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +import wf.bitcoin.javabitcoindrpcclient.BitcoinRPCException; +import wf.bitcoin.javabitcoindrpcclient.GenericRpcException; +import java.util.logging.Logger; + +import com.generalbytes.batm.common.currencies.CryptoCurrency; +import com.generalbytes.batm.server.extensions.extra.common.RPCClient; + +public class VerumcoindRPCClient extends RPCClient { + + private static final Logger logger = Logger.getLogger(VerumcoindRPCClient.class.getCanonicalName()); + + + public VerumcoindRPCClient(String rpcUrl) throws MalformedURLException { + super(CryptoCurrency.VERUM.getCode(), rpcUrl); + } + + @Override + public Transaction getTransaction(String txId) { + return new VerumcoinTransactionWrapper((Map) query("gettransaction", txId)); + } + + @Override + public double getEstimateFee(int numberOfBlocks) throws BitcoinRPCException { + Map result = (Map) query("estimatesmartfee", numberOfBlocks); + Object estimate = result.get("feerate"); + if (estimate == null) { + throw new GenericRpcException("getEstimateFee - no result: " + result.toString()); + } + return ((Number)estimate).doubleValue(); + } + + @Override + public String signRawTransactionWithWallet(String hex, String sigHashType) { + Map result = (Map) query("signrawtransaction", hex, null, null, sigHashType); //if sigHashType is null it will return the default "ALL" + if ((Boolean) result.get("complete")) + return (String) result.get("hex"); + else + throw new GenericRpcException("Incomplete"); + } + + + @SuppressWarnings("serial") + class VerumcoinTransactionWrapper extends MapWrapper implements VerumcoinTransaction, Serializable { + + @SuppressWarnings("rawtypes") + public VerumcoinTransactionWrapper(Map m) { + super(m); + } + + @Override + public String account() { + return mapStr(m, "account"); + } + + @Override + public String address() { + return mapStr(m, "address"); + } + + @Override + public String category() { + return mapStr(m, "category"); + } + + @Override + public BigDecimal amount() { + return mapBigDecimal(m, "amount"); + } + + @Override + public BigDecimal fee() { + return mapBigDecimal(m, "fee"); + } + + @Override + public int confirmations() { + return mapInt(m, "confirmations"); + } + + @Override + public String blockHash() { + return mapStr(m, "blockhash"); + } + + @Override + public int blockIndex() { + return mapInt(m, "blockindex"); + } + + @Override + public Date blockTime() { + return mapCTime(m, "blocktime"); + } + + @Override + public String txId() { + return mapStr(m, "txid"); + } + + @Override + public Date time() { + return mapCTime(m, "time"); + } + + @Override + public Date timeReceived() { + return mapCTime(m, "timereceived"); + } + + @Override + public String comment() { + return mapStr(m, "comment"); + } + + @Override + public String commentTo() { + return mapStr(m, "to"); + } + + @Override + public boolean generated() { + return mapBool(m, "generated"); + } + + @Override + public boolean instantlock() { + return mapBool(m, "instantlock"); + } + + @Override + public boolean instantlock_internal() { + return mapBool(m, "instantlock_internal"); + } + + private RawTransaction raw = null; + + @Override + public RawTransaction raw() { + if (raw == null) + try { + raw = getRawTransaction(txId()); + } catch (GenericRpcException ex) { + logger.warning(ex.getMessage()); + } + return raw; + } + + @Override + public String toString() { + return m.toString(); + } + } +} \ No newline at end of file diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindRPCWallet.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindRPCWallet.java index a6f109fe1..da4ad17ab 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindRPCWallet.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindRPCWallet.java @@ -17,11 +17,124 @@ ************************************************************************************/ package com.generalbytes.batm.server.extensions.extra.verumcoin.wallets.verumcoind; +import wf.bitcoin.javabitcoindrpcclient.BitcoinRPCException; import com.generalbytes.batm.common.currencies.CryptoCurrency; -import com.generalbytes.batm.server.extensions.extra.common.RPCWallet; +import com.generalbytes.batm.server.extensions.IWallet; +import com.generalbytes.batm.server.extensions.extra.common.IRPCWallet; +import com.generalbytes.batm.server.extensions.extra.common.RPCClient; +import com.generalbytes.batm.server.extensions.extra.verumcoin.wallets.VerumcoindRPCClient; -public class VerumcoindRPCWallet extends RPCWallet { - public VerumcoindRPCWallet(String rpcURL, String label) { - super(rpcURL, label, CryptoCurrency.VERUM.getCode()); +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigDecimal; +import java.net.MalformedURLException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class VerumcoindRPCWallet implements IWallet, IRPCWallet { + private static final Logger log = LoggerFactory.getLogger(VerumcoindRPCWallet.class); + private static final String CRYPTO_CURRENCY = CryptoCurrency.VERUM.getCode(); + + public VerumcoindRPCWallet(String rpcURL, String accountName) throws MalformedURLException { + this.rpcURL = rpcURL; + this.accountName = accountName; + } + + private String rpcURL; + private String accountName; + + @Override + public Set getCryptoCurrencies() { + Set result = new HashSet(); + result.add(CRYPTO_CURRENCY); + return result; + + } + + @Override + public String getPreferredCryptoCurrency() { + return CRYPTO_CURRENCY; + } + + @Override + public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) { + if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { + log.error("Verumcoind wallet error: unknown cryptocurrency."); + return null; + } + + log.info("Verumcoind sending coins from " + accountName + " to: " + destinationAddress + " " + amount); + try { + String result = getClient(rpcURL).sendToAddress(destinationAddress, amount); + log.debug("result = " + result); + return result; + } catch (BitcoinRPCException e) { + log.error("Error", e); + return null; + } + } + + @Override + public String getCryptoAddress(String cryptoCurrency) { + if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { + log.error("Verumcoind wallet error: unknown cryptocurrency."); + return null; + } + + try { + String address = getClient(rpcURL).getNewAddress(); + if (address == null) { + return null; + } else { + return address; + } + } catch (BitcoinRPCException e) { + log.error("Error", e); + return null; + } + } + + public String generateNewDepositCryptoAddress(String cryptoCurrency, String label) { + if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { + log.error("Verumcoind wallet error: unknown cryptocurrency."); + return null; + } + + try { + return getClient(rpcURL).getNewAddress(); + } catch (BitcoinRPCException e) { + log.error("Error", e); + return null; + } + } + + @Override + public BigDecimal getCryptoBalance(String cryptoCurrency) { + if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) { + log.error("Verumcoind wallet error: unknown cryptocurrency: " + cryptoCurrency); + return null; + } + try { + return getClient(rpcURL).getBalance(accountName); + } catch (BitcoinRPCException e) { + log.error("Error", e); + return null; + } + } + + private VerumcoindRPCClient getClient(String rpcURL) { + try { + return new VerumcoindRPCClient(rpcURL); + } catch (MalformedURLException e) { + log.error("Error", e); + } + return null; + } + + @Override + public RPCClient getClient() { + return getClient(rpcURL); } } diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindUniqueAddressRPCWallet.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindUniqueAddressRPCWallet.java index c6e590851..2335c6cc0 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindUniqueAddressRPCWallet.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/verumcoin/wallets/verumcoind/VerumcoindUniqueAddressRPCWallet.java @@ -17,10 +17,12 @@ ************************************************************************************/ package com.generalbytes.batm.server.extensions.extra.verumcoin.wallets.verumcoind; +import java.net.MalformedURLException; + import com.generalbytes.batm.server.extensions.IGeneratesNewDepositCryptoAddress; public class VerumcoindUniqueAddressRPCWallet extends VerumcoindRPCWallet implements IGeneratesNewDepositCryptoAddress { - public VerumcoindUniqueAddressRPCWallet(String rpcURL) { - super(rpcURL, ""); // label is used only for reusing the same address + public VerumcoindUniqueAddressRPCWallet(String rpcURL, String accountName) throws MalformedURLException { + super(rpcURL, accountName); } } diff --git a/server_extensions_extra/src/main/resources/batm-extensions.xml b/server_extensions_extra/src/main/resources/batm-extensions.xml index 3ecf57544..2d664897b 100644 --- a/server_extensions_extra/src/main/resources/batm-extensions.xml +++ b/server_extensions_extra/src/main/resources/batm-extensions.xml @@ -233,6 +233,7 @@ HT ZPAE NANO + VERUM HBX @@ -614,6 +615,7 @@ USDS USDT USDTTRON + VERUM VIA VOLTZ WDC @@ -683,6 +685,7 @@ TRX USDT USDTTRON + VERUM VIA VOLTZ WDC