DILSHAD737 commited on
Commit
86c65a4
Β·
1 Parent(s): 990a011

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -29
app.py CHANGED
@@ -129,26 +129,31 @@ def generate_phrases_for_words(wordlist, mode):
129
  yield " ".join(combo)
130
 
131
  # ============================================================
132
- # Simple 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
- return f"❌ File nahi mili: {addresses_file}\n\nKoi match nahi mila"
 
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
- return f"❌ Addresses load fail: {e}\n\nKoi match nahi mila"
 
149
 
150
  if not known:
151
- return "❌ Koi valid address file mein nahi mila\n\nKoi match nahi mila"
 
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
- return log_text + "\n\n### MATCHES ###\n\n" + matches_text
208
 
209
  # ============================================================
210
- # Single Box UI (Impossible to break)
211
  # ============================================================
212
  with gr.Blocks() as demo:
213
  gr.Markdown("# πŸ” Phrase Scanner")
214
 
215
- with gr.Group():
216
- my_phrase = gr.Textbox(
217
- label="πŸ”‘ Apni Phrase (optional)",
218
- value="lesson cushion crane affair federal decline limb spend reunion chief cart zebra",
219
- lines=2,
220
- )
221
- num_phrases = gr.Number(label="Kitni Random Phrases Check Karein?", value=10, precision=0, minimum=0)
222
- addresses_file = gr.Textbox(label="Addresses File", value="12730802_addresses.csv")
223
- phrase_mode = gr.Radio(choices=["replace", "order", "subset"], value="replace", label="Phrase Mode")
224
-
225
- with gr.Row():
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
- output_box = gr.Textbox(
234
- label="Scan Results (Log + Matches)",
235
- lines=25,
236
- interactive=False,
237
- autoscroll=True
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=output_box,
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