Skip to main content
An unresponsive Ark server leaves your wallet app one route: an emergency exit. Respond to forced exits covers exits someone else forces.

Reach for offboarding first

Reserve emergency exits for a server that is unresponsive or uncooperative. Under normal conditions, a cooperative offboard gets bitcoin back on-chain in a single transaction, cheaper and simpler than an exit (on-chain payments covers the calls).

Start the exit

Starting an exit marks the VTXOs for exit. Nothing reaches the chain yet.
  • startExitForEntireWallet() exits every VTXO in the wallet.
  • startExitForVtxos(vtxoIds) exits a chosen set.
  • cancelExit(vtxoId) aborts one exit.
Five behaviors to account for:
  • Exiting the whole wallet also exits locked VTXOs: Bark takes every unspent VTXO, including those locked in an in-flight send, Lightning payment, or round.
  • Dust and non-standard VTXOs stay out of an exit: The whole-wallet call skips them with a warning. The exit can then start with fewer VTXOs than the wallet holds, or none at all. Handle the error that the chosen-set call returns when the set includes one.
  • Cancel works until the final transaction is broadcast: The VTXO stays spendable after a cancel, even if shared ancestor transactions already reached the chain. Bark refuses the cancel once the exit is past its abortable window or its final transaction reached the mempool or the chain. The SDK’s cancelExit reports that refusal in its result (canceled is false, with a reason), not as an error. Canceling twice is a no-op.
  • Movements stay pending until the end: Starting an exit records one movement per VTXO. It stays pending until the exit reaches claimed, which finishes it as successful, or vtxo-already-spent or canceled, which finish it as canceled. An exit that ends in vtxo-swept leaves its movement pending, so read its outcome from the exit state. Track progress through the exit states below, not through the movements.
  • An exit must confirm before the VTXO expires: After expiry_height, the Ark server’s sweep can invalidate any exit transaction that has not confirmed yet (VTXO lifetime). Refresh an expired VTXO instead.

Fund the fees, then progress until done

Exit transactions pay no fees themselves. Bark fee-bumps them with CPFP children paid from the on-chain wallet, so your app must fund that wallet before the exit can move.
1

Price the exit with the fee estimate

Price the VTXOs you are about to exit:
Call estimateEmergencyExitFee with the VTXO IDs. Leave the feerate, destination, or fee margin empty (null, nil, or undefined, depending on the language) to use its default. An empty list prices every spendable VTXO. It leaves out the locked VTXOs that a whole-wallet exit includes. The fields below come back as exitBroadcastFeeSats, claimFeeSats, and totalFeeSats. Ignore the deprecated fundable. In Rust, Wallet::estimate_emergency_exit_fee prices exactly the IDs you pass, so an empty list returns a zero estimate.
Read two fields:
  • exit_broadcast_fee_sat: The CPFP fees paid from the confirmed on-chain balance while the exit runs. This is the amount to fund.
  • claim_fee_sat: The fee of the final claim transaction, taken out of the recovered bitcoin. It needs no on-chain balance.
Handle the error that the estimate returns for a dust, non-standard, unknown, spent, or already exited VTXO. A whole-wallet estimate returns that error when one spendable VTXO is dust or non-standard. Present total_fee_sat as an estimate. The final cost depends on the feerates when each transaction is broadcast.
Check the on-chain balance before the exit starts, not after it stalls. Disable the start action while the confirmed on-chain balance is below exit_broadcast_fee_sat.
Screenshot of the Bark Wallet emergency exit dialog with a confirmed on-chain balance of 0 sats and a disabled Start emergency exit button

Bark Wallet disables the start button while the confirmed on-chain balance is below the exit broadcast fee

2

Fund the on-chain wallet

Send at least exit_broadcast_fee_sat to the on-chain wallet, and wait for it to confirm. Get the address from bark onchain address on the CLI, from POST /api/v1/onchain/addresses/next on Barkd, or from the on-chain wallet your SDK app opened Bark with. Only confirmed bitcoin funds the CPFP children.
3

Progress the exit

The background daemon progresses exits while it runs. Call progressExits to force a step, or on your own schedule while the daemon is off (background refresh covers mobile wakes). It takes one setting, a feerate. Leave it empty to use Bark’s default exit feerate.
4

Monitor until done

The CLI and Barkd progress responses carry three signals:
  • done: True once no exit is left in start, processing, or awaiting-delta.
  • claimable_height: The latest unlock height among the exits whose transactions have all confirmed. It stays null until one reaches awaiting-delta and ignores exits still in start or processing, so read it together with done.
  • error, per exit: How your app tells a failed run from one that made no headway. When the whole run fails, bark exit progress fills a top-level error and Barkd answers a 500.
The Bark SDK returns one status per exit instead. Call allExitsClaimableAtHeight() for the unlock height.

Track exit states in the UI

Each exiting VTXO moves through a state machine.
Diagram of the six exit states from start to claimed and the three states where an exit ends earlyDiagram of the six exit states from start to claimed and the three states where an exit ends early

Your wallet app pays CPFP fees while the exit transactions confirm and, until the background daemon claims on its own, makes the claim call once the exit is claimable

getExitStatus takes a VTXO ID and two flags, includeHistory and includeTransactions, and returns that VTXO’s state. listClaimableExits() returns the VTXOs ready to claim.
Map the states to labels users understand: From awaiting-delta until the claim completes, the exiting sats show in pending_exit_sat. Balances covers how to display that field.

Claim to the on-chain wallet

Once a VTXO is claimable, claim it to an on-chain address:
Call drainExits with drainAll set to true and an empty vtxoIds list to claim every claimable VTXO, or with vtxoIds to claim a chosen set. It returns the signed claim transaction as a PSBT. Extract the final transaction with extractTxFromPsbt and broadcast it with broadcastTx.
Until the background daemon claims exits on its own, your app must make this call. After the claim transaction confirms, the bitcoin is ordinary on-chain bitcoin and follows your normal on-chain backup rules.
Until the claim confirms, the exit depends on the wallet databaseWhich exit transactions were broadcast, their CPFP children, and each VTXO’s state live only in the local wallet database. The mnemonic does not bring them back. A wallet restored from the mnemonic alone resumes an exit only once that VTXO’s own transaction is on-chain or in the mempool. Keep a continuous backup running through the whole exit, and back up anything your app stores outside that database, such as the claim destination. Restore a wallet lists what each restore path brings back.

Keep automation and chain access in place

  • Progress in the background: Once a user triggers an exit, your app progresses it with no further involvement from them. Automated wallet management lists what users should never do by hand.
  • Keep the chain source reachable: An emergency exit never contacts the Ark server. Progressing one needs Esplora or bitcoind to broadcast transactions and watch confirmations.
  • Plan for partial completion: A partially completed exit behaves differently from a finished one. Factor it into any cancellation option you offer.
  • Entry points: “Emergency exit all” in the Danger zone of the Settings page, and “Emergency Exit” for VTXOs selected in the VTXOs table. Both open the same start dialog.
  • Destination first: The dialog asks for the destination address before anything is broadcast and stores it per VTXO ID. It warns that the user cannot cancel an exit once it starts, a stricter rule than the library’s, and keeps the destination editable until the claim is broadcast.
  • Cost check: The dialog shows the total from Bark’s exit fee estimate next to the confirmed on-chain balance. It disables the start button while that balance is below the estimate’s exit broadcast fee and shows “You don’t have enough on-chain bitcoin to cover the exit fees. Deposit more to continue.”
  • Progress and claim: While an exit is live, the app polls exit status every 10 seconds on every page and claims each claimable VTXO to its stored destination. The installed version leaves progress to barkd. The web version (WASM) progresses exits from its worker loop. The progress card labels the phases Starting, Broadcasting, Timelocked, Ready to claim, Claiming, and Claimed (Follow the exit to completion).
  • After a restore: The claim destination lives outside the wallet database. Once an exit is claimable, a restored wallet shows “Add address to claim” on the progress card until the user enters one again.