diff options
| author | Adam Soltys <[email protected]> | 2026-10-07 08:21:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-07 08:21:41 -0700 |
| commit | bba8280a241ce86b0f372818d7aca85073d8e53a (patch) | |
| tree | 9fa806951bf81e394cc67264eb605a3546eaca8c /tools/ark | |
| parent | 52a39d014c03cdcc733ddc91af9d7acfee2ff27a (diff) | |
| download | coinosv3-bba8280a241ce86b0f372818d7aca85073d8e53a.tar.gz coinosv3-bba8280a241ce86b0f372818d7aca85073d8e53a.zip | |
ark board/refresh tests: current regtest chain and server rules
- mine/fund through the bc container (the standalone :18543 node was retired
in the July consolidation)
- board-test hands the server the funding tx (require_board_funding_tx) and
waits for esplora to see the board confirmed: bark silently drops a received
vtxo whose board tx it can't find yet
- refresh-test rounds the ppm fee up like the server (and the manager) do
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'tools/ark')
| -rw-r--r-- | tools/ark/board-test.js | 10 | ||||
| -rw-r--r-- | tools/ark/gift-shot.js | 2 | ||||
| -rw-r--r-- | tools/ark/refresh-test.js | 8 | ||||
| -rw-r--r-- | tools/ark/ui-test.js | 2 |
4 files changed, 15 insertions, 7 deletions
diff --git a/tools/ark/board-test.js b/tools/ark/board-test.js index 40cf0aa..b117fd0 100644 --- a/tools/ark/board-test.js +++ b/tools/ark/board-test.js @@ -28,7 +28,7 @@ const ARK = process.env.ARK_URL || 'http://127.0.0.1:3535'; const ESPLORA = process.env.ESPLORA_URL || 'http://127.0.0.1:30002'; const BARK = `${process.env.HOME}/bark/target/debug/bark`; const ALICE = `${BARK} --datadir ${process.env.HOME}/ark-regtest/alice`; -const BCLI = `bitcoin-cli -regtest -datadir=${process.env.HOME}/ark-regtest/bitcoind -rpcport=18543 -rpcwallet=miner`; +const BCLI = `docker exec bc bitcoin-cli -rpcwallet=coinos`; const BOARD_SAT = 30000; const SPEND_SAT = 5000; @@ -76,6 +76,7 @@ const nonces = musig2.nonceGen(keys.vtxo.pubkey, keys.vtxo.privkey, undefined, b const cosign = await requestBoardCosign(ARK, { amountSat: BOARD_SAT, fundingOutpointRaw, expiryHeight, userPub: keys.vtxo.pubkey, pubNonce: nonces.public, + fundingTxBytes: hex.decode(signed.hex), // require_board_funding_tx }); const finalSig = combineBoardSignature({ board, serverCosign: cosign, userNonces: nonces, vtxoKeys: keys.vtxo, serverPub }); console.log('✓ board exit tx MuSig2 signature combined and verified'); @@ -90,6 +91,13 @@ console.log(`board vtxo: ${vtxo.id} (${vtxo.amountSat} sat)`); // --- 4. confirm, register, prove spendability by paying alice --- execSync(`${BCLI} generatetoaddress 2 $(${BCLI} getnewaddress) >/dev/null`, { shell: '/bin/bash' }); +// bark validates received vtxos against esplora and silently DROPS ones whose +// board tx it can't see yet, so wait for the indexer before paying alice +for (let i = 0; i < 60; i++) { + const st = await fetch(`${ESPLORA}/tx/${fundingTxid}/status`).then((r) => r.ok ? r.json() : {}).catch(() => ({})); + if (st.confirmed) break; + await new Promise((r) => setTimeout(r, 500)); +} await new Promise((r) => setTimeout(r, 2000)); // let the server index the blocks console.log('mined 2 blocks (board confirmed)'); diff --git a/tools/ark/gift-shot.js b/tools/ark/gift-shot.js index 3ebb21f..aac6809 100644 --- a/tools/ark/gift-shot.js +++ b/tools/ark/gift-shot.js @@ -8,7 +8,7 @@ import { wordlist } from '@scure/bip39/wordlists/english'; const PORT = 5199; const APP = `http://localhost:${PORT}`; -const BCLI = `bitcoin-cli -regtest -datadir=${process.env.HOME}/ark-regtest/bitcoind -rpcport=18543 -rpcwallet=miner`; +const BCLI = `docker exec bc bitcoin-cli -rpcwallet=coinos`; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const sh = (cmd) => execSync(cmd, { shell: '/bin/bash' }).toString().trim(); diff --git a/tools/ark/refresh-test.js b/tools/ark/refresh-test.js index f23ee05..0557659 100644 --- a/tools/ark/refresh-test.js +++ b/tools/ark/refresh-test.js @@ -26,11 +26,10 @@ import { cosignHarkLeaf, requestForfeitNonces, forfeitBundle, forfeitVtxos, encodeVtxoFromDecoded, } from '../../src/ark/refresh.js'; +import { ALICE, aliceReady } from './alice.js'; const ARK = process.env.ARK_URL || 'http://127.0.0.1:3535'; -const BARK = `${process.env.HOME}/bark/target/debug/bark`; -const ALICE = `${BARK} --datadir ${process.env.HOME}/ark-regtest/alice`; -const BCLI = `bitcoin-cli -regtest -datadir=${process.env.HOME}/ark-regtest/bitcoind -rpcport=18543 -rpcwallet=miner`; +const BCLI = `docker exec bc bitcoin-cli -rpcwallet=coinos`; const FUND_SAT = 12345; const SPEND_SAT = 3000; @@ -51,6 +50,7 @@ const blinded = blindMailboxId(keys.mailbox.pubkey, hex.decode(info.mailboxPubke const addr = encodeAddress({ testnet: true, serverPubkey: serverPub, userPubkey: keys.vtxo.pubkey, blindedMailboxId: blinded, }); +await aliceReady(); execSync(`${ALICE} -q send ${addr} "${FUND_SAT} sat"`, { stdio: 'ignore' }); let input = null; for (let i = 0; i < 10 && !input; i++) { @@ -67,7 +67,7 @@ console.log(`input vtxo: ${input.id} (${input.amountSat} sat, expiry ${input.exp const tipNow = Number(execSync(`${BCLI} getblockcount`).toString().trim()); const expiryBlocks = input.expiryHeight - tipNow; const entry = info.refreshFees.ppmExpiryTable.filter((e) => e.thresholdBlocks <= expiryBlocks).pop(); -const fee = info.refreshFees.baseFeeSat + Math.floor((input.amountSat * (entry?.ppm ?? 0)) / 1_000_000); +const fee = info.refreshFees.baseFeeSat + Math.ceil((input.amountSat * (entry?.ppm ?? 0)) / 1_000_000); // server rounds the ppm part up const outputs = [{ amountSat: input.amountSat - fee, userPubkey: keys.vtxo.pubkey }]; console.log(`refresh fee: ${fee} sat (ppm ${entry?.ppm}, ${expiryBlocks} blocks to expiry) -> requesting ${outputs[0].amountSat} sat`); diff --git a/tools/ark/ui-test.js b/tools/ark/ui-test.js index 232e742..910c12b 100644 --- a/tools/ark/ui-test.js +++ b/tools/ark/ui-test.js @@ -16,7 +16,7 @@ const PORT = 5199; const APP = `http://localhost:${PORT}`; const BARK = `${process.env.HOME}/bark/target/debug/bark`; const ALICE = `${BARK} --datadir ${process.env.HOME}/ark-regtest/alice`; -const BCLI = `bitcoin-cli -regtest -datadir=${process.env.HOME}/ark-regtest/bitcoind -rpcport=18543 -rpcwallet=miner`; +const BCLI = `docker exec bc bitcoin-cli -rpcwallet=coinos`; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const sh = (cmd) => execSync(cmd, { shell: '/bin/bash' }).toString().trim(); |
