import os,utils

#INP = "/home/user/addresses/"


def extractAddresses(lines):
    addresses = []
    for line in lines:

        address = utils.extractStringBetween(line[:-1], "", " |")
        if address == "":
            address = line[:-1]

        addresses.append(address)

    addresses = set(addresses)
    return addresses




sampleAddresses = []

paths = ["/home/user/Schreibtisch/TransactionInfos/JigsawVanityAddresses/5976edf04bcb2c717e17d820ebf29b398a90993d2ebf20de5d6f6c1ac5c04e54_vanityAddresses.txt",
         "/home/user/Schreibtisch/TransactionInfos/JigsawVanityAddresses/454280128478d0da357e8609d5bef43a601ba18582a96678c0d5e60ceb9b08aa_vanityAddresses.txt"
         ]

for path in paths:
    f = open(path, "r")
    for line in f.readlines():
        sampleAddresses.append(line[:-1])  # skip newline
    f.close()

path = "/home/user/EvalLogs/hunt_JigsawBitcoinStealer_addresses"
#path = "/home/user/EvalLogs/hunt_BtcVanityAddrChanger_addresses"


f = open(path, "r")
lines = f.readlines()
f.close()
crawledAddresses = extractAddresses(lines)

foundAddresses = []

for sampleAddress in sampleAddresses:
    for crawledAddress in crawledAddresses:
        if sampleAddress != crawledAddress:
            print("not found: " + crawledAddress)
            #pass
        else:
            print("found: " + crawledAddress)
            foundAddresses.append(crawledAddress)

print("foundAddresses: " + str(len(foundAddresses)) )
print(foundAddresses)





# for name in os.listdir(INP):
#     print(name)
#     path = INP + name
#     if os.path.isfile(path):
#
#         currentAddresses = []
#         fc = open(path, "r")
#         for line in fc.readlines():
#             currentAddresses.append(line[-1])
#
#         if any(i in checkAddresses for i in currentAddresses):
#             print("found in: " + path + "| addr: " + str(currentAddresses))
