Spaces:
Runtime error
Runtime error
Commit Β·
abdba94
1
Parent(s): ebc22b8
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,38 +128,30 @@ def generate_phrases_for_words(wordlist, mode):
|
|
| 128 |
for combo in combinations(wordlist, r):
|
| 129 |
yield " ".join(combo)
|
| 130 |
|
| 131 |
-
# ---------- HTML Helper ----------
|
| 132 |
-
def make_html(text, height=300, color="#d4d4d4"):
|
| 133 |
-
return f"<pre style='height: {height}px; overflow-y: auto; background: #1e1e1e; color: {color}; padding: 10px; border-radius: 5px; font-family: monospace; white-space: pre-wrap;'>{text}</pre>"
|
| 134 |
-
|
| 135 |
# ============================================================
|
| 136 |
-
# Gradio
|
| 137 |
# ============================================================
|
| 138 |
|
| 139 |
-
def generate_random_phrase():
|
| 140 |
-
return _get_mnemonic().generate(strength=128)
|
| 141 |
-
|
| 142 |
-
|
| 143 |
def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
| 144 |
start_index, end_index, passphrase):
|
| 145 |
if not os.path.exists(addresses_file):
|
| 146 |
-
yield
|
| 147 |
return
|
| 148 |
|
| 149 |
num_phrases = int(num_phrases)
|
| 150 |
start_index = int(start_index)
|
| 151 |
end_index = int(end_index)
|
| 152 |
|
| 153 |
-
yield
|
| 154 |
|
| 155 |
try:
|
| 156 |
known = load_addresses_cached(addresses_file)
|
| 157 |
except Exception as e:
|
| 158 |
-
yield
|
| 159 |
return
|
| 160 |
|
| 161 |
if not known:
|
| 162 |
-
yield
|
| 163 |
return
|
| 164 |
|
| 165 |
mnemo = _get_mnemonic()
|
|
@@ -185,7 +177,7 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
|
| 185 |
log_lines.append(f" {i}. {p}{tag}")
|
| 186 |
log_lines.append("")
|
| 187 |
|
| 188 |
-
yield
|
| 189 |
|
| 190 |
matches = []
|
| 191 |
start = time.time()
|
|
@@ -194,18 +186,23 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
|
| 194 |
for p_idx, phrase in enumerate(phrases, 1):
|
| 195 |
log_lines.append(f"---")
|
| 196 |
log_lines.append(f"π [{p_idx}/{total_phrases}] Checking: {phrase}")
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
| 199 |
|
| 200 |
words = phrase.strip().split()
|
| 201 |
if len(words) != 12:
|
| 202 |
log_lines.append(f"β οΈ Skipped (not 12 words)")
|
|
|
|
| 203 |
continue
|
| 204 |
|
| 205 |
for idx in range(start_index, end_index + 1):
|
| 206 |
log_lines.append(f" - Index {idx}...")
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
| 209 |
|
| 210 |
for phrase_str in generate_phrases_for_words(words, phrase_mode):
|
| 211 |
if not is_valid_bip39(phrase_str):
|
|
@@ -227,8 +224,9 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
|
| 227 |
)
|
| 228 |
log_lines.append(match_line)
|
| 229 |
matches.append((phrase_str, idx, priv.hex(), addr))
|
| 230 |
-
|
| 231 |
-
|
|
|
|
| 232 |
|
| 233 |
elapsed = time.time() - start
|
| 234 |
log_lines.append(f"---")
|
|
@@ -236,13 +234,15 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
|
| 236 |
log_lines.append(f"Total time: {elapsed:.1f}s")
|
| 237 |
log_lines.append(f"Total matches: {len(matches)}")
|
| 238 |
|
| 239 |
-
|
|
|
|
|
|
|
| 240 |
|
| 241 |
-
yield
|
| 242 |
|
| 243 |
|
| 244 |
# ============================================================
|
| 245 |
-
#
|
| 246 |
# ============================================================
|
| 247 |
with gr.Blocks(title="Phrase Scanner") as demo:
|
| 248 |
gr.Markdown("# π Phrase Scanner")
|
|
@@ -277,12 +277,15 @@ with gr.Blocks(title="Phrase Scanner") as demo:
|
|
| 277 |
|
| 278 |
with gr.Column(scale=2):
|
| 279 |
gr.Markdown("### Output")
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
|
|
|
| 283 |
)
|
| 284 |
-
matches_output = gr.
|
| 285 |
-
|
|
|
|
|
|
|
| 286 |
)
|
| 287 |
|
| 288 |
run_btn.click(
|
|
|
|
| 128 |
for combo in combinations(wordlist, r):
|
| 129 |
yield " ".join(combo)
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
# ============================================================
|
| 132 |
+
# Gradio Scan Function
|
| 133 |
# ============================================================
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
| 136 |
start_index, end_index, passphrase):
|
| 137 |
if not os.path.exists(addresses_file):
|
| 138 |
+
yield f"β File nahi mili: {addresses_file}", ""
|
| 139 |
return
|
| 140 |
|
| 141 |
num_phrases = int(num_phrases)
|
| 142 |
start_index = int(start_index)
|
| 143 |
end_index = int(end_index)
|
| 144 |
|
| 145 |
+
yield "Addresses load ho rahe hain...", ""
|
| 146 |
|
| 147 |
try:
|
| 148 |
known = load_addresses_cached(addresses_file)
|
| 149 |
except Exception as e:
|
| 150 |
+
yield f"β Addresses load fail: {e}", ""
|
| 151 |
return
|
| 152 |
|
| 153 |
if not known:
|
| 154 |
+
yield "β Koi valid address file mein nahi mila", ""
|
| 155 |
return
|
| 156 |
|
| 157 |
mnemo = _get_mnemonic()
|
|
|
|
| 177 |
log_lines.append(f" {i}. {p}{tag}")
|
| 178 |
log_lines.append("")
|
| 179 |
|
| 180 |
+
yield "\n".join(log_lines), "Scan shuru ho raha hai..."
|
| 181 |
|
| 182 |
matches = []
|
| 183 |
start = time.time()
|
|
|
|
| 186 |
for p_idx, phrase in enumerate(phrases, 1):
|
| 187 |
log_lines.append(f"---")
|
| 188 |
log_lines.append(f"π [{p_idx}/{total_phrases}] Checking: {phrase}")
|
| 189 |
+
yield "\n".join(log_lines), (
|
| 190 |
+
"\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}\n" for p, i, k, a in matches)
|
| 191 |
+
if matches else "Abhi tak koi match nahi"
|
| 192 |
+
)
|
| 193 |
|
| 194 |
words = phrase.strip().split()
|
| 195 |
if len(words) != 12:
|
| 196 |
log_lines.append(f"β οΈ Skipped (not 12 words)")
|
| 197 |
+
yield "\n".join(log_lines), "Abhi tak koi match nahi"
|
| 198 |
continue
|
| 199 |
|
| 200 |
for idx in range(start_index, end_index + 1):
|
| 201 |
log_lines.append(f" - Index {idx}...")
|
| 202 |
+
yield "\n".join(log_lines), (
|
| 203 |
+
"\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}\n" for p, i, k, a in matches)
|
| 204 |
+
if matches else "Abhi tak koi match nahi"
|
| 205 |
+
)
|
| 206 |
|
| 207 |
for phrase_str in generate_phrases_for_words(words, phrase_mode):
|
| 208 |
if not is_valid_bip39(phrase_str):
|
|
|
|
| 224 |
)
|
| 225 |
log_lines.append(match_line)
|
| 226 |
matches.append((phrase_str, idx, priv.hex(), addr))
|
| 227 |
+
yield "\n".join(log_lines), "\n".join(
|
| 228 |
+
f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}\n" for p, i, k, a in matches
|
| 229 |
+
)
|
| 230 |
|
| 231 |
elapsed = time.time() - start
|
| 232 |
log_lines.append(f"---")
|
|
|
|
| 234 |
log_lines.append(f"Total time: {elapsed:.1f}s")
|
| 235 |
log_lines.append(f"Total matches: {len(matches)}")
|
| 236 |
|
| 237 |
+
matches_text = "\n".join(
|
| 238 |
+
f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}\n" for p, i, k, a in matches
|
| 239 |
+
) if matches else "Koi match nahi mila"
|
| 240 |
|
| 241 |
+
yield "\n".join(log_lines), matches_text
|
| 242 |
|
| 243 |
|
| 244 |
# ============================================================
|
| 245 |
+
# Clean, Standard UI (No fancy CSS that breaks Gradio 6)
|
| 246 |
# ============================================================
|
| 247 |
with gr.Blocks(title="Phrase Scanner") as demo:
|
| 248 |
gr.Markdown("# π Phrase Scanner")
|
|
|
|
| 277 |
|
| 278 |
with gr.Column(scale=2):
|
| 279 |
gr.Markdown("### Output")
|
| 280 |
+
log_output = gr.Textbox(
|
| 281 |
+
label="Scan Log",
|
| 282 |
+
lines=25,
|
| 283 |
+
interactive=False,
|
| 284 |
)
|
| 285 |
+
matches_output = gr.Textbox(
|
| 286 |
+
label="Matches",
|
| 287 |
+
lines=10,
|
| 288 |
+
interactive=False,
|
| 289 |
)
|
| 290 |
|
| 291 |
run_btn.click(
|