aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.js
Commit message (Collapse)AuthorAgeFilesLines
...
* Add per-request timeout + failover for unresponsive hostsAdam Soltys2026-06-151-2/+24
| | | | | | | | | | With concurrency 1, a single hung request (no response) stalled the whole serialized queue indefinitely — so balances/notifications never updated and the console filled with ERR_TIMED_OUT. Each request now has a 10s abort timeout; on timeout/network error the host is parked (20s) and we fail over to the other explorer. Applies to broadcasts too. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Prefer mempool, cooldown 429'ing hosts (stop Blockstream storm)Adam Soltys2026-06-151-16/+33
| | | | | | | | | | Round-robin sent half of every scan to Blockstream, which hard-rate-limits this IP (429 on each), and we kept routing back to it — stalling scans so new balances never showed. Now hosts are tried in order (mempool first) and any host that 429s is parked for 30s, so traffic stays on the healthy host and Blockstream is fallback-only. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Broadcast sends to all explorers in parallelAdam Soltys2026-06-151-15/+15
| | | | | | | | Post the signed tx to both mempool.space and Blockstream at once (outside the throttle, since a send is urgent) so it's visible regardless of which explorer the recipient watches. Succeeds if any accept; only fails if all do. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Global rate-aware request proxy + lighter pollingAdam Soltys2026-06-151-69/+67
| | | | | | | | | | | | | | 429 handling: route every outgoing request (address, utxo, txs, fees, broadcast) through one scheduler. A 429 from ANY request now pauses ALL subsequent requests with exponential backoff (2s→30s), easing off after a streak of successes — instead of only cooling down the same host/kind. Fewer requests: derive balance from /address chain_stats (no /utxo needed just to total), and on background polls fetch only /address. The heavier /utxo + /txs are pulled only on first load or when the balance/addresses actually change. Idle polls drop from ~3N requests to ~N. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Fix Max button, slash scan requests (429s), cache history locallyAdam Soltys2026-06-151-3/+4
| | | | | | | | | | | | | | | | | | | | Max button: fill the amount field with the computed maximum (n inputs, 1 output, current fee rate) so it gives visible feedback instead of just blanking/disabling the field. Rate limits: eliminate look-ahead (gap limit 1 — stop at the first unused address, safe because we only ever expose one unused address at a time), query one address at a time (API concurrency 1, 400ms spacing across two backends), scan chains sequentially, and pause 500ms after each used address. An empty scan is now ~2-3 requests instead of ~10+. History cache: persist scanned state (addresses, utxos, txs, indices) in localStorage keyed by sha256(seed) — the seed itself is never stored. Re- importing the same seed in this browser shows the last-known balance/history instantly while a fresh scan runs. Cleared by nothing automatically (public chain data); different seeds get separate keys. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Drop live badge + fiat price; persist wallet in sessionStorageAdam Soltys2026-06-151-13/+0
| | | | | | | | | | | | | - Remove the online/live status badge and the USD price line, which both appeared after load and caused layout shift. Stop fetching price entirely. - Persist the seed + passphrase in sessionStorage so a page refresh restores the open wallet instead of returning to the unlock screen. Cleared on logout and (by the browser) when the tab closes. Note: sessionStorage holds the seed in plaintext for the tab session — an acceptable tradeoff for this self-custody tool and scoped to the tab. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Defeat scan 429s with multi-backend rotation + cooldownAdam Soltys2026-06-141-39/+105
| | | | | | | | | | | | | | | | | | The "CORS" errors were 429 Too Many Requests (a 429 has no CORS headers, so the browser reports it as a CORS failure). SSL/hosting is irrelevant. Per-request retries made it worse by multiplying load on an already rate-limited host. Replace with: - round-robin across two Esplora-compatible backends (mempool.space + Blockstream), halving per-host load - park a host on an 8s cooldown when it 429s instead of retrying it - keep the global throttle (2 concurrent, 200ms gap) - map Blockstream's /fee-estimates to the named fee tiers Unit-tested rotation/cooldown; live scan of 40 addresses now completes in ~8s with no failures. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Fix scan rate-limiting (CORS errors) + tidy seed inputAdam Soltys2026-06-141-9/+52
| | | | | | | | | | | | | | | | | The "CORS" errors during scan were actually mempool.space rate-limiting: bursting ~40 address lookups gets some throttled, and throttled responses lack the access-control-allow-origin header, which the browser reports as a CORS failure. - api.js: route all requests through a global throttle (max 2 concurrent, 250ms min gap between starts, ~4 req/s) with exponential backoff retry so occasional throttles recover instead of failing. Unit-tested spacing + retry recovery. - Import pane: drop the "(12 or 24 words)" parenthetical (we generate 12), and replace the scrunched ellipsis placeholder with an enumerated word1..word12. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Rebuild as single-file offline BIP84 walletAdam Soltys2026-06-141-0/+104
Replace the SvelteKit/daisyUI prototype with a vanilla JS + hand-rolled CSS app that Bun bundles (code + scure/noble crypto + QR + CSS) into one self-contained dist/index.html runnable offline from file://. Wallet core (src/wallet.js): - BIP84 native-segwit HD wallet from BIP39 seed (+optional passphrase) - gap-limit scan of receive/change chains, aggregate balance, tx history - fresh receive/change addresses; signs with witnessUtxo only (enables offline signing with no prev-tx fetch) - coin selection + fee estimation via btc-signer selectUTXO; send-max; manual coin control - offline JSON snapshot export/import (keyless) + signed-tx hex/QR export - realtime mempool.space WebSocket: track-addresses -> debounced auto refresh of balances/history (no polling); live status badge UI (src/app.js): clean light paper-wallet; create (with optional, skippable backup verification) / import flow; receive (QR) / send / history / coins / tools tabs; clickable logo returns home. API (src/api.js): mempool.space wrapper with retry/backoff for scan-burst rate limiting; single network choke-point for offline enforcement. Verified: BIP84 spec vectors, build/sign/parse for auto/max/manual flows, snapshot roundtrip, live scan + WebSocket, headless-Chrome UI smoke tests. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>