ANIMATION

import bitcoin
import secrets
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def compress_public_key(public_key):
    public_key_bytes = bytes.fromhex(public_key)
    prefix = b'\x02' if public_key_bytes[64] % 2 == 0 else b'\x03'
    compressed_public_key = prefix + public_key_bytes[1:33]
    compressed_public_key_hex = compressed_public_key.hex()
    return compressed_public_key_hex

def derive_bitcoin_address(public_key):
    bitcoin_address = bitcoin.pubtoaddr(public_key)
    return bitcoin_address

def generate_private_key(lower_limit, upper_limit):
    private_key_int = secrets.randbelow(upper_limit - lower_limit + 1) + lower_limit
    return format(private_key_int, 'x').zfill(64)

def main():
    lower_limit = 2 ** 65
    upper_limit = 2 ** 66 - 1
    target_address = "13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so"
   
    counter = 0
    found = False

    while not found and counter < 1000000000000000:  # Limit the loop iterations
        private_key_hex = generate_private_key(lower_limit, upper_limit)
        public_key = bitcoin.privtopub(private_key_hex)
        compressed_public_key = compress_public_key(public_key)
        bitcoin_address = derive_bitcoin_address(compressed_public_key)

        counter += 1

        logger.info(f"Counter: #{counter}: Priv: {private_key_hex},   Address: {bitcoin_address}")

        if bitcoin_address == target_address:
            found = True
            with open("win.txt", "w") as file:
                file.write(f"Private Key (WIF): {private_key_hex}\n")
                file.write(f"Compressed Public Key: {compressed_public_key}\n")
                file.write(f"Bitcoin Address: {bitcoin_address}\n")

    if found:
        logger.info("Matching wallet found! Check 'win.txt' for details.")
    else:
        logger.info("No matching wallet found after 1 million iterations.")

if __name__ == "__main__":
    main()