Spaces:
Runtime error
Runtime error
Commit Β·
86c65a4
1
Parent(s): 990a011
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,26 +129,31 @@ def generate_phrases_for_words(wordlist, mode):
|
|
| 129 |
yield " ".join(combo)
|
| 130 |
|
| 131 |
# ============================================================
|
| 132 |
-
#
|
| 133 |
# ============================================================
|
| 134 |
|
| 135 |
def run_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
| 136 |
start_index, end_index, passphrase):
|
| 137 |
|
| 138 |
if not os.path.exists(addresses_file):
|
| 139 |
-
|
|
|
|
| 140 |
|
| 141 |
num_phrases = int(num_phrases)
|
| 142 |
start_index = int(start_index)
|
| 143 |
end_index = int(end_index)
|
| 144 |
|
|
|
|
|
|
|
| 145 |
try:
|
| 146 |
known = load_addresses_cached(addresses_file)
|
| 147 |
except Exception as e:
|
| 148 |
-
|
|
|
|
| 149 |
|
| 150 |
if not known:
|
| 151 |
-
|
|
|
|
| 152 |
|
| 153 |
mnemo = _get_mnemonic()
|
| 154 |
phrases = []
|
|
@@ -170,19 +175,26 @@ def run_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
|
| 170 |
log_text += f" {i}. {p}{tag}\n"
|
| 171 |
log_text += "\n--- Scanning ---\n"
|
| 172 |
|
|
|
|
|
|
|
| 173 |
matches = []
|
| 174 |
start = time.time()
|
| 175 |
total_phrases = len(phrases)
|
| 176 |
|
| 177 |
for p_idx, phrase in enumerate(phrases, 1):
|
| 178 |
log_text += f"\nπ [{p_idx}/{total_phrases}] Checking: {phrase}\n"
|
|
|
|
|
|
|
| 179 |
words = phrase.strip().split()
|
| 180 |
-
|
| 181 |
if len(words) != 12:
|
| 182 |
log_text += " β οΈ Skipped (not 12 words)\n"
|
|
|
|
| 183 |
continue
|
| 184 |
|
| 185 |
for idx in range(start_index, end_index + 1):
|
|
|
|
|
|
|
|
|
|
| 186 |
for phrase_str in generate_phrases_for_words(words, phrase_mode):
|
| 187 |
if not is_valid_bip39(phrase_str):
|
| 188 |
continue
|
|
@@ -198,50 +210,46 @@ def run_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
|
| 198 |
match_line = f"π MATCH!\nPhrase: {phrase_str}\nIndex: {idx}\nKey: {priv.hex()}\nAddr: {addr}\n"
|
| 199 |
log_text += match_line
|
| 200 |
matches.append(match_line)
|
|
|
|
| 201 |
|
| 202 |
elapsed = time.time() - start
|
| 203 |
log_text += f"\n=== DONE ===\nTotal time: {elapsed:.1f}s\nTotal matches: {len(matches)}\n"
|
| 204 |
|
| 205 |
matches_text = "\n".join(matches) if matches else "Koi match nahi mila"
|
| 206 |
|
| 207 |
-
|
| 208 |
|
| 209 |
# ============================================================
|
| 210 |
-
#
|
| 211 |
# ============================================================
|
| 212 |
with gr.Blocks() as demo:
|
| 213 |
gr.Markdown("# π Phrase Scanner")
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
start_index = gr.Number(label="Start Index", value=0, precision=0, minimum=0)
|
| 227 |
-
end_index = gr.Number(label="End Index", value=20, precision=0, minimum=0)
|
| 228 |
-
|
| 229 |
-
passphrase = gr.Textbox(label="BIP39 Passphrase (khali chhod dein)", value="", type="password")
|
| 230 |
|
| 231 |
run_btn = gr.Button("π Scan Shuru Karein", variant="primary")
|
| 232 |
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
)
|
| 239 |
|
| 240 |
run_btn.click(
|
| 241 |
fn=run_scan,
|
| 242 |
inputs=[my_phrase, num_phrases, addresses_file, phrase_mode,
|
| 243 |
start_index, end_index, passphrase],
|
| 244 |
-
outputs=
|
| 245 |
)
|
| 246 |
|
| 247 |
# ZeroGPU requirement
|
|
|
|
| 129 |
yield " ".join(combo)
|
| 130 |
|
| 131 |
# ============================================================
|
| 132 |
+
# Scan Function
|
| 133 |
# ============================================================
|
| 134 |
|
| 135 |
def run_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
|
| 136 |
start_index, end_index, passphrase):
|
| 137 |
|
| 138 |
if not os.path.exists(addresses_file):
|
| 139 |
+
yield f"β File nahi mili: {addresses_file}\n\nKoi match nahi mila", ""
|
| 140 |
+
return
|
| 141 |
|
| 142 |
num_phrases = int(num_phrases)
|
| 143 |
start_index = int(start_index)
|
| 144 |
end_index = int(end_index)
|
| 145 |
|
| 146 |
+
yield "Addresses load ho rahe hain...", ""
|
| 147 |
+
|
| 148 |
try:
|
| 149 |
known = load_addresses_cached(addresses_file)
|
| 150 |
except Exception as e:
|
| 151 |
+
yield f"β Addresses load fail: {e}\n\nKoi match nahi mila", ""
|
| 152 |
+
return
|
| 153 |
|
| 154 |
if not known:
|
| 155 |
+
yield "β Koi valid address file mein nahi mila\n\nKoi match nahi mila", ""
|
| 156 |
+
return
|
| 157 |
|
| 158 |
mnemo = _get_mnemonic()
|
| 159 |
phrases = []
|
|
|
|
| 175 |
log_text += f" {i}. {p}{tag}\n"
|
| 176 |
log_text += "\n--- Scanning ---\n"
|
| 177 |
|
| 178 |
+
yield log_text, "Scan shuru ho raha hai..."
|
| 179 |
+
|
| 180 |
matches = []
|
| 181 |
start = time.time()
|
| 182 |
total_phrases = len(phrases)
|
| 183 |
|
| 184 |
for p_idx, phrase in enumerate(phrases, 1):
|
| 185 |
log_text += f"\nπ [{p_idx}/{total_phrases}] Checking: {phrase}\n"
|
| 186 |
+
yield log_text, "\n".join(matches) if matches else "Abhi tak koi match nahi"
|
| 187 |
+
|
| 188 |
words = phrase.strip().split()
|
|
|
|
| 189 |
if len(words) != 12:
|
| 190 |
log_text += " β οΈ Skipped (not 12 words)\n"
|
| 191 |
+
yield log_text, "\n".join(matches) if matches else "Abhi tak koi match nahi"
|
| 192 |
continue
|
| 193 |
|
| 194 |
for idx in range(start_index, end_index + 1):
|
| 195 |
+
log_text += f" - Index {idx}...\n"
|
| 196 |
+
yield log_text, "\n".join(matches) if matches else "Abhi tak koi match nahi"
|
| 197 |
+
|
| 198 |
for phrase_str in generate_phrases_for_words(words, phrase_mode):
|
| 199 |
if not is_valid_bip39(phrase_str):
|
| 200 |
continue
|
|
|
|
| 210 |
match_line = f"π MATCH!\nPhrase: {phrase_str}\nIndex: {idx}\nKey: {priv.hex()}\nAddr: {addr}\n"
|
| 211 |
log_text += match_line
|
| 212 |
matches.append(match_line)
|
| 213 |
+
yield log_text, "\n".join(matches)
|
| 214 |
|
| 215 |
elapsed = time.time() - start
|
| 216 |
log_text += f"\n=== DONE ===\nTotal time: {elapsed:.1f}s\nTotal matches: {len(matches)}\n"
|
| 217 |
|
| 218 |
matches_text = "\n".join(matches) if matches else "Koi match nahi mila"
|
| 219 |
|
| 220 |
+
yield log_text, matches_text
|
| 221 |
|
| 222 |
# ============================================================
|
| 223 |
+
# Simple UI
|
| 224 |
# ============================================================
|
| 225 |
with gr.Blocks() as demo:
|
| 226 |
gr.Markdown("# π Phrase Scanner")
|
| 227 |
|
| 228 |
+
my_phrase = gr.Textbox(
|
| 229 |
+
label="π Apni Phrase (optional)",
|
| 230 |
+
value="lesson cushion crane affair federal decline limb spend reunion chief cart zebra",
|
| 231 |
+
lines=2,
|
| 232 |
+
)
|
| 233 |
+
num_phrases = gr.Number(label="Kitni Random Phrases Check Karein?", value=10, precision=0, minimum=0)
|
| 234 |
+
addresses_file = gr.Textbox(label="Addresses File", value="12730802_addresses.csv")
|
| 235 |
+
phrase_mode = gr.Radio(choices=["replace", "order", "subset"], value="replace", label="Phrase Mode")
|
| 236 |
+
start_index = gr.Number(label="Start Index", value=0, precision=0, minimum=0)
|
| 237 |
+
end_index = gr.Number(label="End Index", value=20, precision=0, minimum=0)
|
| 238 |
+
passphrase = gr.Textbox(label="BIP39 Passphrase (khali chhod dein)", value="", type="password")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
run_btn = gr.Button("π Scan Shuru Karein", variant="primary")
|
| 241 |
|
| 242 |
+
gr.Markdown("### Output")
|
| 243 |
+
log_output = gr.Textbox(lines=15, interactive=False, autoscroll=True)
|
| 244 |
+
|
| 245 |
+
gr.Markdown("### Matches")
|
| 246 |
+
matches_output = gr.Textbox(lines=8, interactive=False, autoscroll=True)
|
|
|
|
| 247 |
|
| 248 |
run_btn.click(
|
| 249 |
fn=run_scan,
|
| 250 |
inputs=[my_phrase, num_phrases, addresses_file, phrase_mode,
|
| 251 |
start_index, end_index, passphrase],
|
| 252 |
+
outputs=[log_output, matches_output],
|
| 253 |
)
|
| 254 |
|
| 255 |
# ZeroGPU requirement
|