Skip to content

Commit

Permalink
Merge pull request #951 from filipocelka/feature/BATM-6710-tr-features
Browse files Browse the repository at this point in the history
BATM-6710 TR features
  • Loading branch information
filipocelka authored Dec 11, 2024
2 parents 8438793 + 34f88a7 commit 315eb0d
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
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.travelrule.IWalletTypeEvaluationProvider;
import com.generalbytes.batm.server.extensions.watchlist.IWatchList;

import java.util.Collections;
import java.util.Set;

/**
Expand Down Expand Up @@ -140,4 +142,9 @@ public Set<ISsnValidator> getSsnValidators() {
public IIdentityVerificationProvider createIdentityVerificationProvider(String colonDelimitedParameters, String gbApiKey) {
return null;
}

@Override
public Set<IWalletTypeEvaluationProvider> getWalletTypeEvaluationProviders() {
return Collections.emptySet();
}
}
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 @@ -25,8 +25,11 @@
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.travelrule.ITravelRuleProvider;
import com.generalbytes.batm.server.extensions.travelrule.IWalletTypeEvaluationProvider;
import com.generalbytes.batm.server.extensions.watchlist.IWatchList;

import java.util.Collections;
import java.util.Set;

/**
Expand Down Expand Up @@ -186,6 +189,12 @@ public interface IExtension {
*/
Set<IVoiceCallProvider> getVoiceCallProviders();

/**
* Returns set of external Travel Rule Providers.
* @return {@link Set} of {@link ITravelRuleProvider}.
*/
default Set<ITravelRuleProvider> getTravelRuleProviders() { return Collections.emptySet(); }

/**
* @return Validators that can be used to validate SSNs
*/
Expand All @@ -201,4 +210,12 @@ public interface IExtension {

IIdentityVerificationProvider createIdentityVerificationProvider(String colonDelimitedParameters, String gbApiKey);

/**
* Get wallet type evaluation providers.
*
* @return Set of wallet type evaluation providers.
* @see IWalletTypeEvaluationProvider
*/
Set<IWalletTypeEvaluationProvider> getWalletTypeEvaluationProviders();

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

/**
* Represents the possible types of wallets.
*/
public enum CryptoWalletType {
/**
* Owned and managed by a third party, such as a centralized exchange like Binance.
* The third party controls the private keys, and the user interacts with their funds through the service provider.
*/
CUSTODIAL,
/**
* Also known as a noncustodial wallet, where the user has full control over their private keys.
* Examples include hardware wallets, software wallets, and paper wallets. The user is solely responsible
* for securing their funds.
*/
UNHOSTED,

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

/**
* A Travel Rule Provider definition that makes it possible to connect to an external provider using its API.
* Provider is responsible for implementing compliance checks and procedures necessary to ensure adherence to the Travel Rule regulations.
*/
public interface ITravelRuleProvider {

/**
* This is used as the provider identifier that is displayed in CAS.
* @return Name of Travel Rule Provider.
*/
String getName();

// TODO: implement methods

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

import com.generalbytes.batm.server.extensions.IIdentity;

/**
* This class holds basic information required to identify a wallet.
*/
public interface IWalletContext {

/**
* Get the public id of the identity that the wallet belongs to (if any.)
*
* @return The identity public id or null.
* @see IIdentity
*/
String getIdentityPublicId();

/**
* Get the external id of the identity that the wallet belongs to (if any.)
*
* @return The identity external id or null.
* @see IIdentity
*/
String getIdentityExternalId();

/**
* Get the crypto address of the wallet.
*
* @return The crypto address of the wallet.
*/
String getCryptoAddress();

/**
* Get the cryptocurrency of the wallet.
*
* @return The cryptocurrency of the wallet.
*/
String getCryptocurrency();

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

/**
* This provider is used to evaluate the type of wallet based on its characteristics.
*
* @see CryptoWalletType
*/
public interface IWalletTypeEvaluationProvider {

/**
* Attempt to evaluate the type of wallet based on the provided {@link IWalletContext}.
* <p>
* This method should either return {@link WalletTypeEvaluationResult#evaluated(CryptoWalletType, boolean)},
* with the respective {@link CryptoWalletType} if the wallet was successfully evaluated.
* If the wallet type cannot be evaluated, it returns {@link WalletTypeEvaluationResult#unknown()}.
* </p>
*
* @param walletContext The context containing information needed to identify the wallet type.
* @return A {@link WalletTypeEvaluationResult} indicating success with the wallet type, or failure if not evaluated.
*/
WalletTypeEvaluationResult evaluateWalletType(IWalletContext walletContext);

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

/**
* Represents the result of an attempt on identifying a wallet type.
*
* @see IWalletTypeEvaluationProvider
*/
public class WalletTypeEvaluationResult {

private final CryptoWalletType walletType;
private final boolean belongsToIdentity;

private WalletTypeEvaluationResult(CryptoWalletType walletType, boolean belongsToIdentity) {
this.walletType = walletType;
this.belongsToIdentity = belongsToIdentity;
}

/**
* Get the {@link CryptoWalletType} of the identified wallet.
*
* @return The {@link CryptoWalletType}.
*/
public CryptoWalletType getWalletType() {
return walletType;
}

/**
* @return True if the wallet belongs to the provided identity, false otherwise.
*/
public boolean isBelongsToIdentity() {
return belongsToIdentity;
}

/**
* Create a {@link WalletTypeEvaluationResult} for cases where a wallet type
* is successfully evaluated.
*
* @param walletType The {@link CryptoWalletType} of the evaluated wallet.
* @param belongsToIdentity True if the wallet belongs to the provided identity, false otherwise.
* @return The new {@link WalletTypeEvaluationResult}.
* @throws IllegalArgumentException If the walletType is null.
*/
public static WalletTypeEvaluationResult evaluated(CryptoWalletType walletType, boolean belongsToIdentity) {
if (walletType == null) {
throw new IllegalArgumentException("walletType cannot be null");
}
return new WalletTypeEvaluationResult(walletType, belongsToIdentity);
}

/**
* Create a {@link WalletTypeEvaluationResult} for cases where a wallet type
* could not be identified and remains unknown.
*
* @return The new {@link WalletTypeEvaluationResult}.
*/
public static WalletTypeEvaluationResult unknown() {
return new WalletTypeEvaluationResult(CryptoWalletType.UNKNOWN, false);
}

}

0 comments on commit 315eb0d

Please sign in to comment.