From 09647e5ed33aa093fecbd93fc100155ce6097c67 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 24 Jun 2026 08:17:21 -0700 Subject: Choose your own block explorer; flatten How it works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Settings → Block explorer: pick mempool.space (default, with blockstream.info as a silent failover), blockstream.info only, or a custom Esplora/electrs REST URL (e.g. your own node). The realtime WebSocket only applies to mempool.space; other explorers fall back to polling. Switching rebuilds the API and rescans. Replaces the old undocumented explorer-proxy hack. - How it works: merge the "For the technically curious" disclosure into the main body so it's all visible under "The basics", and dedupe the overlapping no-server/offline sentences. Mentions the new explorer setting. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/wallet.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/wallet.js') diff --git a/src/wallet.js b/src/wallet.js index 111fb92..0f71454 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -148,6 +148,19 @@ export class Wallet { this.emit(); } + // Rebuild the Api against the currently-configured explorer, then rescan and + // reconnect realtime (called when the user switches explorer in Settings). + async reloadExplorer() { + this.stopRealtime(); + this.api = new Api(this.netName); + this.api.offline = this.offline; + if (this.offline) return; + try { + await this.scan(); + } catch {} + this.startRealtime(); + } + get netCfg() { return NETS[this.netName]; } @@ -683,7 +696,9 @@ export class Wallet { // Periodic full scan: reconciles everything refreshLive can't see on its own // — pending→confirmed history, spends, and stale cache/relay state. this._deepTimer = setInterval(() => this.scan({ silent: true }).catch(() => {}), 120000); - if (typeof WebSocket === 'undefined') return; + // Only mempool.space has a live socket; other explorers rely on the poll + // and deep scan above (wsUrl returns null → no socket). + if (typeof WebSocket === 'undefined' || !this.wsUrl()) return; this._wsWant = true; // Heartbeat: ping every 15s; if no message (incl. pong) for 45s the socket -- cgit v1.2.3