diff --git a/gradle.properties b/gradle.properties index 8568b7b6b..ffbfa9a9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # buildscript - project id projectGroup=com.generalbytes.batm.public -projectVersion=1.4.4 +projectVersion=1.4.5 # buildscript - common dependency versions bitrafaelVersion=1.0.44 diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionPreparation.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionPreparation.java index 92424eaa2..9e50c7f05 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionPreparation.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionPreparation.java @@ -18,7 +18,7 @@ package com.generalbytes.batm.server.extensions; -import com.generalbytes.batm.server.extensions.quiz.QuizResult; +import com.generalbytes.batm.server.extensions.questionnaire.QuestionnaireResult; import java.math.BigDecimal; import java.util.Date; @@ -205,10 +205,10 @@ public interface ITransactionPreparation { void setWithdrawalReason(int reason); /** - * Returns quiz results if any quiz has been activated. + * Returns questionnaire results if any questionnaire has been activated. * - * @return List of {@link QuizResult}. Can be null. + * @return List of {@link QuestionnaireResult}. Can be null. */ - List getQuizResults(); + List getQuestionnaireResults(); } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionRequest.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionRequest.java index 9382eaf7e..09ef2c38e 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionRequest.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionRequest.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2024 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 @@ -17,7 +17,7 @@ ************************************************************************************/ package com.generalbytes.batm.server.extensions; -import com.generalbytes.batm.server.extensions.quiz.QuizResult; +import com.generalbytes.batm.server.extensions.questionnaire.QuestionnaireResult; import java.math.BigDecimal; import java.util.Date; @@ -160,11 +160,11 @@ public interface ITransactionRequest { BigDecimal getDiscountQuotient(); /** - * Returns quiz results if any quiz has been activated. + * Returns questionnaire results if any questionnaire has been activated. * - * @return List of {@link QuizResult}. Can be null. + * @return List of {@link QuestionnaireResult}. Can be null. */ - List getQuizResults(); + List getQuestionnaireResults(); /** * Error message displayed to the customer. diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/quiz/QuestionAnswer.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/questionnaire/QuestionAnswer.java similarity index 96% rename from server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/quiz/QuestionAnswer.java rename to server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/questionnaire/QuestionAnswer.java index d80f8236b..3a93e78cc 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/quiz/QuestionAnswer.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/questionnaire/QuestionAnswer.java @@ -15,13 +15,13 @@ * Web : http://www.generalbytes.com * ************************************************************************************/ -package com.generalbytes.batm.server.extensions.quiz; +package com.generalbytes.batm.server.extensions.questionnaire; import com.generalbytes.batm.server.extensions.customfields.CustomFieldDefinition; import com.generalbytes.batm.server.extensions.customfields.CustomFieldDefinitionType; /** - * An object representing the question and answer data in the {@link QuizResult}. + * An object representing the question and answer data in the {@link QuestionnaireResult}. */ public class QuestionAnswer { diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/quiz/QuizResult.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/questionnaire/QuestionnaireResult.java similarity index 62% rename from server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/quiz/QuizResult.java rename to server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/questionnaire/QuestionnaireResult.java index 623e6c913..07f52f7ee 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/quiz/QuizResult.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/questionnaire/QuestionnaireResult.java @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2024 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 @@ -15,34 +15,34 @@ * Web : http://www.generalbytes.com * ************************************************************************************/ -package com.generalbytes.batm.server.extensions.quiz; +package com.generalbytes.batm.server.extensions.questionnaire; import java.util.List; /** - * An object representing data about quiz result. + * An object representing data about questionnaire result. */ -public class QuizResult { +public class QuestionnaireResult { - private String quizName; + private String questionnaireName; private List answers; - public QuizResult() { + public QuestionnaireResult() { } - public QuizResult(String quizName, List answers) { - this.quizName = quizName; + public QuestionnaireResult(String questionnaireName, List answers) { + this.questionnaireName = questionnaireName; this.answers = answers; } - public String getQuizName() { - return quizName; + public String getQuestionnaireName() { + return questionnaireName; } - public void setQuizName(String quizName) { - this.quizName = quizName; + public void setQuestionnaireName(String questionnaireName) { + this.questionnaireName = questionnaireName; } public List getAnswers() { 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 1e0096efc..e31130f10 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-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2024 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 @@ -291,9 +291,11 @@ public IWallet createWallet(String walletLogin, String tunnelPassword) { String proxyUrl = st.nextToken("\n").replaceFirst(":", ""); return new BitcoreWallet(apiKey, proxyUrl); } else if ("bitgo".equalsIgnoreCase(walletType) || "bitgonoforward".equalsIgnoreCase(walletType)) { - // bitgo:host:port:token:wallet_address:wallet_passphrase:num_blocks + // bitgo:host:port:token:wallet_address:wallet_passphrase:num_blocks:fee_rate:max_fee_rate // but host is optionally including the "http://" and port is optional, - // num_blocks is an optional integer greater than 2 and it's used to calculate mining fee. + // num_blocks is an optional integer greater than 2 and it's used to calculate mining fee, + // fee_rate is an optional integer defined fee rate, + // max_fee_rate is an optional integer defined maximum fee rate. // bitgo:http://localhost:80:token:wallet_address:wallet_passphrase // bitgo:http://localhost:token:wallet_address:wallet_passphrase // bitgo:localhost:token:wallet_address:wallet_passphrase @@ -328,22 +330,22 @@ public IWallet createWallet(String walletLogin, String tunnelPassword) { host = tunnelAddress.getHostString(); port = tunnelAddress.getPort(); - String blocks; - int num; - Integer numBlocks = 2; - if(st.hasMoreTokens()){ - blocks = st.nextToken(); - num = Integer.parseInt(blocks); - if(num > 2) { - numBlocks = num; - } + int numBlocks = 2; + if (st.hasMoreTokens()) { + int number = Integer.parseInt(st.nextToken()); + if (number > 2) { + numBlocks = number; + } } + Integer feeRate = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : null; + Integer maxFeeRate = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : null; + if ("bitgonoforward".equalsIgnoreCase(walletType)) { - return new BitgoWalletWithUniqueAddresses(scheme, host, port, token, walletId, walletPassphrase, numBlocks); + return new BitgoWalletWithUniqueAddresses(scheme, host, port, token, walletId, walletPassphrase, numBlocks, feeRate, maxFeeRate); } - return new BitgoWallet(scheme, host, port, token, walletId, walletPassphrase, numBlocks); + return new BitgoWallet(scheme, host, port, token, walletId, walletPassphrase, numBlocks, feeRate, maxFeeRate); } else if ("coinbasewallet2".equalsIgnoreCase(walletType) || "coinbasewallet2noforward".equalsIgnoreCase(walletType)) { 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 e7a6c585b..d33a42ded 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-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2024 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 @@ -57,6 +57,8 @@ public class BitgoWallet implements IWallet, ICanSendMany { protected String url; protected static final Integer readTimeout = 90 * 1000; //90 seconds protected Integer numBlocks; + protected Integer feeRate; + protected Integer maxFeeRate; protected static final Map cryptoCurrencies = new HashMap() { { @@ -93,10 +95,16 @@ private int pow10Exp(BigDecimal val) { }; public BitgoWallet(String scheme, String host, int port, String token, String walletId, String walletPassphrase, Integer numBlocks) { + this(scheme, host, port, token, walletId, walletPassphrase, numBlocks, null, null); + } + + public BitgoWallet(String scheme, String host, int port, String token, String walletId, String walletPassphrase, Integer numBlocks, Integer feeRate, Integer maxFeeRate) { this.walletId = walletId; this.walletPassphrase = walletPassphrase; this.url = new HttpUrl.Builder().scheme(scheme).host(host).port(port).build().toString(); this.numBlocks = numBlocks; + this.feeRate = feeRate; + this.maxFeeRate = maxFeeRate; ClientConfig config = new ClientConfig(); config.setHttpReadTimeout(readTimeout); @@ -146,7 +154,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); + final BitGoCoinRequest request = new BitGoCoinRequest(destinationAddress, toSatoshis(amount, cryptoCurrency), walletPassphrase, description, this.numBlocks, this.feeRate, this.maxFeeRate); String bitgoCryptoCurrency = cryptoCurrencies.get(cryptoCurrency); return getResultTxId(api.sendCoins(bitgoCryptoCurrency, this.walletId, request)); } catch (HttpStatusIOException hse) { @@ -172,7 +180,7 @@ private Integer getDecimals(String cryptoCurrency) { @Override public String getCryptoAddress(String cryptoCurrency) { - if(cryptoCurrency == null) { + if (cryptoCurrency == null) { cryptoCurrency = getPreferredCryptoCurrency(); } String bitgoCryptoCurrency = cryptoCurrencies.get(cryptoCurrency); @@ -181,18 +189,18 @@ public String getCryptoAddress(String cryptoCurrency) { } try { final Map response = api.getWalletById(bitgoCryptoCurrency, walletId); - if(response == null || response.isEmpty()) { + if (response == null || response.isEmpty()) { return null; } Object receiveAddressObj = response.get("receiveAddress"); - if(receiveAddressObj == null || !(receiveAddressObj instanceof Map)) { + if (!(receiveAddressObj instanceof Map)) { return null; } Map receiveAddressMap = (Map)receiveAddressObj; Object addressObj = receiveAddressMap.get("address"); - if(addressObj == null || !(addressObj instanceof String)) { + if (!(addressObj instanceof String)) { return null; } return (String)addressObj; 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 f2328b1d3..213f7dffa 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-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2024 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 @@ -46,6 +46,10 @@ public BitgoWalletWithUniqueAddresses(String scheme, String host, int port, Stri super(scheme, host, port, token, walletId, walletPassphrase, numBlocks); } + public BitgoWalletWithUniqueAddresses(String scheme, String host, int port, String token, String walletId, String walletPassphrase, Integer numBlocks, Integer feeRate, Integer maxFeeRate) { + super(scheme, host, port, token, walletId, walletPassphrase, numBlocks, feeRate, maxFeeRate); + } + @Override public String generateNewDepositCryptoAddress(String cryptoCurrency, String label) { if (cryptoCurrency == null) { 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 aa3e9a60c..3f9ad4b85 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-2020 GENERAL BYTES s.r.o. All rights reserved. + * Copyright (C) 2014-2024 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 @@ -23,6 +23,8 @@ public class BitGoCoinRequest { private String walletPassphrase; private Integer numBlocks; private String comment; + private Integer feeRate; + private Integer maxFeeRate; public BitGoCoinRequest(String address, String amount, String walletPassphrase, String comment, Integer numBlocks) { @@ -33,6 +35,13 @@ 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) { + this(address, amount, walletPassphrase, comment, numBlocks); + + this.feeRate = feeRate; + this.maxFeeRate = maxFeeRate; + } + public String getAddress() { return address; } @@ -72,4 +81,20 @@ public String getComment() { public void setComment(String comment){ this.comment = comment; } + + public Integer getFeeRate() { + return feeRate; + } + + public void setFeeRate(Integer feeRate) { + this.feeRate = feeRate; + } + + public Integer getMaxFeeRate() { + return maxFeeRate; + } + + public void setMaxFeeRate(Integer maxFeeRate) { + this.maxFeeRate = maxFeeRate; + } } diff --git a/server_extensions_extra/src/main/resources/batm-extensions.xml b/server_extensions_extra/src/main/resources/batm-extensions.xml index 1ab29a93a..e97882634 100644 --- a/server_extensions_extra/src/main/resources/batm-extensions.xml +++ b/server_extensions_extra/src/main/resources/batm-extensions.xml @@ -37,6 +37,8 @@ + + BCH BTC LTC @@ -54,6 +56,8 @@ + + BCH BTC LTC