diff options
| author | Adam Soltys <[email protected]> | 2026-08-01 19:38:30 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-01 19:38:30 -0700 |
| commit | 348a57004f94dd0f58c4e70769e65ca7ea3f7619 (patch) | |
| tree | 5f8cd2930abd9c1e05bb7c18e0bec239780281ef /tools/swap-manager.test.js | |
| parent | 9196f4804851a87c8356418b1c4cade6e87c54ba (diff) | |
| download | coinosv3-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-manager.test.js')
| -rw-r--r-- | tools/swap-manager.test.js | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/tools/swap-manager.test.js b/tools/swap-manager.test.js deleted file mode 100644 index 7a83be1..0000000 --- a/tools/swap-manager.test.js +++ /dev/null @@ -1,43 +0,0 @@ -// Drives the SwapManager reverse flow end-to-end with a minimal wallet shim: -// startReverse -> pay the hold invoice from cl -> manager auto-claims on-chain. -// Run (stack up): bun tools/swap-manager.test.js -import { HDKey } from '@scure/bip32'; -import * as btc from '@scure/btc-signer'; -import { secp256k1 } from '@noble/curves/secp256k1'; -import { randomBytes } from '@noble/hashes/utils'; -import { SwapManager, REGTEST } from '../src/swap.js'; - -const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); -const ESPLORA = 'http://localhost:3000'; -// Fresh random seed per run (real wallet persists swaps so swapNode indices -// increment; this shim's store is in-memory, so randomize to avoid preimage reuse). -const acct = HDKey.fromMasterSeed(randomBytes(64)).derive("m/84'/1'/0'"); - -let store = []; -const wallet = { - loadSwaps: () => store, - saveSwaps: (l) => { store = l; }, - nextSwapIndex: () => store.reduce((m, s) => Math.max(m, (s.swapIndex ?? -1) + 1), 0), - swapNode: (i) => acct.deriveChild(2).deriveChild(i), - freshReceive: () => ({ address: btc.p2wpkh(secp256k1.getPublicKey(acct.deriveChild(0).deriveChild(7).privateKey, true), REGTEST).address }), - api: { - addressUtxos: async (a) => { const r = await fetch(`${ESPLORA}/address/${a}/utxo`); return r.ok ? r.json() : []; }, - broadcast: async (hex) => { const r = await fetch(`${ESPLORA}/tx`, { method: 'POST', body: hex }); const t = await r.text(); if (!r.ok) throw new Error(t); return t; }, - }, -}; - -const sm = new SwapManager({ wallet, network: 'regtest', getApi: () => 'http://localhost:9001', feeRate: 2, onUpdate: () => {} }); -const rec = await sm.startReverse(120000); -console.log('startReverse ->', rec.id, rec.status, 'lockup', rec.lockupAddress); - -console.log('paying hold invoice from cl…'); -Bun.spawn(['docker', 'exec', 'cl', 'lightning-cli', '--regtest', 'pay', rec.invoice], { stdout: 'ignore', stderr: 'ignore' }); - -for (let i = 0; i < 60; i++) { - await sleep(1000); - const r = sm.list().find((s) => s.id === rec.id); - if (r.status === 'claimed') { console.log(`\nPASS — SwapManager auto-claimed: ${r.received} sats, txid ${r.claimTxid}`); process.exit(0); } - if (r.lastError && i % 5 === 0) console.log(' …', r.lastError); -} -console.log('FAIL — not claimed:', JSON.stringify(sm.list())); -process.exit(1); |
