diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/Converters.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/Converters.java index 7e70fa49b..278b080a4 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/Converters.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/Converters.java @@ -32,6 +32,7 @@ public class Converters { public static final BigDecimal XRP = BigDecimal.TEN.pow(6); public static final BigDecimal VERUM = BigDecimal.TEN.pow(8); public static final BigDecimal TRX = BigDecimal.TEN.pow(6); + public static final BigDecimal USDC = BigDecimal.TEN.pow(6); public static final BigDecimal TBCH = BigDecimal.TEN.pow(8); public static final BigDecimal TBTC = BigDecimal.TEN.pow(8); diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java index ce2410314..a231e5f97 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2024 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 @@ -56,7 +56,9 @@ import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.coinbase.v2.CoinbaseWalletV2WithUniqueAddresses; import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.cryptx.v2.CryptXWallet; import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.cryptx.v2.CryptXWithUniqueAddresses; +import com.generalbytes.batm.server.extensions.extra.ethereum.UsdcDefinition; import com.generalbytes.batm.server.extensions.watchlist.IWatchList; +import com.google.common.collect.ImmutableSet; import java.math.BigDecimal; import java.net.InetSocketAddress; @@ -613,7 +615,7 @@ public IRateSource createRateSource(String sourceLogin) { @Override public Set getSupportedCryptoCurrencies() { - Set result = new HashSet(); + Set result = new HashSet<>(); result.add(CryptoCurrency.BTC.getCode()); result.add(CryptoCurrency.ETH.getCode()); result.add(CryptoCurrency.LTC.getCode()); @@ -621,6 +623,7 @@ public Set getSupportedCryptoCurrencies() { result.add(CryptoCurrency.EGLD.getCode()); result.add(CryptoCurrency.USDTTRON.getCode()); result.add(CryptoCurrency.BNB.getCode()); + result.add(CryptoCurrency.USDC.getCode()); return result; } @@ -636,6 +639,6 @@ public IWatchList getWatchList(String name) { @Override public Set getCryptoCurrencyDefinitions() { - return null; + return ImmutableSet.of(new UsdcDefinition()); } } diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWallet.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWallet.java index 4d4d8a98e..4e2e75221 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWallet.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWallet.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2024 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 @@ -70,6 +70,7 @@ public class BitgoWallet implements IWallet, ICanSendMany { put(CryptoCurrency.USDTTRON.getCode(), "trx:usdt"); put(CryptoCurrency.XRP.getCode(), "xrp"); put(CryptoCurrency.TBTC.getCode(), "tbtc"); + put(CryptoCurrency.USDC.getCode(), "usdc"); } }; @@ -85,6 +86,7 @@ public class BitgoWallet implements IWallet, ICanSendMany { put(CryptoCurrency.TBTC.getCode(), pow10Exp(Converters.TBTC)); put(CryptoCurrency.TLTC.getCode(), pow10Exp(Converters.TLTC)); put(CryptoCurrency.TBCH.getCode(), pow10Exp(Converters.TBCH)); + put(CryptoCurrency.USDC.getCode(), pow10Exp(Converters.USDC)); } private int pow10Exp(BigDecimal val) { @@ -138,7 +140,7 @@ public String sendMany(Collection transfers, String cryptoCurrency, St List recipients = transfers.stream() .map(transfer -> new BitGoRecipient(transfer.getDestinationAddress(), toSatoshis(transfer.getAmount(), cryptoCurrency))) .collect(Collectors.toList()); - final BitGoSendManyRequest request = new BitGoSendManyRequest(recipients, walletPassphrase, description, this.numBlocks); + final BitGoSendManyRequest request = createBitGoSendManyRequest(recipients, cryptoCurrency, description); String bitgoCryptoCurrency = cryptoCurrencies.get(cryptoCurrency); return getResultTxId(api.sendMany(bitgoCryptoCurrency, this.walletId, request)); } catch (HttpStatusIOException hse) { @@ -154,7 +156,7 @@ public String sendMany(Collection transfers, String cryptoCurrency, St @Override public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) { try { - final BitGoCoinRequest request = new BitGoCoinRequest(destinationAddress, toSatoshis(amount, cryptoCurrency), walletPassphrase, description, this.numBlocks, this.feeRate, this.maxFeeRate); + final BitGoCoinRequest request = createBitGoCoinRequest(destinationAddress, amount, cryptoCurrency, description); String bitgoCryptoCurrency = cryptoCurrencies.get(cryptoCurrency); return getResultTxId(api.sendCoins(bitgoCryptoCurrency, this.walletId, request)); } catch (HttpStatusIOException hse) { @@ -167,6 +169,43 @@ public String sendCoins(String destinationAddress, BigDecimal amount, String cry return null; } + private BitGoSendManyRequest createBitGoSendManyRequest(List recipients, String cryptoCurrency, String description) { + if (CryptoCurrency.USDC.getCode().equalsIgnoreCase(cryptoCurrency)) { + return new BitGoSendManyRequest(recipients, this.walletPassphrase, description, this.numBlocks, "transfer"); + } + + return new BitGoSendManyRequest(recipients, this.walletPassphrase, description, this.numBlocks); + } + + private BitGoCoinRequest createBitGoCoinRequest(String destinationAddress, + BigDecimal amount, + String cryptoCurrency, + String description + ) { + if (CryptoCurrency.USDC.getCode().equalsIgnoreCase(cryptoCurrency)) { + return new BitGoCoinRequest( + destinationAddress, + toSatoshis(amount, cryptoCurrency), + this.walletPassphrase, + description, + this.numBlocks, + this.feeRate, + this.maxFeeRate, + "transfer" + ); + } + + return new BitGoCoinRequest( + destinationAddress, + toSatoshis(amount, cryptoCurrency), + this.walletPassphrase, + description, + this.numBlocks, + this.feeRate, + this.maxFeeRate + ); + } + protected String toSatoshis(BigDecimal amount, String cryptoCurrency) { return amount .movePointRight(getDecimals(cryptoCurrency)) diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWalletWithUniqueAddresses.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWalletWithUniqueAddresses.java index e754f827b..950684904 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWalletWithUniqueAddresses.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/BitgoWalletWithUniqueAddresses.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2024 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 @@ -45,6 +45,7 @@ public class BitgoWalletWithUniqueAddresses extends BitgoWallet implements IGene { put(CryptoCurrency.USDT.getCode(), "eth"); put(CryptoCurrency.USDTTRON.getCode(), "trx"); + put(CryptoCurrency.USDC.getCode(), "eth"); } }; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/IBitgoAPI.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/IBitgoAPI.java index 0721d2df4..17a756bce 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/IBitgoAPI.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/IBitgoAPI.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoCoinRequest.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoCoinRequest.java index d08b64693..dde6f1708 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoCoinRequest.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoCoinRequest.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2024 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 @@ -28,6 +28,7 @@ public class BitGoCoinRequest { private String comment; private Integer feeRate; private Integer maxFeeRate; + private String type; public BitGoCoinRequest(String address, String amount, String walletPassphrase, String comment, Integer numBlocks) { @@ -38,13 +39,34 @@ public BitGoCoinRequest(String address, String amount, String walletPassphrase, this.comment = comment; } - public BitGoCoinRequest(String address, String amount, String walletPassphrase, String comment, Integer numBlocks, Integer feeRate, Integer maxFeeRate) { + public BitGoCoinRequest(String address, + String amount, + String walletPassphrase, + String comment, + Integer numBlocks, + Integer feeRate, + Integer maxFeeRate + ) { this(address, amount, walletPassphrase, comment, numBlocks); this.feeRate = feeRate; this.maxFeeRate = maxFeeRate; } + public BitGoCoinRequest(String address, + String amount, + String walletPassphrase, + String comment, + Integer numBlocks, + Integer feeRate, + Integer maxFeeRate, + String type + ) { + this(address, amount, walletPassphrase, comment, numBlocks, feeRate, maxFeeRate); + + this.type = type; + } + public String getAddress() { return address; } @@ -100,4 +122,12 @@ public Integer getMaxFeeRate() { public void setMaxFeeRate(Integer maxFeeRate) { this.maxFeeRate = maxFeeRate; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoSendManyRequest.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoSendManyRequest.java index 5ece9607f..3494822b9 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoSendManyRequest.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/wallets/bitgo/v2/dto/BitGoSendManyRequest.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2019 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 @@ -24,6 +24,7 @@ public class BitGoSendManyRequest { public String walletPassphrase; public Integer numBlocks; public String comment; + public String type; public BitGoSendManyRequest(List recipients, String walletPassphrase, String comment){ this(recipients, walletPassphrase, comment, 2); @@ -36,6 +37,12 @@ public BitGoSendManyRequest(List recipients, String walletPassph this.comment = comment; } + public BitGoSendManyRequest(List recipients, String walletPassphrase, String comment, Integer numBlocks, String type) { + this(recipients, walletPassphrase, comment, numBlocks); + + this.type = type; + } + public static class BitGoRecipient { public String address; public String amount; // in satoshis diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcDefinition.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcDefinition.java index 6d3e77a81..80d185899 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcDefinition.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcDefinition.java @@ -1,10 +1,27 @@ +/************************************************************************************* + * Copyright (C) 2014-2025 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.ethereum; import com.generalbytes.batm.common.currencies.CryptoCurrency; import com.generalbytes.batm.server.extensions.CryptoCurrencyDefinition; import com.generalbytes.batm.server.extensions.payment.IPaymentSupport; -public class UsdcDefinition extends CryptoCurrencyDefinition{ +public class UsdcDefinition extends CryptoCurrencyDefinition { private final IPaymentSupport paymentSupport = new UsdcPaymentSupport(); public UsdcDefinition() { diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcPaymentSupport.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcPaymentSupport.java index fdb4af443..8a019aab5 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcPaymentSupport.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/ethereum/UsdcPaymentSupport.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2025 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 diff --git a/server_extensions_extra/src/main/resources/batm-extensions.xml b/server_extensions_extra/src/main/resources/batm-extensions.xml index 3ecf57544..a63cea567 100644 --- a/server_extensions_extra/src/main/resources/batm-extensions.xml +++ b/server_extensions_extra/src/main/resources/batm-extensions.xml @@ -45,6 +45,7 @@ ETH XRP USDT + USDC Host should start with http:// or https://. num_blocks is an integer greater than 2. @@ -65,6 +66,7 @@ XRP USDT USDTTRON + USDC This variant of the wallet generates new addresses for each sell transaction and does not forward payments from temporary address. Host should start with http:// or https://. num_blocks is an integer greater than 2.