aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ark/refresh-test.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-07 09:13:31 -0700
committerAdam Soltys <[email protected]>2026-10-07 09:13:31 -0700
commit95b72a73545cd2a3700b0e0866eee54e59d3b50e (patch)
tree81cc50c71d5e6cb78beaa1a7f755a23691f8983f /tools/ark/refresh-test.js
parent3aff6e4cc9eb97fc0fa488f1f95001f69f24330a (diff)
parentdf87bd84560fec4b085b6f0f4785b61502ffd480 (diff)
downloadcoinosv3-95b72a73545cd2a3700b0e0866eee54e59d3b50e.tar.gz
coinosv3-95b72a73545cd2a3700b0e0866eee54e59d3b50e.zip
Merge branch 'worktree-agent-a9ba2f8bea9a7dafc'
Diffstat (limited to 'tools/ark/refresh-test.js')
-rw-r--r--tools/ark/refresh-test.js8
1 files changed, 4 insertions, 4 deletions
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`);