diff options
| author | Adam Soltys <[email protected]> | 2026-06-27 08:40:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-27 08:40:41 -0700 |
| commit | a9a903e7a1f80ed4a6f4163419b25d4e6de5db01 (patch) | |
| tree | 8598b89bfd414b7fb4323fee506bcdb98dfb1143 /src/wallet.js | |
| parent | 291e03eb15a97fdaaa18537cc4a811b6e6004a8f (diff) | |
| download | coinosv3-a9a903e7a1f80ed4a6f4163419b25d4e6de5db01.tar.gz coinosv3-a9a903e7a1f80ed4a6f4163419b25d4e6de5db01.zip | |
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 <[email protected]>
Diffstat (limited to 'src/wallet.js')
| -rw-r--r-- | src/wallet.js | 8 |
1 files changed, 6 insertions, 2 deletions
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; |
