Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
papiro08
on 20/04/2025, 08:39:45 UTC
random and sequential in Cyclone  Grin

Code:
import secrets
import subprocess
import time

# Hash160 objetivo
hash160_hex = "61eb8a50c86b0584bb727dd65bed8d2400d6d5aa"

# Rango de claves (10 cifras hexadecimales)
LOWER_BOUND = 0x10000000000
UPPER_BOUND = 0x1FFFFFFFFFF

# Máscara XOR
xor_mask = 0x13f53a6da4925903f1


# Set para evitar claves repetidas
used_keys = set()

def generate_unique_key(seed, xor_mask):
    """Genera una clave única hexadecimal usando una semilla y una máscara XOR."""
    while True:
        # Realizamos un XOR entre la semilla y la máscara
        new_seed = seed ^ xor_mask
       
        # Usamos la nueva semilla para generar un número aleatorio
        key = secrets.randbelow(UPPER_BOUND - LOWER_BOUND + 1) + LOWER_BOUND
       
        # Actualizamos la semilla para el siguiente número aleatorio
        seed = new_seed
       
        if key not in used_keys:
            used_keys.add(key)
            return f"{key:010X}", seed

def run_cyclone():
    count = 0
    seed = 0xBEBB3940CD0FC1491  # Semilla inicial
   
    while True:
        key_prefix, seed = generate_unique_key(seed, xor_mask)
        start_range = key_prefix + "0000000"
        end_range = key_prefix + "FFFFFFF"

        command = [
            "./Cyclone",
            "-h", hash160_hex,
            "-r", f"{start_range}:{end_range}",
            "-b", "5",
            "-t", "12",  # Puedes ajustar según tus núcleos
            "-S"
        ]

        print(f"\n[Intento {count + 1}] Ejecutando Cyclone con rango:")
        print(f"  {start_range} - {end_range}")
        print("-" * 60)

        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
        found_match = False
        lines_to_save = []

        for line in iter(process.stdout.readline, ''):
            print(line, end='')
            if "FOUND MATCH!" in line:
                found_match = True
            if found_match and len(lines_to_save) < 9:
                lines_to_save.append(line)

        process.wait()

        if found_match:
            with open("found_match.txt", "w") as file:
                file.writelines(lines_to_save)
            print("================== ¡FOUND MATCH! ==================")
            break

        if process.returncode != 0:
            error_output = process.stderr.read()
            print(f"[Error] Cyclone terminó con código {process.returncode}")
            print(f"[Error Output] {error_output}")

        count += 1
        time.sleep(0.1)


if __name__ == "__main__":
    run_cyclone()