Spaces:
Sleeping

Daddy / app.py
polla1987's picture
Update app.py
de89aca verified
Raw History Blame
8.58 kB
import os
import sys
# 📌 ขั้นตอนพิเศษ: รวม requirements.txt ไว้ที่นี่ ระบบจะติดตั้งโมดูลคณิตศาสตร์อัตโนมัติเมื่อรัน
try:
import ecdsa
except ModuleNotFoundError:
print("⏳ กำลังติดตั้งแพ็กเกจคณิตศาสตร์ Bitcoin (ecdsa)... กรุณารอครู่เดียว")
os.system(f"{sys.executable} -m pip install ecdsa")
import ecdsa
print("✅ ติดตั้ง ecdsa เรียบร้อยแล้ว!")
import gradio as gr
import threading
import time
import hashlib
from ecdsa import SigningKey, SECP256k1
# กำหนดช่วงของ Puzzle #71
BASE_START = 0x400000000000000000
BASE_END = 0x7fffffffffffffffff
TOTAL_KEYS = BASE_END - BASE_START + 1
# พิกัดเริ่มต้นที่คุณต้องการ (56.710099385442%)
PERCENTAGE = 77.710099385442
DEFAULT_START = BASE_START + int(TOTAL_KEYS * (PERCENTAGE / 100))
# เป้าหมายแฮช RipeMD-160 ของ Puzzle #71 ของจริง บนบล็อกเชน
TARGET_RIPEMD = "f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8"
# ตัวแปรระบบเบื้องหลัง
is_running = False
current_key = DEFAULT_START
keys_checked = 0
speed = 0.0
found_private_key = "ยังไม่พบ (กำลังค้นหาอย่างละเอียด...)"
system_log = "📡 ระบบเปิดใช้งานกลไกตรวจสอบคีย์จริง 100% แล้ว (ช้าแต่ชัวร์ ไม่ปล่อยหลุดรอด)"
def check_real_bitcoin_key(key_int):
"""
🧠 ฟังก์ชันตรวจสอบคีย์แท้: แปลง Private Key -> Public Key -> RipeMD160
เป็นกระบวนการคณิตศาสตร์เต็มรูปแบบ ป้องกันการปล่อยคีย์หลุดรอด 100%
"""
try:
# 1. แปลงเลขพิกัดฐานสิบเป็นไบต์ข้อมูลขนาด 32 ไบต์
private_bytes = key_int.to_bytes(32, byteorder='big')
# 2. คำนวณหา Public Key ตามมาตรฐานวงรี SECP256k1 ของ Bitcoin
sk = SigningKey.from_string(private_bytes, curve=SECP256k1)
vk = sk.verifying_key
pub_key = vk.to_string(encoded=True)
# 3. แปลงให้เป็น Public Key แบบบีบอัด (Compressed Public Key ขนาด 33 ไบต์)
if pub_key[63] % 2 == 0:
compressed_pub = b'\x02' + pub_key[0:32]
else:
compressed_pub = b'\x03' + pub_key[0:32]
# 4. ทำการแฮชด้วย SHA-256 แล้วตามด้วย RIPEMD-160
sha = hashlib.sha256(compressed_pub).digest()
ripemd = hashlib.new('ripemd160', sha).hexdigest()
# 5. เปรียบเทียบผลลัพธ์กับกล่องรางวัล #71
if ripemd == TARGET_RIPEMD:
return True
except:
pass
return False
def scan_loop():
global current_key, keys_checked, is_running, speed, found_private_key, system_log
start_time = time.time()
local_count = 0
while is_running and current_key <= BASE_END:
# ตรวจสอบคีย์ของจริงอย่างละเอียดในทุกลูปคณิตศาสตร์
if check_real_bitcoin_key(current_key):
is_running = False
found_private_key = hex(current_key)
system_log = "🎉 [SUCCESS] พบคีย์ที่ถูกต้องแล้ว! ระบบทำการล็อกคีย์ถาวรเพื่อความปลอดภัย"
break
current_key += 1
keys_checked += 1
local_count += 1
# คำนวณความเร็ว
if local_count >= 20: # ปรับตัวนับให้เล็กลงเพื่อให้ความเร็วอัปเดตไวขึ้นเพราะระบบคำนวณหนัก
elapsed = time.time() - start_time
if elapsed > 0:
speed = keys_checked / elapsed
local_count = 0
if current_key > BASE_END:
is_running = False
system_log = "🏁 ค้นหาจนสุดขอบเขตของช่วงคีย์แล้วแต่ยังไม่พบคีย์ที่ถูกต้อง"
def control_scan(action, custom_resume_hex):
global is_running, current_key, system_log
if action == "start":
if not is_running:
if custom_resume_hex and custom_resume_hex.strip():
try:
current_key = int(custom_resume_hex.strip(), 16)
except:
return "❌ รูปแบบโค้ด Hex ไม่ถูกต้อง"
is_running = True
system_log = "กำลังตรวจสอบคีย์จริงแบบเรียลไทม์... 🟢 (ระบบล็อกเป้า ป้องกันคีย์หลุดรอด)"
threading.Thread(target=scan_loop, daemon=True).start()
return system_log
elif action == "stop":
is_running = False
system_log = "หยุดชั่วคราวเรียบร้อยแล้ว ⏸"
return system_log
def get_status():
global current_key, keys_checked, speed, is_running, found_private_key, system_log
status_text = "กำลังทำงาน 🟢" if is_running else "หยุดทำงาน 🔴"
return (
status_text,
hex(current_key),
f"{keys_checked:,} คีย์",
f"{speed:.2f} คีย์/วินาที",
hex(current_key),
found_private_key,
f"### {system_log}"
)
# --- หน้าจอแสดงผลเสถียรพิเศษรองรับ iOS Web Browser ---
with gr.Blocks(title="Bitcoin Puzzle #71 Real Validator") as demo:
gr.Markdown("# 🔍 Bitcoin Puzzle #71 Real Validator (ระบบตรวจสอบจริงจัง 100%)")
found_out = gr.Textbox(
label="🎉 แจ้งเตือนเมื่อพบคีย์ (FOUND PRIVATE KEY!)",
value=found_private_key,
interactive=False
)
with gr.Row():
status_out = gr.Textbox(label="สถานะเซิร์ฟเวอร์ปัจจุบัน", value="หยุดทำงาน 🔴", interactive=False)
current_hex_out = gr.Textbox(label="พิกัดปัจจุบันที่วิ่งถึง (Hex)", value=hex(current_key), interactive=False)
with gr.Row():
count_out = gr.Textbox(label="จำนวนคีย์ที่ตรวจสอบจริงแล้ว", value="0 คีย์", interactive=False)
speed_out = gr.Textbox(label="ความเร็วตรวจสอบจริง", value="0.00 คีย์/วินาที", interactive=False)
resume_input = gr.Textbox(
label="พิกัดสำหรับกดรันต่อเนื่อง",
value=hex(current_key),
interactive=True
)
log_out = gr.Markdown(f"### {system_log}")
with gr.Row():
btn_start = gr.Button("▶ รันระบบตรวจสอบจริง", variant="primary")
btn_stop = gr.Button("⏸ หยุดชั่วคราว", variant="stop")
# ระบบรีเฟรชค่าบนหน้าจอมือถืออัตโนมัติ
timer = gr.Timer(value=1.0, active=True)
timer.tick(fn=get_status, outputs=[status_out, current_hex_out, count_out, speed_out, resume_input, found_out, log_out])
btn_start.click(fn=lambda resume_val: control_scan("start", resume_val), inputs=[resume_input], outputs=log_out)
btn_stop.click(fn=lambda: control_scan("stop", None), outputs=log_out)
if __name__ == "__main__":
demo.launch()