aboutsummaryrefslogtreecommitdiffstats
path: root/migrator/server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-12-04 13:24:16 -0700
committerAdam Soltys <[email protected]>2026-12-04 13:24:16 -0700
commit6ed67f1c8d9f552cbcbe5c149f25470da4916f05 (patch)
tree383a5dcf2cc665e19b737ca75252ee843e39628e /migrator/server.js
parentc13388dc345f74b194eb106680a0cf9cf6da013f (diff)
downloadcoinosv3-server-6ed67f1c8d9f552cbcbe5c149f25470da4916f05.tar.gz
coinosv3-server-6ed67f1c8d9f552cbcbe5c149f25470da4916f05.zip
migrator: board the float from any wallet (finds the board output in the funding tx).
The funding tx for the float's board comes from an ordinary wallet, which may put change first. /admin/board remembers each board's address and amount; /admin/board/complete looks the tx up on esplora, finds the output paying exactly that to that address, and boards from that vout (409 until esplora has seen the tx). e2e: the float board is funded with change first (vout 1) — 20/20 pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar
Diffstat (limited to 'migrator/server.js')
-rw-r--r--migrator/server.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/migrator/server.js b/migrator/server.js
index 8b1f8fe..cf654ef 100644
--- a/migrator/server.js
+++ b/migrator/server.js
@@ -196,12 +196,25 @@ Bun.serve({
// float liquidity on the new server: board on-chain coins into it
if (req.method === 'POST' && p === '/admin/board') {
const { amountSat } = await req.json();
- return json(await newW.startBoard(Number(amountSat)));
+ const b = await newW.startBoard(Number(amountSat));
+ (state.boards ||= {})[b.actionId] = { fundingAddress: b.fundingAddress, amountSat: Number(amountSat) };
+ persist();
+ return json(b);
}
+ // { actionId, txid }: the funding tx may come from any wallet, so find
+ // the output paying the board address (exact amount) rather than
+ // assuming it's the first.
if (req.method === 'POST' && p === '/admin/board/complete') {
const { actionId, txid } = await req.json();
- const a = await newW.completeBoard(actionId, txid);
- return json({ step: a.step, error: a.lastError || null });
+ const b = state.boards?.[actionId];
+ if (!b) return json({ error: 'unknown board' }, 404);
+ const r = await fetch(`${CFG.new.esplora}/tx/${txid}`);
+ if (!r.ok) return json({ error: `funding tx ${txid} not seen by ${CFG.new.esplora} yet — try again shortly` }, 409);
+ const tx = await r.json();
+ const vout = tx.vout.findIndex((o) => o.scriptpubkey_address === b.fundingAddress && o.value === b.amountSat);
+ if (vout < 0) return json({ error: `no output of exactly ${b.amountSat} sat to ${b.fundingAddress} in ${txid}` }, 400);
+ const a = await newW.completeBoard(actionId, txid, vout);
+ return json({ step: a.step, vout, confs: a.confs ?? null, error: a.lastError || null });
}
if (req.method === 'GET' && p === '/admin/float-address') return json({ address: newW.address() });
}