aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-01 19:38:30 -0700
committerAdam Soltys <[email protected]>2026-08-01 19:38:30 -0700
commit348a57004f94dd0f58c4e70769e65ca7ea3f7619 (patch)
tree5f8cd2930abd9c1e05bb7c18e0bec239780281ef /src/api.js
parent9196f4804851a87c8356418b1c4cade6e87c54ba (diff)
downloadcoinosv3-348a57004f94dd0f58c4e70769e65ca7ea3f7619.tar.gz
coinosv3-348a57004f94dd0f58c4e70769e65ca7ea3f7619.zip
Simplify: one Lightning path, one balance, fewer features
Dropped: silent payments (feature, wallet chains, scan worker, indexer config), Boltz submarine/reverse swaps (feature + swap.js + tools), the third-party ark swap bridge (config, client flows, settings card — the ASP's own Lightning send is the one path now), and the Consolidate coins settings action. The NWC pouch is gone with them: background answering now spends the WHOLE ark balance. The IndexedDB record mirrors the real manager state plus the chain-3 keys for its live coins and a change-index window; the worker pays through the ASP exactly like the open app, and the app folds the worker's spends, change, and key allocations back in on connect (additive merge + reconcile against the server). A leftover chain-6 pouch from the short-lived pouch era is swept home automatically using the keys stored in its own record. The stated tradeoff: same-origin script access now reaches the ark balance, not a carve-out — the ark balance is walking-around money, the on-chain wallet's keys are never mirrored, and per-connection NWC budgets remain the enforced ceiling. Bundle: 726KB -> 602KB. Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src/api.js')
-rw-r--r--src/api.js102
1 files changed, 0 insertions, 102 deletions
diff --git a/src/api.js b/src/api.js
index 8fefa5f..5824120 100644
--- a/src/api.js
+++ b/src/api.js
@@ -273,108 +273,6 @@ export function getArkConfig(net = getNetwork()) {
return cfg.ark && cfg.esplora ? cfg : null;
}
-// Ark->Lightning swap bridge — an optional third-party provider that pays
-// bolt11 invoices out of your Ark balance for less than the ASP charges. The
-// swap is trustless (funds are locked in an HTLC only the bridge can claim,
-// and only by revealing the invoice preimage), but it requires an ASP that
-// supports third-party HTLC vtxos. Off means bolt11 payments use the ASP's
-// own — pricier — lightning-send path.
-const BRIDGE_PRESETS_BY_NET = {
- mainnet: [
- { id: 'off', label: 'Off (use the ASP)', url: '' },
- { id: 'coinos', label: 'coinos (arkswap.coinos.io)', url: 'https://arkswap.coinos.io' },
- { id: 'custom', label: 'Custom…', url: '' },
- ],
- testnet: [{ id: 'off', label: 'Off (use the ASP)', url: '' }, { id: 'custom', label: 'Custom…', url: '' }],
- signet: [{ id: 'off', label: 'Off (use the ASP)', url: '' }, { id: 'custom', label: 'Custom…', url: '' }],
- mutinynet: [
- { id: 'off', label: 'Off (use the ASP)', url: '' },
- { id: 'coinos', label: 'coinos (arkswap-staging.coinos.io)', url: 'https://arkswap-staging.coinos.io' },
- { id: 'custom', label: 'Custom…', url: '' },
- ],
- regtest: [
- { id: 'off', label: 'Off (use the ASP)', url: '' },
- { id: 'local', label: 'Local (regtest)', url: 'http://localhost:8790' },
- { id: 'custom', label: 'Custom…', url: '' },
- ],
-};
-// Mainnet defaults to the coinos bridge: small bolt11 sends (zaps) are
-// unroutable through the ASP path, whose CLN fee budget is a fraction of the
-// ASP's own 3-sat minimum fee. The bridge runs open (no token) for this.
-const BRIDGE_DEFAULT = { mainnet: 'coinos', testnet: 'off', signet: 'off', mutinynet: 'off', regtest: 'off' };
-const BRIDGE_KEY = 'btc-wallet-ark-bridge'; // selected preset id, per network
-const BRIDGE_CUSTOM_KEY = 'btc-wallet-ark-bridge-custom'; // custom url, per network
-const BRIDGE_TOKEN_KEY = 'btc-wallet-ark-bridge-token'; // access token, per network
-
-export function bridgePresets(net = getNetwork()) {
- return BRIDGE_PRESETS_BY_NET[net] || BRIDGE_PRESETS_BY_NET.mainnet;
-}
-export function getBridgeProviderId(net = getNetwork()) {
- try {
- const id = localStorage.getItem(nk(BRIDGE_KEY, net));
- if (id && bridgePresets(net).some((p) => p.id === id)) return id;
- } catch {}
- return BRIDGE_DEFAULT[net] || 'off';
-}
-export function setBridgeProviderId(id, net = getNetwork()) {
- try { localStorage.setItem(nk(BRIDGE_KEY, net), id); } catch {}
-}
-export function getBridgeCustom(net = getNetwork()) {
- try { return localStorage.getItem(nk(BRIDGE_CUSTOM_KEY, net)) || ''; } catch { return ''; }
-}
-export function setBridgeCustom(url, net = getNetwork()) {
- try { localStorage.setItem(nk(BRIDGE_CUSTOM_KEY, net), (url || '').trim()); } catch {}
-}
-export function getBridgeToken(net = getNetwork()) {
- try { return localStorage.getItem(nk(BRIDGE_TOKEN_KEY, net)) || ''; } catch { return ''; }
-}
-export function setBridgeToken(tok, net = getNetwork()) {
- try { localStorage.setItem(nk(BRIDGE_TOKEN_KEY, net), (tok || '').trim()); } catch {}
-}
-// { url, token } when a bridge is configured, else null.
-export function getBridgeConfig(net = getNetwork()) {
- const id = getBridgeProviderId(net);
- if (id === 'off') return null;
- const p = bridgePresets(net).find((x) => x.id === id);
- const url = id === 'custom' ? getBridgeCustom(net) : p.url;
- return url ? { url: url.replace(/\/$/, ''), token: getBridgeToken(net) } : null;
-}
-
-// Silent-payment (BIP-352) tweak indexer — a separate, optional endpoint used
-// only for SP receiving. It serves public tweak/UTXO data (the scan key never
-// leaves the device), but a public one can observe which blocks hold your
-// outputs, so self-hosting is the privacy-max option. Per network; an empty URL
-// means SP receiving is unavailable on that network.
-const SP_INDEXER_PRESETS_BY_NET = {
- mainnet: [{ id: 'coinos', label: 'coinos', url: 'https://sp.coinos.io' }, { id: 'custom', label: 'Custom', url: '' }],
- testnet: [{ id: 'custom', label: 'Custom', url: '' }],
- signet: [{ id: 'custom', label: 'Custom', url: '' }],
- mutinynet: [{ id: 'custom', label: 'Custom', url: '' }],
- regtest: [{ id: 'local', label: 'Local (proxied)', url: '/sp' }, { id: 'custom', label: 'Custom', url: '' }],
-};
-const SP_INDEXER_DEFAULT = { mainnet: 'coinos', testnet: 'custom', signet: 'custom', mutinynet: 'custom', regtest: 'local' };
-const SP_INDEXER_KEY = 'btc-wallet-sp-indexer';
-export function spIndexerPresets(net = getNetwork()) { return SP_INDEXER_PRESETS_BY_NET[net] || SP_INDEXER_PRESETS_BY_NET.mainnet; }
-export function getSpIndexerConfig(net = getNetwork()) {
- try {
- const c = JSON.parse(localStorage.getItem(nk(SP_INDEXER_KEY, net)) || 'null');
- if (c && c.server) return { server: c.server, url: c.url || '' };
- } catch {}
- return { server: SP_INDEXER_DEFAULT[net] || 'custom', url: '' };
-}
-export function setSpIndexerConfig({ server, url }, net = getNetwork()) {
- try { localStorage.setItem(nk(SP_INDEXER_KEY, net), JSON.stringify({ server, url: url || '' })); } catch {}
-}
-// The resolved indexer base URL for a network, or '' if none is configured.
-export function spIndexerUrl(net = getNetwork()) {
- const cfg = getSpIndexerConfig(net);
- if (cfg.server === 'custom') return cfg.url.trim().replace(/\/+$/, '');
- const p = spIndexerPresets(net).find((x) => x.id === cfg.server);
- return p && p.url ? p.url.replace(/\/+$/, '') : '';
-}
-// SP receiving is available only when an indexer is configured for this network.
-export function spReceiveEnabled(net = getNetwork()) { return !!spIndexerUrl(net); }
-
// Resolve the configured explorer to the host list the Api tries in order.
function resolveHosts(net) {
const src = getSource(net);