aboutsummaryrefslogtreecommitdiffstats
path: root/src/wallet.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-24 08:17:21 -0700
committerAdam Soltys <[email protected]>2026-06-24 08:17:21 -0700
commit09647e5ed33aa093fecbd93fc100155ce6097c67 (patch)
treea35e4692aa896fcc63e608cba12e8973423b9e6b /src/wallet.js
parent2b2e62375738e5d3f7b627e0a5d69b627194612d (diff)
downloadcoinosv3-09647e5ed33aa093fecbd93fc100155ce6097c67.tar.gz
coinosv3-09647e5ed33aa093fecbd93fc100155ce6097c67.zip
Choose your own block explorer; flatten How it works
- 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) <[email protected]>
Diffstat (limited to 'src/wallet.js')
-rw-r--r--src/wallet.js17
1 files changed, 16 insertions, 1 deletions
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