Skip to content

Commit

Permalink
Merge branch 'master' into 0110sync1.3.0toMaster
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
Filip Ocelka committed Jan 10, 2024
2 parents c7ae4d8 + d638fa4 commit 94e20c4
Show file tree
Hide file tree
Showing 32 changed files with 1,134 additions and 5 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Requirements:
* Java **1.8** (we recommend using https://sdkman.io/ for managing multiple JDK versions on your computer)
* Gradle

When you implement support for a new crypto-coin, please add it to **server_extensions_extra** - so that it may get into the default CAS installation pack for customers.
When you implement support for a new crypto-coin, please add it to **server_extensions_extra** - so that it may get into the default CAS distribution ready to be used by other operators.
Please use the appropriate Fork and Pull Request in the GitHub workflow when adding new functions, and bear in mind that your code will be reviewed prior to any merge with the master.

When adding new cryptocurrency support, please remember to provide its logo! This logo will later be downloaded by the BATM from CAS and displayed on the BATM screen. Both SVG and PNG logos are supported; however, only the SVG logo is used on newer BATM versions. A PNG logo is offered only for backward compatibility, and in the few cases where the SVG logo has an unusually large size.
Expand All @@ -88,6 +88,16 @@ Note that on startup, CAS scans the: <code>/batm/app/master/extensions/</code> f

If you happen to add new cryptocurrency in CryptoCurrency class in currencies module then don't forget to make sure that you copy your version of currencies-1.0.XX-SNAPSHOT.jar to /batm/app/master/lib

Creating your own extension
=================
When you want to develop your own operator specific extension please create a new module and implement your extension there.
Use server_extensions_template module as a termplate for your first extension. Just copy this module and rename it.
You will need to modify also settings.gradle file to contain your new extension module's name. See how is the server_extensions_template module mentioned and add line for your new extension module.
After building the whole project your built extension shoud be in following file: <code>yournewextension/build/libs/yournewextension.jar</code>
Copy it to CAS server at following location: <code>/batm/app/master/extensions/</code>
You may also want to modify build.gradle in your new module to change at least package names and final output filename.


How to run Tester
==========
```bash
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# buildscript - project id
projectGroup=com.generalbytes.batm.public
projectVersion=1.3.5
projectVersion=1.4.1

# buildscript - common dependency versions
bitrafaelVersion=1.0.44
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.generalbytes.batm.server.extensions.aml.verification.IIdentityVerificationProvider;
import com.generalbytes.batm.server.extensions.communication.ICommunicationProvider;
import com.generalbytes.batm.server.extensions.communication.IPhoneLookupProvider;
import com.generalbytes.batm.server.extensions.communication.voicecall.IVoiceCallProvider;
import com.generalbytes.batm.server.extensions.watchlist.IWatchList;

import java.util.Set;
Expand Down Expand Up @@ -127,6 +128,9 @@ public Set<ICommunicationProvider> getCommunicationProviders() {
return null;
}

@Override
public Set<IVoiceCallProvider> getVoiceCallProviders() { return null; }

@Override
public Set<ISsnValidator> getSsnValidators() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.generalbytes.batm.server.extensions.aml.verification.IIdentityVerificationProvider;
import com.generalbytes.batm.server.extensions.communication.ICommunicationProvider;
import com.generalbytes.batm.server.extensions.communication.IPhoneLookupProvider;
import com.generalbytes.batm.server.extensions.communication.voicecall.IVoiceCallProvider;
import com.generalbytes.batm.server.extensions.watchlist.IWatchList;

import java.util.Set;
Expand Down Expand Up @@ -174,11 +175,17 @@ public interface IExtension {
ITransactionScoringProvider createTransactionScoringProvider(String transactionScoringProviderParamValues);

/**
* Optionally returns external communication providers that can be used by server to sending SMS or making voice calls.
* Optionally returns external communication providers that can be used by server to sending SMS.
* @return
*/
Set<ICommunicationProvider> getCommunicationProviders();

/**
* Optionally returns external communication providers that can be used by server to making voice call.
* @return
*/
Set<IVoiceCallProvider> getVoiceCallProviders();

/**
* @return Validators that can be used to validate SSNs
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*************************************************************************************
* Copyright (C) 2014-2023 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.communication.voicecall;

public interface IVoiceCallErrorResponse {

/**
* Error message.
*/
String getErrorMessage();

/**
* Making of voice call failed due the number is on black list.
*/
boolean isBlacklisted();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*************************************************************************************
* Copyright (C) 2014-2023 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.communication.voicecall;

/**
* Provider for making voice call.
*/
public interface IVoiceCallProvider {

/**
* Name of the voice call provider.
*/
String getName();

/**
* Make the voice call.
*
* @param credentials Credentials.
* @param phoneNumber Phone number.
* @param message Message.
* @param messageType Type of message.
* @param language Language in ISO 639-1 standard used at terminal.
* @return {@link IVoiceCallResponse}
*/
IVoiceCallResponse makeVoiceCall(String credentials, String phoneNumber, String message, MessageType messageType, String language);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*************************************************************************************
* Copyright (C) 2014-2023 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.communication.voicecall;

public interface IVoiceCallResponse {

enum ResponseStatus {
OK,
ERROR
}

/**
* ID of voice call.
*/
String getSid();

/**
* Response status [OK, ERROR].
*/
ResponseStatus getStatus();

/**
* Error information.
*/
IVoiceCallErrorResponse getErrorResponse();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*************************************************************************************
* Copyright (C) 2014-2023 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.communication.voicecall;

public enum MessageType {
MESSAGE,
OTP
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.hitbtc.HitbtcExchange;
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.enigma.EnigmaExchange;
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.poloniex.PoloniexExchange;
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.StillmanDigitalExchange;
import com.generalbytes.batm.server.extensions.extra.bitcoin.paymentprocessors.bitcoinpay.BitcoinPayPP;
import com.generalbytes.batm.server.extensions.extra.bitcoin.paymentprocessors.coinofsale.CoinOfSalePP;
import com.generalbytes.batm.server.extensions.extra.bitcoin.sources.bitkub.BitKubRateSource;
Expand Down Expand Up @@ -221,6 +222,11 @@ public IExchange createExchange(String paramString) {
String apiKey = paramTokenizer.nextToken();
String apiSecret = paramTokenizer.nextToken();
return new BitbuyExchange(apiKey, apiSecret);
} else if ("stillmandigital".equalsIgnoreCase(prefix)) {
String apiKey = paramTokenizer.nextToken();
String apiSecret = paramTokenizer.nextToken();
boolean useSandbox = paramTokenizer.hasMoreTokens() && paramTokenizer.nextToken().equals("sandbox");
return new StillmanDigitalExchange(apiKey, apiSecret, useSandbox);
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -585,6 +591,11 @@ public IRateSource createRateSource(String sourceLogin) {
String apiKey = st.nextToken();
String apiSecret = st.nextToken();
return new BitbuyExchange(apiKey, apiSecret);
} else if ("stillmandigital".equalsIgnoreCase(rsType)) {
String apiKey = st.nextToken();
String apiSecret = st.nextToken();
boolean useSandbox = st.hasMoreTokens() && st.nextToken().equals("sandbox");
return new StillmanDigitalExchange(apiKey, apiSecret, useSandbox);
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.binance;

import com.generalbytes.batm.common.currencies.CryptoCurrency;
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.XChangeExchange;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Wallet;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -91,6 +93,11 @@ protected BigDecimal getAmountRoundedToMinStep(BigDecimal cryptoAmount, BigDecim
public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) {
BigDecimal withdrawalFee = getWithdrawalFee(cryptoCurrency);
amount = amount.add(withdrawalFee);

if (CryptoCurrency.USDT.getCode().equals(cryptoCurrency)) {
amount = amount.setScale(6, RoundingMode.FLOOR);
}

return super.sendCoins(destinationAddress, amount, cryptoCurrency, description);
}

Expand All @@ -110,8 +117,8 @@ protected BigDecimal getWithdrawalMinStep(String cryptoCurrency) {
}

protected static class SupportedCryptoCurrency {
private String cryptoCurrency;
private BigDecimal withdrawalMinStep;
private final String cryptoCurrency;
private final BigDecimal withdrawalMinStep;

public SupportedCryptoCurrency(String cryptoCurrency) {
this(cryptoCurrency, new BigDecimal("0.00000001"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*************************************************************************************
* Copyright (C) 2014-2023 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.bitcoin.exchanges.stillmandigital;

import si.mazi.rescu.SynchronizedValueFactory;

import java.time.Clock;
import java.util.concurrent.TimeUnit;

public class CurrentTimeFactory implements SynchronizedValueFactory<Long> {

private static final Clock UTC_CLOCK = Clock.systemUTC();


@Override
public Long createValue() {
return TimeUnit.MILLISECONDS.toSeconds(UTC_CLOCK.millis());
}
}
Loading

0 comments on commit 94e20c4

Please sign in to comment.