From 0dfd92bcd608bdd1d6f0d4354947a73c630a28e8 Mon Sep 17 00:00:00 2001 From: terrtia Date: Wed, 8 May 2024 15:14:51 +0200 Subject: [PATCH] chg: [tron] add TRON crytocurrency detection + correlation. Thanks @pventuzelo for the contribution --- bin/lib/ail_core.py | 2 +- bin/lib/objects/CryptoCurrencies.py | 12 ++++++------ bin/modules/Cryptocurrencies.py | 8 +++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/lib/ail_core.py b/bin/lib/ail_core.py index 9483a3d0..5bcb6920 100755 --- a/bin/lib/ail_core.py +++ b/bin/lib/ail_core.py @@ -68,7 +68,7 @@ def get_object_all_subtypes(obj_type): # TODO Dynamic subtype if obj_type == 'chat-thread': return r_object.smembers(f'all_chat-thread:subtypes') if obj_type == 'cryptocurrency': - return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'zcash'] + return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'tron', 'zcash'] if obj_type == 'pgp': return ['key', 'mail', 'name'] if obj_type == 'username': diff --git a/bin/lib/objects/CryptoCurrencies.py b/bin/lib/objects/CryptoCurrencies.py index 01ff0c5e..ac545cc2 100755 --- a/bin/lib/objects/CryptoCurrencies.py +++ b/bin/lib/objects/CryptoCurrencies.py @@ -60,7 +60,7 @@ class CryptoCurrency(AbstractSubtypeObject): pass def is_valid_address(self): - if self.type == 'bitcoin' or self.type == 'dash' or self.type == 'litecoin': + if self.subtype == 'bitcoin' or self.subtype == 'dash' or self.subtype == 'litecoin' or self.subtype == 'tron': return check_base58_address(self.id) else: return True @@ -80,6 +80,8 @@ class CryptoCurrency(AbstractSubtypeObject): return 'ZEC' elif self.subtype == 'dash': return 'DASH' + elif self.subtype == 'tron': + return 'TRX' return None def get_link(self, flask_context=False): @@ -140,7 +142,7 @@ class CryptoCurrency(AbstractSubtypeObject): def get_all_subtypes(): # return ail_core.get_object_all_subtypes(self.type) - return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'zcash'] + return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'tron', 'zcash'] # def build_crypto_regex(subtype, search_id): @@ -172,6 +174,8 @@ def get_subtype_by_symbol(symbol): return 'zcash' elif symbol == 'DASH': return 'dash' + elif symbol == 'TRX': + return 'tron' return None @@ -189,10 +193,6 @@ def get_all_cryptocurrencies_by_subtype(subtype): def sanitize_cryptocurrency_name_to_search(name_to_search, subtype): # TODO FILTER NAME + Key + mail if subtype == '': pass - elif subtype == 'name': - pass - elif subtype == 'mail': - pass return name_to_search def search_cryptocurrency_by_name(name_to_search, subtype, r_pos=False): diff --git a/bin/modules/Cryptocurrencies.py b/bin/modules/Cryptocurrencies.py index 036b02b4..cf36ed81 100755 --- a/bin/modules/Cryptocurrencies.py +++ b/bin/modules/Cryptocurrencies.py @@ -92,7 +92,13 @@ CURRENCIES = { 'regex': r'\b(?