-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...src/main/java/io/horizontalsystems/bankwallet/core/address/ChainalysisAddressValidator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.horizontalsystems.bankwallet.core.address | ||
|
||
import io.horizontalsystems.bankwallet.core.managers.APIClient | ||
import io.horizontalsystems.bankwallet.entities.Address | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
class ChainalysisAddressValidator( | ||
baseUrl: String, | ||
apiKey: String | ||
) : AddressSecurityCheckerChain.IAddressSecurityCheckerItem { | ||
|
||
private val apiService by lazy { | ||
APIClient.build( | ||
baseUrl, | ||
mapOf("Accept" to "application/json", "X-API-KEY" to apiKey) | ||
).create(ChainalysisApi::class.java) | ||
} | ||
|
||
override suspend fun handle(address: Address): AddressSecurityCheckerChain.SecurityIssue? { | ||
val response = apiService.address(address.hex) | ||
return if (response.identifications.isNotEmpty()) | ||
AddressSecurityCheckerChain.SecurityIssue.Sanctioned("Sanctioned address. ${response.identifications.size} identifications found.") | ||
else | ||
null | ||
} | ||
|
||
data class ChainalysisApiResponse( | ||
val identifications: List<Identification> | ||
) | ||
|
||
data class Identification( | ||
val category: String, | ||
val name: String?, | ||
val description: String?, | ||
val url: String? | ||
) | ||
|
||
private interface ChainalysisApi { | ||
@GET("address/{address}") | ||
suspend fun address(@Path("address") address: String): ChainalysisApiResponse | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters