aboutsummaryrefslogtreecommitdiffstats
path: root/tools/swap-e2e-submarine.test.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 /tools/swap-e2e-submarine.test.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 'tools/swap-e2e-submarine.test.js')
-rw-r--r--tools/swap-e2e-submarine.test.js56
1 files changed, 0 insertions, 56 deletions
diff --git a/tools/swap-e2e-submarine.test.js b/tools/swap-e2e-submarine.test.js
deleted file mode 100644
index 265721d..0000000
--- a/tools/swap-e2e-submarine.test.js
+++ /dev/null
@@ -1,56 +0,0 @@
-// End-to-end SUBMARINE swap (hal spends over Lightning) on regtest:
-// 1. `cl` issues an invoice (the payee/merchant)
-// 2. hal creates a submarine swap for it (refund key it controls)
-// 3. hal funds the on-chain lockup with expectedAmount (here: from bc)
-// 4. Boltz detects the lockup, pays the LN invoice, and claims the lockup
-// 5. the invoice is paid → hal's on-chain spend reached a LN payee
-// Proves swap creation + address + the funded-lockup → Boltz-pays path.
-// (Refund-path signing is the same buildSwapSpend validated by the reverse E2E.)
-// Run (stack up): bun tools/swap-e2e-submarine.test.js
-import { $ } from 'bun';
-import { secp256k1 } from '@noble/curves/secp256k1';
-import { ripemd160 } from '@noble/hashes/legacy';
-import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
-import { swapP2TR } from '../src/swap.js';
-
-const BOLTZ = 'http://localhost:9001';
-const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
-const post = async (p, b) => {
- const r = await fetch(BOLTZ + p, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(b) });
- const j = await r.json(); if (!r.ok) throw new Error(`${p}: ${JSON.stringify(j)}`); return j;
-};
-const bcli = (...a) => $`docker exec bc bitcoin-cli -regtest -rpcuser=admin1 -rpcpassword=123 ${a}`.text();
-const clcli = (...a) => $`docker exec cl lightning-cli --regtest ${a}`.text();
-
-// cl (payee) issues an invoice hal wants to pay.
-const amount = 120000;
-const inv = JSON.parse(await clcli('invoice', String(amount * 1000), `hal-${Date.now()}`, 'submarine test'));
-
-// hal's refund key + submarine swap.
-const refundPriv = secp256k1.utils.randomPrivateKey();
-const refundPub = secp256k1.getPublicKey(refundPriv, true);
-const swap = await post('/v2/swap/submarine', { invoice: inv.bolt11, from: 'BTC', to: 'BTC', refundPublicKey: bytesToHex(refundPub) });
-console.log('swap', swap.id, 'lockup', swap.address, 'expected', swap.expectedAmount);
-
-// Verify the lockup address before funding (don't-trust-verify).
-const d = swapP2TR({ kind: 'submarine', preimageHash160: ripemd160(hexToBytes(inv.payment_hash)), boltzPub33: hexToBytes(swap.claimPublicKey), halPub33: refundPub, lockTime: swap.timeoutBlockHeight, network: 'regtest' });
-if (d.address !== swap.address) throw new Error('address mismatch — abort');
-console.log('lockup address verified ✓');
-
-// Fund the lockup (in real hal this is wallet coin-selection; here: from bc).
-await bcli('-rpcwallet=coinos', 'sendtoaddress', swap.address, (swap.expectedAmount / 1e8).toFixed(8));
-const mineAddr = (await bcli('-rpcwallet=coinos', 'getnewaddress')).trim();
-await bcli('generatetoaddress', '1', mineAddr); // confirm (maxZeroConfAmount=0)
-console.log('lockup funded + confirmed; waiting for Boltz to pay the invoice…');
-
-// Boltz should detect the lockup, pay the LN invoice, and claim.
-let paid = false;
-for (let i = 0; i < 45; i++) {
- await sleep(1000);
- const ls = JSON.parse(await clcli('listinvoices'));
- const mine = ls.invoices?.find((x) => x.payment_hash === inv.payment_hash);
- if (mine?.status === 'paid') { paid = true; break; }
-}
-if (!paid) throw new Error('invoice not paid by Boltz within timeout');
-console.log(`\nPASS — Boltz paid hal's submarine invoice (${amount} sat) after the on-chain lockup. hal spent on-chain → LN payee.`);
-process.exit(0);