DILSHAD737 commited on
Commit
ebc22b8
Β·
1 Parent(s): 866ec2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -51
app.py CHANGED
@@ -128,6 +128,10 @@ def generate_phrases_for_words(wordlist, mode):
128
  for combo in combinations(wordlist, r):
129
  yield " ".join(combo)
130
 
 
 
 
 
131
  # ============================================================
132
  # Gradio functions
133
  # ============================================================
@@ -139,23 +143,23 @@ def generate_random_phrase():
139
  def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
140
  start_index, end_index, passphrase):
141
  if not os.path.exists(addresses_file):
142
- yield f"❌ File nahi mili: {addresses_file}", ""
143
  return
144
 
145
  num_phrases = int(num_phrases)
146
  start_index = int(start_index)
147
  end_index = int(end_index)
148
 
149
- yield "Addresses load ho rahe hain...", ""
150
 
151
  try:
152
  known = load_addresses_cached(addresses_file)
153
  except Exception as e:
154
- yield f"❌ Addresses load fail: {e}", ""
155
  return
156
 
157
  if not known:
158
- yield "❌ Koi valid address file mein nahi mila", ""
159
  return
160
 
161
  mnemo = _get_mnemonic()
@@ -181,7 +185,7 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
181
  log_lines.append(f" {i}. {p}{tag}")
182
  log_lines.append("")
183
 
184
- yield "\n".join(log_lines), "Scan shuru ho raha hai..."
185
 
186
  matches = []
187
  start = time.time()
@@ -190,25 +194,18 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
190
  for p_idx, phrase in enumerate(phrases, 1):
191
  log_lines.append(f"---")
192
  log_lines.append(f"πŸ” [{p_idx}/{total_phrases}] Checking: {phrase}")
193
- yield "\n".join(log_lines), (
194
- "\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}"
195
- for p, i, k, a in matches)
196
- if matches else "Abhi tak koi match nahi"
197
- )
198
 
199
  words = phrase.strip().split()
200
  if len(words) != 12:
201
  log_lines.append(f"⚠️ Skipped (not 12 words)")
202
- yield "\n".join(log_lines), "Abhi tak koi match nahi"
203
  continue
204
 
205
  for idx in range(start_index, end_index + 1):
206
  log_lines.append(f" - Index {idx}...")
207
- yield "\n".join(log_lines), (
208
- "\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}"
209
- for p, i, k, a in matches)
210
- if matches else "Abhi tak koi match nahi"
211
- )
212
 
213
  for phrase_str in generate_phrases_for_words(words, phrase_mode):
214
  if not is_valid_bip39(phrase_str):
@@ -230,10 +227,8 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
230
  )
231
  log_lines.append(match_line)
232
  matches.append((phrase_str, idx, priv.hex(), addr))
233
- yield "\n".join(log_lines), "\n".join(
234
- f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}"
235
- for p, i, k, a in matches
236
- )
237
 
238
  elapsed = time.time() - start
239
  log_lines.append(f"---")
@@ -241,16 +236,13 @@ def run_multi_phrase_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
241
  log_lines.append(f"Total time: {elapsed:.1f}s")
242
  log_lines.append(f"Total matches: {len(matches)}")
243
 
244
- matches_text = "\n".join(
245
- f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}"
246
- for p, i, k, a in matches
247
- ) if matches else "Koi match nahi mila"
248
 
249
- yield "\n".join(log_lines), matches_text
250
 
251
 
252
  # ============================================================
253
- # Build UI (Cleaned up)
254
  # ============================================================
255
  with gr.Blocks(title="Phrase Scanner") as demo:
256
  gr.Markdown("# πŸ” Phrase Scanner")
@@ -278,36 +270,19 @@ with gr.Blocks(title="Phrase Scanner") as demo:
278
  label="Phrase Mode",
279
  )
280
  with gr.Row():
281
- start_index = gr.Number(
282
- label="Start Index",
283
- value=0, precision=0, minimum=0,
284
- )
285
- end_index = gr.Number(
286
- label="End Index",
287
- value=20, precision=0, minimum=0,
288
- )
289
- passphrase = gr.Textbox(
290
- label="BIP39 Passphrase (khali chhod dein)",
291
- value="",
292
- type="password",
293
- )
294
  run_btn = gr.Button("πŸš€ Scan Shuru Karein", variant="primary")
295
 
296
  with gr.Column(scale=2):
297
  gr.Markdown("### Output")
298
- log_output = gr.Textbox(
299
- label="Scan Log",
300
- lines=20,
301
- max_lines=30,
302
- interactive=False,
303
- autoscroll=True,
304
  )
305
- matches_output = gr.Textbox(
306
- label="Matches",
307
- lines=10,
308
- max_lines=20,
309
- interactive=False,
310
- autoscroll=True,
311
  )
312
 
313
  run_btn.click(
 
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 functions
137
  # ============================================================
 
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 make_html(f"❌ File nahi mili: {addresses_file}"), make_html("")
147
  return
148
 
149
  num_phrases = int(num_phrases)
150
  start_index = int(start_index)
151
  end_index = int(end_index)
152
 
153
+ yield make_html("Addresses load ho rahe hain..."), make_html("")
154
 
155
  try:
156
  known = load_addresses_cached(addresses_file)
157
  except Exception as e:
158
+ yield make_html(f"❌ Addresses load fail: {e}"), make_html("")
159
  return
160
 
161
  if not known:
162
+ yield make_html("❌ Koi valid address file mein nahi mila"), make_html("")
163
  return
164
 
165
  mnemo = _get_mnemonic()
 
185
  log_lines.append(f" {i}. {p}{tag}")
186
  log_lines.append("")
187
 
188
+ yield make_html("\n".join(log_lines)), make_html("Scan shuru ho raha hai...")
189
 
190
  matches = []
191
  start = time.time()
 
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
+ matches_html = "\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}" for p, i, k, a in matches) if matches else "Abhi tak koi match nahi"
198
+ yield make_html("\n".join(log_lines)), make_html(matches_html, color="#4caf50")
 
 
 
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
+ matches_html = "\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}" for p, i, k, a in matches) if matches else "Abhi tak koi match nahi"
208
+ yield make_html("\n".join(log_lines)), make_html(matches_html, color="#4caf50")
 
 
 
209
 
210
  for phrase_str in generate_phrases_for_words(words, phrase_mode):
211
  if not is_valid_bip39(phrase_str):
 
227
  )
228
  log_lines.append(match_line)
229
  matches.append((phrase_str, idx, priv.hex(), addr))
230
+ matches_html = "\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}" for p, i, k, a in matches)
231
+ yield make_html("\n".join(log_lines)), make_html(matches_html, color="#4caf50")
 
 
232
 
233
  elapsed = time.time() - start
234
  log_lines.append(f"---")
 
236
  log_lines.append(f"Total time: {elapsed:.1f}s")
237
  log_lines.append(f"Total matches: {len(matches)}")
238
 
239
+ final_matches = "\n".join(f"Phrase: {p}\nIndex: {i}\nKey: {k}\nAddr: {a}" for p, i, k, a in matches) if matches else "Koi match nahi mila"
 
 
 
240
 
241
+ yield make_html("\n".join(log_lines)), make_html(final_matches, color="#4caf50")
242
 
243
 
244
  # ============================================================
245
+ # Build UI
246
  # ============================================================
247
  with gr.Blocks(title="Phrase Scanner") as demo:
248
  gr.Markdown("# πŸ” Phrase Scanner")
 
270
  label="Phrase Mode",
271
  )
272
  with gr.Row():
273
+ start_index = gr.Number(label="Start Index", value=0, precision=0, minimum=0)
274
+ end_index = gr.Number(label="End Index", value=20, precision=0, minimum=0)
275
+ passphrase = gr.Textbox(label="BIP39 Passphrase (khali chhod dein)", value="", type="password")
 
 
 
 
 
 
 
 
 
 
276
  run_btn = gr.Button("πŸš€ Scan Shuru Karein", variant="primary")
277
 
278
  with gr.Column(scale=2):
279
  gr.Markdown("### Output")
280
+ # βœ… HTML Components
281
+ log_output = gr.HTML(
282
+ value=make_html("")
 
 
 
283
  )
284
+ matches_output = gr.HTML(
285
+ value=make_html("", height=150, color="#4caf50")
 
 
 
 
286
  )
287
 
288
  run_btn.click(