| … | … | @@ -2199,10 +2199,14 @@ async function promptForPassword() { |
| 2199 | 2199 | const maxAttempts = 3 |
| 2200 | 2200 | let attempts = 0 |
| 2201 | 2201 | |
| 2202 | console.log('🔐 promptForPassword() called') |
| 2203 | |
| 2202 | 2204 | // Check if this is first-time password setup or regular unlock |
| 2203 | 2205 | const isEncrypted = await checkEncryptionStatus() |
| 2204 | 2206 | const isFirstTimeSetup = isEncrypted === false |
| 2205 | 2207 | |
| 2208 | console.log('📊 Encryption status:', { isEncrypted, isFirstTimeSetup }) |
| 2209 | |
| 2206 | 2210 | return new Promise((resolve) => { |
| 2207 | 2211 | const dialog = document.getElementById('password-dialog') |
| 2208 | 2212 | const titleEl = document.getElementById('password-dialog-title') |
| … | … | @@ -2218,6 +2222,16 @@ async function promptForPassword() { |
| 2218 | 2222 | const cancelBtn = document.getElementById('password-cancel-btn') |
| 2219 | 2223 | const attemptsEl = document.getElementById('password-attempts') |
| 2220 | 2224 | |
| 2225 | // Check if all elements exist |
| 2226 | if (!dialog || !passwordInput || !submitBtn) { |
| 2227 | console.error('❌ Password dialog elements not found!') |
| 2228 | console.error({ dialog, passwordInput, submitBtn }) |
| 2229 | resolve(false) |
| 2230 | return |
| 2231 | } |
| 2232 | |
| 2233 | console.log('✅ Password dialog elements found') |
| 2234 | |
| 2221 | 2235 | // Configure dialog for first-time setup vs unlock |
| 2222 | 2236 | if (isFirstTimeSetup) { |
| 2223 | 2237 | titleEl.textContent = '⚠️ SET WALLET PASSWORD' |
| … | … | @@ -2457,12 +2471,15 @@ async function init() { |
| 2457 | 2471 | // Fetch prices first (don't wait) |
| 2458 | 2472 | fetchPrices() |
| 2459 | 2473 | |
| 2460 | | if (initialized) { |
| 2474 | // Only load wallet data if initialized AND authenticated |
| 2475 | if (initialized && getToken()) { |
| 2461 | 2476 | await Promise.all([ |
| 2462 | 2477 | loadCurrentBalance(), |
| 2463 | 2478 | loadCurrentQRCode(), |
| 2464 | 2479 | loadTransactions() |
| 2465 | 2480 | ]) |
| 2481 | } else if (initialized && !getToken()) { |
| 2482 | console.warn('⚠️ Wallet initialized but not authenticated - waiting for password') |
| 2466 | 2483 | } |
| 2467 | 2484 | |
| 2468 | 2485 | // Auto-refresh every 30 seconds |