diff options
Diffstat (limited to 'tools/ark/board-test.js')
| -rw-r--r-- | tools/ark/board-test.js | 10 |
1 files changed, 9 insertions, 1 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)'); |
