From a9a903e7a1f80ed4a6f4163419b25d4e6de5db01 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 27 Jun 2026 08:40:41 -0700 Subject: Add regtest network support New `regtest` network (bech32 `bcrt`, testnet version bytes) selectable in Settings, pointed at a configurable local Esplora (default http://localhost:3000). Adds getNetwork/setNetwork + getRegtestEsplora persistence, a regtest branch in resolveHosts, mainnet-only gating for the realtime watcher + Electrum backend, and a Network selector card. Account loading reads the active network. Co-Authored-By: Claude Opus 4.8 --- src/wallet.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/wallet.js') diff --git a/src/wallet.js b/src/wallet.js index 33a1f3f..a721c00 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -41,6 +41,9 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const NETS = { mainnet: { net: btc.NETWORK, coin: 0 }, testnet: { net: btc.TEST_NETWORK, coin: 1 }, + // Regtest shares testnet's version bytes / coin type; only the bech32 HRP + // differs (`bcrt`). @scure/btc-signer derives addresses + validates from this. + regtest: { net: { ...btc.TEST_NETWORK, bech32: 'bcrt' }, coin: 1 }, }; export function newMnemonic(strengthBits = 128) { @@ -192,7 +195,7 @@ export class Wallet { this.api = new ElectrumApi({ call: (m, p) => this._rpcCall(m, p), network: this.netCfg.net, - testnet: this.netName === 'testnet', + testnet: this.netName !== 'mainnet', explorerWeb: explorerWeb(), }); } else { @@ -1266,7 +1269,8 @@ export class Wallet { // and balances update with no polling. wsUrl() { // Electrum backend: pick the current failover candidate (rotated on failure). - if (getBackend() === 'electrum' && this.netName !== 'testnet') { + // Electrum is mainnet-only here; testnet/regtest use esplora + polling. + if (getBackend() === 'electrum' && this.netName === 'mainnet') { if (!this._wsCandidates || !this._wsCandidates.length) { this._wsCandidates = electrumCandidates(); this._wsCandIdx = 0; } const list = this._wsCandidates; return list.length ? list[(this._wsCandIdx || 0) % list.length] : null; -- cgit v1.2.3