DILSHAD737 commited on
Commit
927abf6
Β·
1 Parent(s): 86c65a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -22
app.py CHANGED
@@ -129,31 +129,26 @@ def generate_phrases_for_words(wordlist, mode):
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,26 +170,19 @@ def run_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
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,17 +198,17 @@ def run_scan(my_phrase, num_phrases, addresses_file, phrase_mode,
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")
@@ -240,10 +228,10 @@ with gr.Blocks() as demo:
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,
 
129
  yield " ".join(combo)
130
 
131
  # ============================================================
132
+ # Scan Function (Returns all at once, NO yield)
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}", ""
 
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}", ""
 
149
 
150
  if not known:
151
+ return "❌ Koi valid address file mein nahi mila", ""
 
152
 
153
  mnemo = _get_mnemonic()
154
  phrases = []
 
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
  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
+ # Returns everything at the very end
208
+ return log_text, matches_text
209
 
210
  # ============================================================
211
+ # Clean UI (Standard Gradio, no blank screens)
212
  # ============================================================
213
  with gr.Blocks() as demo:
214
  gr.Markdown("# πŸ” Phrase Scanner")
 
228
  run_btn = gr.Button("πŸš€ Scan Shuru Karein", variant="primary")
229
 
230
  gr.Markdown("### Output")
231
+ log_output = gr.Textbox(lines=15, interactive=False, show_label=False)
232
 
233
  gr.Markdown("### Matches")
234
+ matches_output = gr.Textbox(lines=8, interactive=False, show_label=False)
235
 
236
  run_btn.click(
237
  fn=run_scan,