Skip to content

Commit

Permalink
Merge branch 'master' into sync1.6toMaster
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Ocelka committed Sep 3, 2024
2 parents f8f4ef7 + 206a0b2 commit 85e149d
Show file tree
Hide file tree
Showing 23 changed files with 308 additions and 21 deletions.
2 changes: 1 addition & 1 deletion annotations/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("shared-build-conventions")
id("shared-publish-conventions")
}

group = projectGroup
Expand Down
1 change: 0 additions & 1 deletion batm_ssh_tunnel/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("application")
id("shared-build-conventions")
}

version = "1.0.0"
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id("shared-build-conventions")
}

allprojects {
apply plugin: 'shared-build-conventions'
}
1 change: 0 additions & 1 deletion buildSrc/src/main/groovy/shared-build-conventions.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id("java")
id("com.generalbytes.gradle.main")
id("shared-publish-conventions")
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion currencies/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("shared-build-conventions")
id("shared-publish-conventions")
}

group = projectGroup
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.6.4
projectVersion=1.7.3

# buildscript - common dependency versions
bitrafaelVersion=1.0.44
Expand Down
2 changes: 1 addition & 1 deletion operators_sample_website/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("shared-build-conventions")
id("shared-publish-conventions")
}

group = projectGroup
Expand Down
2 changes: 1 addition & 1 deletion server_extensions_api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("shared-build-conventions")
id("shared-publish-conventions")
id("distribution")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +17,8 @@
************************************************************************************/
package com.generalbytes.batm.server.extensions;

import com.generalbytes.batm.server.extensions.watchlist.WatchListScanIdentityMatchesData;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
Expand Down Expand Up @@ -293,6 +295,13 @@ default void watchlistScanBan(String terminalSerialNumber) {}
*/
default void watchlistScanIdentityMatches(String identityPublicId) {}

/**
* Triggered if there is a match on the WatchList with the Identity. Contains detailed information.
*
* @param data Object containing detailed information about match result.
*/
default void watchlistScanIdentityMatches(WatchListScanIdentityMatchesData data) {}

default void lifetimeIdentityVolumeReached(String terminalSerialNumber, BigDecimal lifetimeVolume, String cashCurrency, BigDecimal preConditionAmount, String identityPublicId) {}

default void transactionSupplyLimitReached(String terminalSerialNumber) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.generalbytes.batm.server.extensions.payment;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
Expand All @@ -28,6 +29,7 @@ public class ReceivedAmount {

private final BigDecimal totalAmountReceived;
private final int confirmations;
private List<String> transactionHashes;

public ReceivedAmount(BigDecimal totalAmountReceived, int confirmations) {
this.totalAmountReceived = Objects.requireNonNull(totalAmountReceived);
Expand All @@ -49,4 +51,18 @@ public BigDecimal getTotalAmountReceived() {
public int getConfirmations() {
return confirmations;
}

/**
* @return hashes of all incoming transactions
*/
public List<String> getTransactionHashes() {
return transactionHashes;
}

/**
* @param transactionHashes hashes of all incoming transactions
*/
public void setTransactionHashes(List<String> transactionHashes) {
this.transactionHashes = transactionHashes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*************************************************************************************
* 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
* 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.watchlist;

import java.io.Serializable;

public class WatchListScanIdentityMatchesData implements Serializable {

/**
* Public ID of identity.
*/
private String identityPublicId;

/**
* Code of WatchList.
*/
private String watchListCode;

/**
* Unique identifier of the matching entity.
*/
private String partyId;

/**
* Type of WatchList trigger.
*/
private WatchListTrigger trigger;

/**
* Result of scan.
*/
private WatchListScanResult scanResult;

/**
* Terminal serial number. It is available if the trigger is {@link WatchListTrigger#PRE_TRANSACTION}, otherwise null.
*/
private String terminalSerialNumber;

public String getIdentityPublicId() {
return identityPublicId;
}

public void setIdentityPublicId(String identityPublicId) {
this.identityPublicId = identityPublicId;
}

public String getWatchListCode() {
return watchListCode;
}

public void setWatchListCode(String watchListCode) {
this.watchListCode = watchListCode;
}

public String getPartyId() {
return partyId;
}

public void setPartyId(String partyId) {
this.partyId = partyId;
}

public WatchListTrigger getTrigger() {
return trigger;
}

public void setTrigger(WatchListTrigger trigger) {
this.trigger = trigger;
}

public WatchListScanResult getScanResult() {
return scanResult;
}

public void setScanResult(WatchListScanResult scanResult) {
this.scanResult = scanResult;
}

public String getTerminalSerialNumber() {
return terminalSerialNumber;
}

public void setTerminalSerialNumber(String terminalSerialNumber) {
this.terminalSerialNumber = terminalSerialNumber;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*************************************************************************************
* 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
* 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.watchlist;

public enum WatchListScanResult {

NO_MATCH,
PARTIAL_MATCH,
FULL_MATCH

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*************************************************************************************
* 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
* 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.watchlist;

public enum WatchListTrigger {

MANUAL,
PRE_TRANSACTION,
PERIODIC,
EXTENSION

}
2 changes: 1 addition & 1 deletion server_extensions_examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("shared-build-conventions")
id("shared-publish-conventions")
}

group = projectGroup
Expand Down
2 changes: 1 addition & 1 deletion server_extensions_extra/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("shared-build-conventions")
id("shared-publish-conventions")
id("shared-repositories-ext-conventions")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -29,7 +29,7 @@ public class BinanceCoinAddressValidator implements ICryptoAddressValidator {
@Override
public boolean isAddressValid(String address) {
try {
Bech32.Bech32Data bech32Data = Bech32.decodeUnlimitedLength(address);
Bech32.Bech32Data bech32Data = Bech32.decodeUnlimitedLength(getAddressWithoutTag(address));
if (!bech32Data.hrp.equals("bnb")) {
log.info("Address HRP is not 'bnb'");
return false;
Expand All @@ -50,4 +50,9 @@ public boolean isPaperWalletSupported() {
public boolean mustBeBase58Address() {
return false;
}

private String getAddressWithoutTag(String address) {
return address.split(":")[0];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,27 @@
import com.generalbytes.batm.common.currencies.CryptoCurrency;
import com.generalbytes.batm.server.extensions.IGeneratesNewDepositCryptoAddress;
import com.generalbytes.batm.server.extensions.IQueryableWallet;
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitgo.v2.dto.BitGoCreateAddressRequest;
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitgo.v2.dto.BitGoAddressResponse;
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitgo.v2.dto.BitGoCreateAddressRequest;
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitgo.v2.dto.BitGoTransfer;
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitgo.v2.dto.BitGoTransfersResponse;
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitgo.v2.dto.ErrorResponseException;
import com.generalbytes.batm.server.extensions.payment.ReceivedAmount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import si.mazi.rescu.HttpStatusIOException;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BitgoWalletWithUniqueAddresses extends BitgoWallet implements IGeneratesNewDepositCryptoAddress, IQueryableWallet {
private static final Logger log = LoggerFactory.getLogger(BitgoWalletWithUniqueAddresses.class);

private static final String TRANSFER_STATE_CONFIRMED = "confirmed";
private static final String TRANSFER_TYPE_RECEIVE = "receive";
private static final Map<String, String> newAddressCryptoCurrency = new HashMap<String, String>() {
{
put(CryptoCurrency.USDT.getCode(), "eth");
Expand Down Expand Up @@ -93,11 +99,30 @@ public ReceivedAmount getReceivedAmount(String address, String cryptoCurrency) {
}

try {
BitGoAddressResponse resp = api.getAddress(bitgoCryptoCurrency, walletId, address);
if (resp.getBalance().getConfirmedBalance().compareTo(BigDecimal.ZERO) > 0) {
return new ReceivedAmount(fromSatoshis(cryptoCurrency, resp.getBalance().getConfirmedBalance()), 999);
BitGoTransfersResponse transfersResponse = api.getTransfers(
bitgoCryptoCurrency,
walletId,
TRANSFER_STATE_CONFIRMED,
TRANSFER_TYPE_RECEIVE,
address
);
BigDecimal totalInBaseUnits = BigDecimal.ZERO;
int confirmations = 0;
List<String> transactionHashes = new ArrayList<>();

for (BitGoTransfer confirmedTransfer : transfersResponse.getTransfers()) {
BigDecimal valueInBaseUnits = fromSatoshis(cryptoCurrency, confirmedTransfer.getValue());

totalInBaseUnits = totalInBaseUnits.add(valueInBaseUnits);
if (confirmations == 0 || confirmedTransfer.getConfirmations() < confirmations) {
confirmations = confirmedTransfer.getConfirmations();
}
transactionHashes.add(confirmedTransfer.getTransactionHash());
}
return new ReceivedAmount(fromSatoshis(cryptoCurrency, resp.getBalance().getBalance()), 0);

ReceivedAmount receivedAmount = new ReceivedAmount(totalInBaseUnits, confirmations);
receivedAmount.setTransactionHashes(transactionHashes);
return receivedAmount;
} catch (HttpStatusIOException e) {
log.debug("get address error: {}", e.getHttpBody());
} catch (ErrorResponseException e) {
Expand Down
Loading

0 comments on commit 85e149d

Please sign in to comment.