As already mentioned there are few things that can be improved.
Overall you should consider using bit/tqdm as libraries. Instead of that you should look for more performant libraries or consider lower-level libraries.
Checking 'if address in b_addresses' inside the loop may slow down the script since 'b_addresses' is growing continuously.
key1 == key2
doesn't seem to be do anything useful, just remove that to keep the script clean as possible.
wif = bytes_to_wif(key1.to_bytes(), compressed=False)
wif2 = bytes_to_wif(key1.to_bytes(), compressed=True)
Try to avoid to use the same functions within the loop. You can store them in variables outside the loop.
wif_list.append(wif)
wif_list.append(wif2)
Same for that. You can use 'wif_list.extend([wif, wif2])' for that.
The script might be slightly faster if you are using a for-loop instead of using a while-loop. You might want to test that out:
for variable in range(start, stop, step):
OK i try my best and this is the result ... more than happy for now, BIG THX
100%|█████████████████████████████████████████████████████████████████████| 1000000/1000000 [01:07<00:00, 14767.12it/s]
also i show the changes that i make, what is in my skills till now
from bit import Key
from bit.format import bytes_to_wif
from tqdm import tqdm
i = 1
target = 1000000
wif_list = []
addr_list = []
matching_addresses = []
with open("target.txt", "r") as b_file:
b_addresses = set(b_file.read().splitlines())
pbar = tqdm(total=(target - i + 1))
# Calculate WIFs outside the loop
wif_calculator = bytes_to_wif(Key.from_int(i).to_bytes())
wif_compressed_calculator = bytes_to_wif(Key.from_int(i).to_bytes(), compressed=True)
while i <= target:
key1 = Key.from_int(i)
# Use the precalculated WIFs
wif = wif_calculator
wif2 = wif_compressed_calculator
wif_list.extend([wif, wif2])
address = key1.address
addr_list.append(address)
if address in b_addresses:
matching_addresses.append(address)
i += 1
pbar.update(1)
pbar.close()
# Write to disk after the loop
with open("wif.txt", "w") as f, open("add.txt", "w") as addr_file:
f.write("\n".join(wif_list) + "\n")
addr_file.write("\n".join(addr_list) + "\n")
for matching_address in matching_addresses:
print("Found matching address:", matching_address)
learning by testing and be educated from legends