aboutsummaryrefslogtreecommitdiffstats
path: root/src/sp-worker.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/sp-worker.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/sp-worker.js')
-rw-r--r--src/sp-worker.js69
1 files changed, 0 insertions, 69 deletions
diff --git a/src/sp-worker.js b/src/sp-worker.js
deleted file mode 100644
index 59a1769..0000000
--- a/src/sp-worker.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// Web Worker: the EC-heavy silent-payment crypto, kept off the main thread so a
-// large scan never janks the UI. Memoizes per tweak (a tweak's outcome is fixed),
-// so repeated mempool pushes — which re-send the same tweaks — stay cheap.
-//
-// Protocol (request/response by id):
-// { id, op:'keys', scanPriv, spendPub } → { id, ok:true }
-// { id, op:'candidates', blocks:[{height,tweaks,filter}] } → { id, hits:[height] }
-// { id, op:'scan', items:[{txid,tweak,outputs}] } → { id, found:[utxo] }
-
-import { hex } from '@scure/base';
-import { silentPaymentScan, silentPaymentCandidate, bloomHas } from './silentpay.js';
-
-let scanPriv = null;
-let spendPub = null;
-const scanCache = new Map(); // tweakHex -> matches
-const candCache = new Map(); // tweakHex -> candidate x-only hex
-
-self.onmessage = (e) => {
- const { id, op } = e.data;
- try {
- if (op === 'keys') {
- scanPriv = e.data.scanPriv;
- spendPub = e.data.spendPub;
- scanCache.clear();
- candCache.clear();
- self.postMessage({ id, ok: true });
- return;
- }
- if (op === 'candidates') {
- // Return the heights of blocks whose Bloom filter could contain one of our
- // outputs (derive a candidate per tweak, test the filter, stop on first hit).
- const hits = [];
- for (const b of e.data.blocks) {
- for (const tw of b.tweaks) {
- let c = candCache.get(tw);
- if (!c) {
- if (candCache.size > 100000) candCache.clear();
- c = silentPaymentCandidate({ scanPriv, spendPub, tweak: hex.decode(tw) });
- candCache.set(tw, c);
- }
- if (bloomHas(b.filter, c)) { hits.push(b.height); break; }
- }
- }
- self.postMessage({ id, hits });
- return;
- }
- if (op === 'scan') {
- // Full scan: return resolved utxos {txid,vout,value,xonly,tweak} for ours.
- const found = [];
- for (const it of e.data.items) {
- let m = scanCache.get(it.tweak);
- if (!m) {
- if (scanCache.size > 100000) scanCache.clear();
- m = silentPaymentScan({ scanPriv, spendPub, tweak: hex.decode(it.tweak), outputs: it.outputs.map((o) => o.xonly) });
- scanCache.set(it.tweak, m);
- }
- for (const mm of m) {
- const o = it.outputs.find((x) => x.xonly === mm.output);
- if (o) found.push({ txid: it.txid, vout: o.vout, value: o.value, xonly: mm.output, tweak: mm.tweak });
- }
- }
- self.postMessage({ id, found });
- return;
- }
- self.postMessage({ id, error: 'unknown op ' + op });
- } catch (err) {
- self.postMessage({ id, error: String((err && err.message) || err) });
- }
-};