aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ark/refresh-test.js
diff options
context:
space:
mode:
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`);