Skip to content

Commit cd5c23d

Browse files
committed
Fix failure to remove
1 parent 11b432c commit cd5c23d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

generate-address-list.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
FEATURE_TYPE_TEXT = "Digital Currency Address - "
1111
NAMESPACE = {'sdn': 'https://sanctionslistservice.ofac.treas.gov/api/PublicationPreview/exports/ADVANCED_XML'}
1212

13-
# List of assets that have been sanctioned by the OFAC.
14-
# Possible assets be seen by grepping the sdn_advanced.xml file for "Digital Currency Address".
15-
POSSIBLE_ASSETS = ["XBT", "ETH", "XMR", "LTC", "ZEC", "DASH", "BTG", "ETC",
16-
"BSV", "BCH", "XVG", "USDT", "XRP", "ARB", "BSC", "USDC",
17-
"TRX"]
18-
1913
# List of implemented output formats
2014
OUTPUT_FORMATS = ["TXT", "JSON"]
2115

@@ -130,6 +124,19 @@ def main():
130124
else:
131125
output_formats = args.format
132126

127+
# Delete old output files to ensure removed addresses/assets are cleaned up
128+
# This loop handles the case where an asset is completely removed from OFAC list
129+
for fmt in output_formats:
130+
if fmt == "TXT":
131+
pattern = "sanctioned_addresses_*.txt"
132+
elif fmt == "JSON":
133+
pattern = "sanctioned_addresses_*.json"
134+
else:
135+
continue
136+
137+
for old_file in args.outpath.glob(pattern):
138+
old_file.unlink()
139+
133140
for asset in assets:
134141
address_id = get_address_id(root, asset)
135142
addresses = get_sanctioned_addresses(root, address_id)

0 commit comments

Comments
 (0)