aboutsummaryrefslogtreecommitdiffstats
path: root/tools/swap-live.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-live.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-live.test.js')
-rw-r--r--tools/swap-live.test.js57
1 files changed, 0 insertions, 57 deletions
diff --git a/tools/swap-live.test.js b/tools/swap-live.test.js
deleted file mode 100644
index f56105a..0000000
--- a/tools/swap-live.test.js
+++ /dev/null
@@ -1,57 +0,0 @@
-// Live integration check against the local Boltz (http://localhost:9001) +
-// regtest CLN. Confirms Hal's locally-derived swap address + tapleaves match
-// Boltz's lockupAddress + swapTree for BOTH flows — proving the MuSig2
-// internal-key order ([boltzKey, halKey]), the taptweak, and leaf construction.
-// Run (regtest Boltz stack up): bun tools/swap-live.test.js
-import { $ } from 'bun';
-import { secp256k1 } from '@noble/curves/secp256k1';
-import { sha256 } from '@noble/hashes/sha2';
-import { ripemd160 } from '@noble/hashes/legacy';
-import { randomBytes, bytesToHex, hexToBytes } from '@noble/hashes/utils';
-import { hash160, swapP2TR, buildSwapTree } from '../src/swap.js';
-
-const BOLTZ = process.env.BOLTZ_API || 'http://localhost:9001';
-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} -> ${r.status} ${JSON.stringify(j)}`);
- return j;
-};
-const kp = () => { const sk = secp256k1.utils.randomPrivateKey(); return { sk, pk: secp256k1.getPublicKey(sk, true) }; };
-let fail = 0;
-const eq = (n, g, w) => { if (g === w) console.log(` ok ${n}`); else { fail++; console.log(`FAIL ${n}\n got: ${g}\n want: ${w}`); } };
-
-// ---------- REVERSE (hal receives over LN; hal claims) ----------
-{
- const claim = kp();
- const preimage = randomBytes(32);
- const res = await post('/v2/swap/reverse', {
- invoiceAmount: 100000, from: 'BTC', to: 'BTC',
- claimPublicKey: bytesToHex(claim.pk), preimageHash: bytesToHex(sha256(preimage)),
- });
- const boltzPub = hexToBytes(res.refundPublicKey); // Boltz refunds on reverse
- const d = swapP2TR({ kind: 'reverse', preimageHash160: hash160(preimage), boltzPub33: boltzPub, halPub33: claim.pk, lockTime: res.timeoutBlockHeight, network: 'regtest' });
- eq('reverse lockup address', d.address, res.lockupAddress);
- eq('reverse claim leaf', bytesToHex(d.claimLeaf), res.swapTree.claimLeaf.output);
- eq('reverse refund leaf', bytesToHex(d.refundLeaf), res.swapTree.refundLeaf.output);
-}
-
-// ---------- SUBMARINE (hal spends over LN; hal refunds) ----------
-{
- const inv = JSON.parse(await $`docker exec clb lightning-cli --regtest invoice 100000000 hal-sub-${Date.now()} test`.text());
- const payHash = inv.payment_hash;
- const refund = kp(); // hal's refund key
- const res = await post('/v2/swap/submarine', {
- invoice: inv.bolt11, from: 'BTC', to: 'BTC', refundPublicKey: bytesToHex(refund.pk),
- });
- const boltzPub = hexToBytes(res.claimPublicKey); // Boltz claims on submarine
- // tapscript embeds hash160(preimage) = ripemd160(payment_hash)
- const ph160 = ripemd160(hexToBytes(payHash));
- const d = swapP2TR({ kind: 'submarine', preimageHash160: ph160, boltzPub33: boltzPub, halPub33: refund.pk, lockTime: res.timeoutBlockHeight, network: 'regtest' });
- eq('submarine lockup address', d.address, res.address);
- eq('submarine claim leaf', bytesToHex(d.claimLeaf), res.swapTree.claimLeaf.output);
- eq('submarine refund leaf', bytesToHex(d.refundLeaf), res.swapTree.refundLeaf.output);
-}
-
-console.log(fail ? `\n${fail} FAILED` : '\nall good');
-process.exit(fail ? 1 : 0);