From 9ab7f898a02ecbafd7da511107cddf2fd5fe104d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 15 Jun 2026 09:52:18 -0700 Subject: Fix Max button, slash scan requests (429s), cache history locally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/api.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/api.js') diff --git a/src/api.js b/src/api.js index 43d2bae..3e10351 100644 --- a/src/api.js +++ b/src/api.js @@ -28,9 +28,10 @@ export class Api { })); this._rr = 0; - // Global throttle. - this._maxConcurrent = 2; - this._minGapMs = 200; + // Global throttle: one request at a time, well spaced. Combined with + // round-robin across two backends this keeps each host's rate very low. + this._maxConcurrent = 1; + this._minGapMs = 400; this._active = 0; this._nextStart = 0; this._queue = []; -- cgit v1.2.3