Skip to main content

Put the fee on the movement

Build three things for it:
  • Render the fee line: A refresh records a movement whose fee field carries the fee: offchainFeeSats in the Bark SDK, offchain_fee_sat in Barkd and CLI output. Render it as a fee line like on any other movement rather than absorbing it silently.
  • Label it honestly: Call it a refresh fee, and never advertise maintenance refreshes as always free unless your Ark server’s fee schedule is all zero.
  • Estimate ahead: In the Bark SDK, call estimateRefreshFee on the IDs that getVtxosToRefresh returns (estimate_refresh_fee() and get_vtxos_to_refresh() in Rust) to price exactly the set the next pass would submit. On Barkd, price the refresh yourself from the selection rules and the schedule below.

Read the fee from your Ark server’s schedule

The Ark server prices every refresh from its published fee schedule, which your wallet app reads from feeSchedule.refresh in the SDK’s arkInfo(), or from fees.refresh in GET /api/v1/wallet/ark-info on Barkd. The schedule has two parts:
  • Base fee: A flat fee per refresh, when the schedule sets one.
  • Rate: A rate (in ppm) of each input VTXO’s amount, set by how far that VTXO is from expiry. The rate falls as expiry nears.
Nothing ties the free bracket to your vtxo_refresh_expiry_threshold. The brackets are server configuration. On Second’s Ark server (pricing): A VTXO refreshed at the default 144-block threshold therefore pays nothing there.

Expect bundled VTXOs to add to the fee

A maintenance pass first finds the VTXOs that need a refresh now:
  • Near or past expiry: Within vtxo_refresh_expiry_threshold blocks of expiry, or already past it.
  • At the depth limit: Exit depth at the server’s max_vtxo_exit_depth, past which the server does not co-sign further off-chain payments.
If none qualify, the pass refreshes nothing and costs nothing. If at least one does, the pass folds into the same round every VTXO that is unsafe or uneconomical to leave alone:
  • Approaching expiry: Within vtxo_refresh_expiry_threshold plus 28 blocks of expiry.
  • Approaching the depth limit: Exit depth at half the server’s maximum.
  • Uneconomical to exit: Worth less than the estimated cost of its own emergency exit at the current fast feerate.
  • Dust: Below 330 sats, too small to ever produce a valid on-chain output.
Expect the pass to carry a fee even when the VTXO that triggered it pays nothing:
  • Bundled VTXOs cost more: They typically have most of their lifetime left and land in a higher bracket.
  • Bundling is deliberate: Those VTXOs all need a refresh eventually, or the user cannot exit them safely at all. The wallet app is already joining a round.
  • The fee comes out of the refreshed amount: The user forfeits the old VTXOs and receives one new VTXO worth the total minus the fee. Bark refuses a refresh whose new VTXO would fall under 330 sats (surface the dust floor covers that case).

Refresh an explicit list when you want no bundling

Only the maintenance selection bundles. The bark library’s background daemon and bark maintain on the CLI use it. So do maintenance(), maintenanceDelegated(), and maintenanceRefresh() in the Bark SDK. To refresh without bundling, have the wallet app choose the inputs itself:
  • Explicit list: refreshVtxos(vtxoIds) in the Bark SDK, bark refresh --vtxo <id> on the CLI, or POST /api/v1/wallet/refresh/vtxos on Barkd refreshes exactly that list.
  • Threshold only: bark refresh without flags refreshes only the VTXOs inside the expiry threshold.
  • Counterparty risk only: bark refresh --counterparty, or POST /api/v1/wallet/refresh/counterparty on Barkd, refreshes every VTXO with an out-of-round hop signed by a key your wallet doesn’t own, whatever its expiry.
Each refresh takes at most 1,000 VTXOs, the ones that expire first. Run it again for the rest.
  • Fee line: Bark Wallet reads offchainFeeSats from the movement and shows it as a Fee line in the movement detail dialog. Refresh movements stay out of the history list until the user turns off “Hide refreshes”, which is on by default.
  • Labels: The movement is labeled “Ark: Refresh”. The Auto-refresh threshold options name their fee bracket, such as “1 day before expiry · free” or “7 days before expiry · 0.2% fee”. The user sees the price of refreshing earlier before selecting it.
  • Estimate: The Refresh all action prices the refresh client-side from the server’s fee schedule and shows “Estimated fee: X” before the user selects it. In the web version it submits every spendable VTXO not already in a round, the same set the estimate prices. In the installed version barkd submits every spendable VTXO.
  • Two paths in the installed version: The barkd daemon refreshes through the maintenance selection. A VTXO that reaches the threshold or the depth limit therefore pulls dust and uneconomical VTXOs along and can carry a fee. The app’s own auto-refresh submits only the spendable VTXOs inside the user’s threshold and bundles nothing.