Know who can force an exit
- Any previous owner of a spend VTXO: Everyone who held the VTXO earlier in its chain of Ark payments still holds the pre-signed exit transactions of the VTXO they paid from. They can broadcast them at any time. Once their VTXO’s output confirms, its
exit_deltatimelock starts. On Second’s Ark server, that owner can claim the output alone after 144 blocks, about 24 hours. The checkpoint transaction that spends it toward the user’s VTXO has to confirm first. The Ark server watches for these exits and broadcasts that checkpoint, so the user’s VTXO stays spendable off-chain. The user relies on the server acting honestly (Spend VTXOs explains the trust model). - Anyone holding the transaction that creates the VTXO: The previous sender, the Ark server, or a second install on the same mnemonic can broadcast the transaction whose output is the user’s VTXO. Only the user can claim that output. The server refuses further off-chain spends of a VTXO whose funding transaction is on-chain, so the wallet app has to exit and claim it. Another user’s exit in the same tree stops at the shared transactions and leaves the user’s VTXO off-chain.
- The Ark server, only after expiry: The server cannot take a VTXO before its
expiry_height. Routine maintenance refreshes VTXOs before that deadline.
exit_delta timelock. The Ark server runs that race for the user. Every other forced exit has one deadline, VTXO expiry. A forced exit has to confirm before expiry_height, because the server can then sweep the outputs its transactions spend. Each maintenance refresh replaces a VTXO with one that expires later.
Keep the response running and funded
Bark detects a forced exit of the user’s own VTXOs and responds on its own. Keep the wallet syncing, and give Bark an on-chain wallet that can pay the CPFP fees.1
Keep the wallet syncing
The background daemon scans for forced exits on every sync pass where the chain tip has moved. It syncs every 60 seconds by default and on every new block. The scan looks for any spendable VTXO whose own funding transaction has appeared on-chain or in the mempool and routes every hit into the emergency exit process. The daemon then progresses the exit on every interval.Without the daemon, as on the Bark CLI or with
runDaemon: false in the SDK, every maintenance pass runs the same scan, so your maintenance schedule is what covers detection. On the Bark CLI, schedule bark exit progress as well (maintenance shows the cron lines).2
Configure an on-chain wallet
Open the wallet with an on-chain wallet. Exit transactions pay no fees themselves. Bark fee-bumps them through CPFP children spent from the on-chain wallet.Decide when to fund it. Your app can hold confirmed bitcoin there as an exit reserve, sized with the exit fee estimate, so an exit moves as soon as it starts. Or it can count on the Ark server’s cooperation and ask the user for a deposit only when an exit needs one. That deposit has to confirm early enough for the exit to confirm before the VTXO’s
expiry_height.Paying exit fees from your own on-chain wallet
Paying exit fees from your own on-chain wallet
An app that pays fees from its own on-chain wallet can still fee-bump. In the native SDK bindings, create the on-chain wallet with
OnchainWallet.custom() and implement CustomOnchainWalletCallbacks. Bark calls its makeSignedP2aCpfp for each CPFP child when progressExits() or the background daemon runs. Bark calls it again with feesType set to Rbf to replace a child in the mempool that pays below the target feerate. In Rust, the app can instead call progress_exits() on the exit manager, read exits_needing_cpfp(), sign the child transactions itself, hand them back with provide_cpfp_tx(), then call progress_exits() again.The fee estimate doesn’t read the on-chain wallet, so it also works with an app-supplied callback wallet. Compare its exit_broadcast_fee_sat (exitBroadcastFeeSats in the SDK) with the confirmed balance of the wallet that pays the CPFP children.3
Watch for exit movements
Starting an exit records a movement, so a forced exit surfaces through the same notification stream as any other wallet event (maintenance lists the stream per surface). Treat a movement whose
input_vtxos (inputVtxoIds in the SDK) the user never chose to exit as the trigger to check exit status. After a lag event (ChannelLagging in the SDK, channel-lagging on the CLI and Barkd), reread the history for such movements.4
Monitor exit state until claimed
A forced exit moves through the same states as a user-started one. Until the background daemon claims exits on its own, the claim is your app’s call to make. Exit handling covers reading the state per surface and claiming.
5
Watch for the fee shortfall
When the on-chain wallet cannot cover a CPFP child, the background daemon retries on the next interval. Detect the shortfall and prompt the user for a deposit:
- Treat an exit that sits in
processingacross intervals while the confirmed on-chain balance is low as a fee shortfall. - Re-run the exit fee estimate for the exiting VTXOs. It prices only the transactions still unconfirmed.
- Prompt the user to send at least the estimate’s
exit_broadcast_fee_satminus the confirmed on-chain balance to the on-chain wallet. Only confirmed bitcoin counts, so prompt early enough for the deposit and the exit to confirm before the VTXO expires. - Escalate through push notifications or email if the app is closed. This is the one condition where user inaction can turn into loss.
Tell the user what is happening
Alert the user when Bark detects a forced exit, even when the wallet app can handle it unaided. Their bitcoin moved on-chain without their consent, so silence looks like a bug or a theft. Show three things while the exit runs:- The amount being recovered: The exiting sats appear in
pending_exit_satonce every exit transaction confirms (balances covers the display). - The unlock height:
allExitsClaimableAtHeight()in the Bark SDK (all_claimable_at_heighton the Rust exit manager) returns the latest unlock height among the exits whose transactions have all confirmed. CLI and Barkd progress responses carry it asclaimable_height. Render heights as approximate times. - The current state: Map the exit states to the same labels as exit handling, with copy that explains why this exit started without the user.
Copy your app can ship
Use this copy for each stage of a forced exit. It matches the state labels on exit handling. Replace the bracketed values from the exit status fields and the exit fee estimate.How Bark Wallet does it
How Bark Wallet does it
- Same UI as a user-started exit: Bark Wallet shows a forced exit with the same badges, polling, and history entry.
- Claim: Once the exit is claimable, it asks for a destination on its Settings page and auto-claims.
- Detection in both versions: The web version (WASM) syncs from its worker loop while a tab is open, so it finds a forced exit then. In the installed version, the
barkddaemon finds one on its first sync pass after a new block, with or without an open tab.