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:
offchainFeeSatsin the Bark SDK,offchain_fee_satin 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
estimateRefreshFeeon the IDs thatgetVtxosToRefreshreturns (estimate_refresh_fee()andget_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 fromfeeSchedule.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.
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_thresholdblocks 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.
- Approaching expiry: Within
vtxo_refresh_expiry_thresholdplus 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.
- 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 andbark 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, orPOST /api/v1/wallet/refresh/vtxoson Barkd refreshes exactly that list. - Threshold only:
bark refreshwithout flags refreshes only the VTXOs inside the expiry threshold. - Counterparty risk only:
bark refresh --counterparty, orPOST /api/v1/wallet/refresh/counterpartyon Barkd, refreshes every VTXO with an out-of-round hop signed by a key your wallet doesn’t own, whatever its expiry.
How Bark Wallet does it
How Bark Wallet does it
- Fee line: Bark Wallet reads
offchainFeeSatsfrom 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
barkdsubmits every spendable VTXO. - Two paths in the installed version: The
barkddaemon 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.