From 348a57004f94dd0f58c4e70769e65ca7ea3f7619 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 19:38:30 -0700 Subject: Simplify: one Lightning path, one balance, fewer features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tools/swap-e2e-reverse.test.js | 78 ------------------------------------------ 1 file changed, 78 deletions(-) delete mode 100644 tools/swap-e2e-reverse.test.js (limited to 'tools/swap-e2e-reverse.test.js') diff --git a/tools/swap-e2e-reverse.test.js b/tools/swap-e2e-reverse.test.js deleted file mode 100644 index e3cd082..0000000 --- a/tools/swap-e2e-reverse.test.js +++ /dev/null @@ -1,78 +0,0 @@ -// End-to-end REVERSE swap (hal receives over Lightning) on regtest: -// 1. hal requests a reverse swap (preimage it controls) -// 2. coinos `cl` pays the hold invoice (HTLC locked) -// 3. Boltz locks funds on-chain to the swap address -// 4. hal claims them on-chain via the taproot SCRIPT PATH (preimage + sig) -// 5. Boltz extracts the preimage, settles the LN payment -// Proves buildSwapSpend (reverse claim) against the live stack. -// Run (stack up): bun tools/swap-e2e-reverse.test.js -import { $ } from 'bun'; -import { secp256k1 } from '@noble/curves/secp256k1'; -import * as btc from '@scure/btc-signer'; -import { sha256 } from '@noble/hashes/sha2'; -import { randomBytes, bytesToHex, hexToBytes } from '@noble/hashes/utils'; -import { hash160, swapP2TR, buildSwapSpend, REGTEST } from '../src/swap.js'; - -const BOLTZ = 'http://localhost:9001'; -const ESPLORA = 'http://localhost:3000'; -const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); -const jget = async (u) => { const r = await fetch(u); return r.ok ? r.json() : null; }; -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; -}; - -// hal's claim key, preimage, and a destination address it controls. -const claimPriv = secp256k1.utils.randomPrivateKey(); -const claimPub = secp256k1.getPublicKey(claimPriv, true); -const preimage = randomBytes(32); -const destPriv = secp256k1.utils.randomPrivateKey(); -const destAddr = btc.p2wpkh(secp256k1.getPublicKey(destPriv, true), REGTEST).address; - -const amount = 120000; -const swap = await post('/v2/swap/reverse', { - invoiceAmount: amount, from: 'BTC', to: 'BTC', - claimPublicKey: bytesToHex(claimPub), preimageHash: bytesToHex(sha256(preimage)), -}); -console.log('swap', swap.id, 'lockup', swap.lockupAddress, 'onchain', swap.onchainAmount); - -const boltzPub = hexToBytes(swap.refundPublicKey); -const d = swapP2TR({ kind: 'reverse', preimageHash160: hash160(preimage), boltzPub33: boltzPub, halPub33: claimPub, lockTime: swap.timeoutBlockHeight, network: 'regtest' }); -if (d.address !== swap.lockupAddress) throw new Error('address mismatch — abort'); - -// Pay the hold invoice from cl (backgrounded — it stays pending until we claim). -console.log('paying hold invoice from cl…'); -Bun.spawn(['docker', 'exec', 'cl', 'lightning-cli', '--regtest', 'pay', swap.invoice], { stdout: 'ignore', stderr: 'ignore' }); - -// Wait for Boltz to lock funds on-chain to the swap address. -let utxo = null; -for (let i = 0; i < 40; i++) { - await sleep(1000); - const us = await jget(`${ESPLORA}/address/${swap.lockupAddress}/utxo`); - if (us && us.length) { utxo = us[0]; break; } -} -if (!utxo) throw new Error('lockup not seen on-chain (esplora)'); -console.log('lockup utxo', utxo.txid, 'vout', utxo.vout, 'value', utxo.value); - -// Claim it on-chain via the script path. -const fee = 300; -const claimHex = buildSwapSpend({ - pay: d.pay, leaf: d.claimLeaf, halPriv: claimPriv, preimage, - lockupTxid: utxo.txid, lockupVout: utxo.vout, lockupValue: utxo.value, - destAddress: destAddr, fee, network: 'regtest', -}); -const br = await fetch(`${ESPLORA}/tx`, { method: 'POST', body: claimHex }); -const claimTxid = await br.text(); -if (!br.ok) throw new Error('broadcast failed: ' + claimTxid); -console.log('claim broadcast', claimTxid); - -// Verify hal's destination received the funds. -let got = null; -for (let i = 0; i < 15; i++) { - await sleep(1000); - const us = await jget(`${ESPLORA}/address/${destAddr}/utxo`); - if (us && us.length) { got = us[0]; break; } -} -if (!got) throw new Error('destination did not receive claim'); -console.log(`\nPASS — hal received ${got.value} sat on-chain at ${destAddr} (reverse swap claimed via script path)`); -process.exit(0); -- cgit v1.2.3