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.
Bark SDK
Bark CLI
Barkd
startExitForEntireWallet() exits every VTXO in the wallet.
startExitForVtxos(vtxoIds) exits a chosen set.
cancelExit(vtxoId) aborts one exit.
bark exit start --all
Pass --vtxo <VTXO_ID> (repeatable) instead of --all to exit a chosen set. bark exit cancel <VTXO_ID> aborts one exit.
POST /api/v1/exits/start/all exits every VTXO in the wallet.
POST /api/v1/exits/start/vtxos with a list of VTXO IDs exits a chosen set.
POST /api/v1/exits/cancel/{vtxo_id} 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:
Bark SDK
Bark CLI
Barkd
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.
bark exit estimate-fee --all
Pass --vtxo <VTXO_ID> (repeatable) instead of --all to price a chosen set.
Call GET /api/v1/exits/fee, with a comma-separated vtxo_ids for a chosen set or without it for every spendable VTXO, with the same limit as the SDK.
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.
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
Bark SDK
Bark CLI
Barkd
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.
bark exit progress --wait
The command retries every 60 seconds until done turns true, which can take hours or days.
Barkd progresses registered exits on its own. Call POST /api/v1/exits/progress to force a step.
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.
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
Bark SDK
Bark CLI
Barkd
getExitStatus takes a VTXO ID and two flags, includeHistory and includeTransactions, and returns that VTXO’s state. listClaimableExits() returns the VTXOs ready to claim.
bark exit status <VTXO_ID> prints one VTXO’s state, and bark exit list every live exit. Pass --include-finished to include exits that reached claimed, vtxo-already-spent, vtxo-swept, or canceled.
GET /api/v1/exits/status/live returns every live exit. /status/finished returns the exits that reached claimed, vtxo-already-spent, vtxo-swept, or canceled. /status/all returns both.
Map the states to labels users understand:
State
Suggested label
What your app does next
start
Exit requested
Waits for the next progress run to broadcast the exit transactions.
processing
Broadcasting exit transactions
Keeps progressing so every transaction gets fee-bumped and confirmed.
awaiting-delta
Timelock counting down
Shows the blocks remaining until claimable_height.
claimable
Ready to claim
Prompts for a destination, or claims automatically if that is your exit policy.
claim-in-progress
Claim pending
Waits for the claim transaction to confirm. Returns to claimable if that transaction drops out of the mempool.
claimed
Back on-chain
Nothing more. The bitcoin is a regular on-chain output.
vtxo-already-spent
Nothing to exit
Drops the entry. The user spent the VTXO off-chain (a refresh or a send) after the exit started.
vtxo-swept
Exit failed
Drops the entry and offers a refresh, which can still work depending on what spent the output. An output the exit chain needs was spent on-chain by someone else, usually the server’s sweep after expiry_height.
canceled
Exit canceled
Drops the entry. The user canceled the exit before its final transaction was broadcast. The VTXO is still spendable.
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:
Bark SDK
Bark CLI
Barkd
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.
bark exit claim <destination> --all
Pass --vtxo <VTXO_ID> instead of --all to claim a chosen set.
POST /api/v1/exits/claim/all claims every claimable VTXO, and POST /api/v1/exits/claim/vtxos a chosen set.
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.
How Bark Wallet does it
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.
Was this page helpful?
⌘I
{"docsConfig":{"theme":"almond","$schema":"https://mintlify.com/docs.json","name":"Second Docs","colors":{"primary":"#060606","light":"#ffffff","dark":"#060606"},"logo":{"light":"https://mintcdn.com/second-0659a37d/92YUTFvK58wCxpgQ/images/second_logo_dark.svg?fit=max\u0026auto=format\u0026n=92YUTFvK58wCxpgQ\u0026q=85\u0026s=9d392517d5260474f0784083ce6f77bd","dark":"https://mintcdn.com/second-0659a37d/92YUTFvK58wCxpgQ/images/second_logo_white.svg?fit=max\u0026auto=format\u0026n=92YUTFvK58wCxpgQ\u0026q=85\u0026s=fef43cab4ec3fec5d2e42df265e28538"},"favicon":"https://mintcdn.com/second-0659a37d/8VZedF7eKiQd6Pfy/images/favicon.png?fit=max\u0026auto=format\u0026n=8VZedF7eKiQd6Pfy\u0026q=85\u0026s=2a570937017174600743608577deb308","api":{"playground":{"display":"simple"}},"appearance":{"default":"system"},"navbar":{"links":[{"href":"https://community.second.tech","label":"Forum"},{"href":"https://chat.second.tech","label":"Chat"}]},"footer":{"socials":{"youtube":"https://www.youtube.com/@secondhq","linkedin":"https://www.linkedin.com/company/2ndhq","x":"https://x.com/secondhq"},"links":[{"header":"Company","items":[{"label":"About","href":"https://second.tech/about"},{"label":"Blog","href":"https://second.tech/blog"},{"label":"Careers","href":"https://bitcoinerjobs.com/company/second"}]},{"header":"Developer","items":[{"label":"Support","href":"https://second.tech/docs/support"},{"label":"GitLab","href":"https://gitlab.com/ark-bitcoin/bark"},{"label":"Community forum","href":"https://community.second.tech"},{"label":"Community chat","href":"https://chat.second.tech"},{"label":"Labs","href":"https://labs.second.tech"},{"label":"Signet faucet","href":"https://signet.2nd.dev/"},{"label":"Test store","href":"https://signet.2nd.dev/store"}]}]},"seo":{"metatags":{"canonical":"https://second.tech/docs"}},"fonts":{"family":"DM Sans"},"styling":{"codeblocks":{"theme":{"light":"github-light","dark":"github-dark"}},"latex":false},"integrations":{"plausible":{"domain":"second.tech/docs"}},"contextual":{"options":["copy","view","mcp","cursor","claude"],"display":"header"},"thumbnails":{"appearance":"dark","fonts":{"family":"DM Sans"}},"variables":{"versionReleaseTag":"bark-0.9.0","versionBark":"0.9.0","versionServer":"0.9.0","arkServerSignet":"https://ark.signet.2nd.dev","esploraSignet":"https://esplora.signet.2nd.dev","arkServerMainnet":"https://ark.second.tech","esploraMainnetUrl":"https://mempool.second.tech/api"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"second-0659a37d","hasAudioNarration":false,"actualSubdomain":"second-0659a37d","customDomains":["second.tech"],"gitSource":{"type":"gitlab","owner":"ark-bitcoin","repo":"docs","projectId":78167504,"deployBranch":"master","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b065e4b8294c1a94ef2f934","clientVersion":"0.0.4304","searchFilterCounts":[{"language":"default","tag":"Barkd","count":87},{"language":"default","tag":"REST API","count":82},{"language":"default","tag":"Apps","count":38},{"language":"default","tag":"Docs","count":31},{"language":"default","tag":"wallet","count":29},{"language":"default","tag":"Learn","count":28},{"language":"default","tag":"Bark Wallet","count":22},{"language":"default","tag":"BTCPay Server plugin","count":22},{"language":"default","tag":"Bark Pay","count":18},{"language":"default","tag":"Design patterns","count":17}]},"assistantConfig":{"deflection":{"enabled":true,"email":"hello@second.tech","showHelpButton":true}},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":":root{--second-black: #060606;--second-white: #ffffff;--second-body: #242424;--second-light-grey: #f5f5f5;--second-muted: #b2b2b2;--second-blue: #3d8afb;--second-yellow: #f6d032;--second-red: #fa1336;--second-green: #43b929;--second-orange: #f4931b;--second-purple: #6f2dbd;--second-border: #e5e7eb;--second-border-dark: #1e1e1e;--second-hover-tint: rgba(128, 128, 128, 0.12);--second-hover-tint-subtle: rgba(128, 128, 128, 0.06);--second-code-bg: rgba(128, 128, 128, 0.14);--second-code-bg-dark: rgba(128, 128, 128, 0.24);--second-video-progress-height: 4px;--second-video-progress-gap: 8px}:root.dark{--second-border: var(--second-border-dark);--second-code-bg: var(--second-code-bg-dark);--second-hover-tint-subtle: rgba(128, 128, 128, 0.18)}body{background:var(--second-white)!important}.dark body{background:var(--second-black)!important}.almond-layout{padding:0!important;background:var(--second-white);min-height:100vh}.almond-layout>div:first-child{padding-left:0}.almond-layout>div:last-child{border-radius:0;height:calc(100dvh - 3.5rem)!important}#content-container{border-radius:0;border:none;border-left:1px solid var(--second-border)}#content-container:only-child{border-radius:0}.dark .almond-layout,.dark #content-container,.dark #content-area{background:var(--second-black)}.mdx-content hr{border-color:var(--second-border)!important}#page-title{letter-spacing:-0.01em;color:var(--second-black)!important}.mdx-content h1,.mdx-content h2,.mdx-content h3,.mdx-content h4,.mdx-content h5,.mdx-content h6{font-weight:700;color:var(--second-black)!important}.dark .eyebrow{color:var(--second-white)!important}.dark #page-title,.dark .mdx-content h1,.dark .mdx-content h2,.dark .mdx-content h3,.dark .mdx-content h4,.dark .mdx-content h5,.dark .mdx-content h6{color:var(--second-white)!important}body :not(pre)>code{padding-left:0.1875rem;padding-right:0.1875rem;background-color:var(--second-code-bg)}.dark body :not(pre)>code{background-color:var(--second-code-bg)}.mdx-content a{font-weight:400!important;color:var(--second-black)!important}.mdx-content a:hover{color:var(--second-black)!important}.mdx-content strong a{font-weight:inherit!important}.dark .mdx-content a{color:var(--second-white)!important}.dark .mdx-content a.link{border-bottom-color:var(--second-white)!important}.dark .mdx-content a:hover{color:var(--second-white)!important}.nav-logo{height:1.8rem}#navbar{background:var(--second-white);border-bottom:1px solid var(--second-border)}#navbar [class*=\"text-shadow\"]{text-shadow:none;font-weight:700}.dark #navbar{background:var(--second-black);border-bottom-color:var(--second-border)}.dark #navbar a{color:rgba(255, 255, 255, 0.7)!important}.dark #navbar a:hover{color:var(--second-white)!important}.dark #navbar [class*=\"text-shadow\"]{color:var(--second-white)!important}html[data-current-path^=\"/bark-sdk\"] #navbar [class*=\"text-shadow\"],html[data-current-path^=\"/barkd\"] #navbar [class*=\"text-shadow\"]{font-weight:500}html[data-current-path^=\"/bark-sdk\"] #navbar a[href=\"/bark-sdk\"],html[data-current-path^=\"/barkd\"] #navbar a[href=\"/barkd\"]{font-weight:700}#navbar a[target=\"_blank\"]::after{content:\"↗\";font-size:0.85em;margin-left:-0.1em;font-weight:300}div:has(>a.nav-dropdown-item){min-width:20rem;padding:0;background:var(--second-white);border:1px solid var(--second-border);border-radius:0.75rem}.dark div:has(>a.nav-dropdown-item){background:var(--second-black)}a.nav-dropdown-item{display:flex;align-items:flex-start;gap:0.875rem;padding:0.875rem 1rem;border-radius:calc(0.75rem - 1px)}a.nav-dropdown-item:hover{background:var(--second-hover-tint-subtle)!important}a.nav-dropdown-item>img{width:1.25rem;height:1.25rem;margin-top:0.3125rem;filter:grayscale(1);opacity:0.85}.dark a.nav-dropdown-item>img{filter:grayscale(1) invert(1)}a.nav-dropdown-item span:first-child{color:var(--second-body);font-weight:600;margin-bottom:0.1875rem}.dark a.nav-dropdown-item span:first-child{color:var(--second-white)}a.nav-dropdown-item span:last-child{font-size:0.8125rem;line-height:1.45}#sidebar-content{background:var(--second-white);padding-top:1.25rem}.dark #sidebar-content,.dark #search-bar-entry,.dark #search-bar-entry-mobile{background:var(--second-black)!important}.sidebar-group-header{font-weight:700;color:var(--second-black)!important}.dark .sidebar-group-header{color:var(--second-white)!important}#sidebar-content a,#sidebar-content li>button{color:var(--second-black)!important}#sidebar-content a:hover{background-color:var(--second-hover-tint-subtle)!important}.dark #sidebar-content a,.dark #sidebar-content li>button{color:var(--second-white)!important}.dark #sidebar-content a img{filter:invert(1)}#sidebar-content [class*=\"text-primary\"],#sidebar-content [class*=\"text-shadow\"],#sidebar-content [class*=\"text-shadow\"] a{text-shadow:none;font-weight:700;color:var(--second-black)!important}.dark #sidebar-content [class*=\"text-primary\"],.dark #sidebar-content [class*=\"text-shadow\"],.dark #sidebar-content [class*=\"text-shadow\"] a{color:var(--second-white)!important}#sidebar-content [class*=\"border-primary\"]{border-color:var(--second-black)!important}.dark #sidebar-content [class*=\"border-primary\"]{border-color:var(--second-white)!important}#sidebar-content [class*=\"bg-primary\"]{background-color:var(--second-light-grey)!important}.dark #sidebar-content [class*=\"bg-primary\"]{background-color:var(--second-border-dark)!important}#sidebar-content a:has(.method-nav-pill){padding-left:1rem!important}.toc-item[data-active]>a{text-shadow:none!important;font-weight:700}.dark .toc-item[data-active]>a{color:var(--second-white)!important;border-color:var(--second-white)!important}.dark [data-component-part=\"tab-button\"][data-active=\"true\"]{color:var(--second-white)!important}[data-component-part=\"step-number\"]>div{background:var(--second-light-grey)!important;border:none!important}.dark [data-component-part=\"step-number\"]>div{background:rgba(255, 255, 255, 0.1)!important;border:none!important}[data-component-part=\"step-line\"]{background-color:var(--second-border)!important;background-image:none!important}.step:last-child [data-component-part=\"step-line\"]{background-color:transparent!important;background-image:linear-gradient(to bottom, var(--second-border), transparent)!important}.frame{background:var(--second-white)!important}.dark .frame{background:var(--second-black)!important}.frame [class*=\"bg-grid\"]{display:none!important}.video-progress{height:var(--second-video-progress-height);margin-top:var(--second-video-progress-gap);border-radius:9999px;background:var(--second-border);overflow:hidden}.video-progress-fill{height:100%;background:var(--second-black);transform:scaleX(0);transform-origin:left;will-change:transform}.dark .video-progress-fill{background:var(--second-white)}.dark img[src^=\"/images/bark-wallet/\"][src$=\"-logo.svg\"],.dark img[src^=\"/images/built-with-bark/\"][src$=\"-logo.svg\"]{filter:invert(1)}[data-table-wrapper=\"true\"],.code-block-background{scrollbar-width:thin!important}.callout [data-component-part=\"callout-content\"]{color:var(--second-body)!important}.dark .callout [data-component-part=\"callout-content\"]{color:rgba(255, 255, 255, 0.9)!important}.callout[class*=\"bg-blue-50\"]{background-color:rgba(246, 208, 50, 0.1)!important;border-color:var(--second-yellow)!important}.callout[class*=\"bg-blue-50\"] [data-component-part=\"callout-icon\"] svg{color:var(--second-yellow)!important}.dark .callout[class*=\"bg-blue-50\"]{background-color:rgba(246, 208, 50, 0.07)!important;border-color:rgba(246, 208, 50, 0.7)!important}.dark .callout[class*=\"bg-blue-50\"] [data-component-part=\"callout-icon\"] svg{color:rgba(246, 208, 50, 0.7)!important}.callout[class*=\"bg-green-50\"]{background-color:rgba(61, 138, 251, 0.1)!important;border-color:var(--second-blue)!important}.callout[class*=\"bg-green-50\"] [data-component-part=\"callout-icon\"] svg{color:var(--second-blue)!important}.dark .callout[class*=\"bg-green-50\"]{background-color:rgba(61, 138, 251, 0.06)!important;border-color:rgba(61, 138, 251, 0.6)!important}.dark .callout[class*=\"bg-green-50\"] [data-component-part=\"callout-icon\"] svg{color:rgba(61, 138, 251, 0.6)!important}.callout[class*=\"bg-yellow-50\"]{background-color:rgba(250, 19, 54, 0.1)!important;border-color:var(--second-red)!important}.callout[class*=\"bg-yellow-50\"] [data-component-part=\"callout-icon\"] svg{color:var(--second-red)!important}.dark .callout[class*=\"bg-yellow-50\"]{background-color:rgba(250, 19, 54, 0.07)!important;border-color:rgba(250, 19, 54, 0.7)!important}.dark .callout[class*=\"bg-yellow-50\"] [data-component-part=\"callout-icon\"] svg{color:rgba(250, 19, 54, 0.7)!important}.code-block-background,[data-component-part=\"code-block-root\"],[data-component-part=\"code-block-root\"] pre.shiki{background-color:transparent!important;--shiki-light-bg: transparent !important}.dark .code-block-background,.dark [data-component-part=\"code-block-root\"],.dark [data-component-part=\"code-block-root\"] pre.shiki{background-color:transparent!important;--shiki-dark-bg: transparent !important}.code-group,.dark .code-group{background:transparent!important}[data-fade-overlay=\"true\"]{display:none!important}.dark .border-standard,.dark .code-group{border-color:var(--second-border-dark)!important}#content-side-layout .code-group,[id^=\"api-playground\"] .code-group,.dark #content-side-layout .code-group,.dark [id^=\"api-playground\"] .code-group{background:rgba(128, 128, 128, 0.1)!important;border-color:transparent!important}[id^=\"api-playground\"] .border-standard,.dark [id^=\"api-playground\"] .border-standard{border-color:transparent!important}.dark .border-standard{background:var(--second-black)!important}.dark .code-group .code-block-background,.dark .code-group [data-component-part=\"code-block-root\"]{background-color:var(--second-black)!important;--shiki-dark-bg: var(--second-black) !important}.code-group [data-component-part=\"code-group-tab-bar\"] button[aria-haspopup=\"menu\"]>div{color:var(--second-black)!important}.dark .code-group [data-component-part=\"code-group-tab-bar\"] button[aria-haspopup=\"menu\"]>div{color:var(--second-white)!important}.code-group [data-component-part=\"code-group-tab-bar\"] button[aria-haspopup=\"menu\"]>div:hover{background:var(--second-hover-tint)!important}.code-group [data-component-part=\"code-group-tab-bar\"] button[aria-haspopup=\"menu\"][data-state=\"open\"]>div{border-color:var(--second-black)!important}[role=\"menu\"][data-radix-menu-content]:not(:has(a.nav-dropdown-item)){background:#f3f3f3!important;border-color:var(--second-border)!important}.dark [role=\"menu\"][data-radix-menu-content]:not(:has(a.nav-dropdown-item)){background:#0b0b0b!important}[role=\"menu\"][data-radix-menu-content]:not(:has(a.nav-dropdown-item)) [role=\"menuitem\"]:hover,[role=\"menu\"][data-radix-menu-content]:not(:has(a.nav-dropdown-item)) [role=\"menuitem\"][data-highlighted]{background:var(--second-hover-tint)!important}.dark [role=\"menu\"][data-radix-menu-content] [role=\"menuitem\"]:not([class*=\"text-gray-500\"]),.dark [role=\"menu\"][data-radix-menu-content] [role=\"menuitem\"]:hover,.dark [role=\"menu\"][data-radix-menu-content] [role=\"menuitem\"][data-highlighted]{color:var(--second-white)!important}.dark .code-group button:hover .peer\\/title,.dark .code-group button[data-state=\"active\"] .peer\\/title{color:var(--second-white)!important}.dark .code-group button[data-state=\"active\"] .peer\\/title+div{background:var(--second-white)!important}.code-group [data-testid=\"copy-code-button\"]{border-radius:10px!important;padding:5px!important}.code-group [data-testid=\"copy-code-button\"] svg{color:var(--second-black)!important}.code-group [data-testid=\"copy-code-button\"]:hover{background:var(--second-hover-tint)!important}.dark .code-group [data-testid=\"copy-code-button\"] svg{color:var(--second-white)!important}.method-pill[class*=\"bg-blue\"],.method-nav-pill span[class*=\"bg-blue\"]{color:var(--second-blue)!important;background:rgba(61, 138, 251, 0.15)!important}.method-nav-pill .bg-\\[\\#3064E3\\]{color:var(--second-white)!important;background:var(--second-blue)!important}.dark .method-nav-pill .bg-\\[\\#3064E3\\]{color:var(--second-black)!important}.method-pill[class*=\"bg-green\"],.method-nav-pill span[class*=\"bg-green\"]{color:var(--second-green)!important;background:rgba(67, 185, 41, 0.15)!important}.method-nav-pill .bg-\\[\\#2AB673\\]{color:var(--second-white)!important;background:var(--second-green)!important}.dark .method-nav-pill .bg-\\[\\#2AB673\\]{color:var(--second-black)!important}.bg-\\[\\#FDEAD8\\]{color:var(--second-orange)!important;background:rgba(244, 147, 27, 0.15)!important}[data-component-part=\"field-name\"]{color:var(--second-black)!important}.dark [data-component-part=\"field-name\"]{color:var(--second-white)!important}[data-component-part=\"field-info-pill\"]{color:var(--second-black)!important}.dark [data-component-part=\"field-info-pill\"]{color:var(--second-white)!important}[data-component-part=\"field-required-pill\"]{color:var(--second-red)!important;background:rgba(250, 19, 54, 0.1)!important}.dark mark,.dark mark b{color:var(--second-white)!important;background-color:transparent!important}.dark [role=\"dialog\"] svg{color:rgba(255, 255, 255, 0.5)!important}[data-component-part=\"update-label\"]{background:var(--second-light-grey)!important;color:var(--second-black)!important}.dark [data-component-part=\"update-label\"]{background:rgba(255, 255, 255, 0.1)!important;color:var(--second-white)!important}[data-component-part=\"update-content\"]>:first-child{margin-top:0!important}[data-component-part=\"update-content\"]>span[data-rmiz]:first-child img,[data-component-part=\"update-content\"]>img:first-child{margin-top:0!important}[data-component-part=\"update-content\"] h3 svg.icon{vertical-align:-0.1em!important;margin-right:0.35em}.changelog-key svg.icon{vertical-align:-0.1em!important;margin-right:0.25em}.dark [data-component-part=\"card-icon\"] svg{background-color:var(--second-white)!important}.dark [data-component-part=\"card-icon\"] img{filter:invert(1)}[data-component-part=\"card-icon\"] img[src*=\"go-logo\"]{transform:scale(1.6);transform-origin:left center}[data-component-part=\"card-icon\"]:has(img[src*=\"/images/built-with-bark/\"]){margin-top:6px}.card:hover{border-color:var(--second-black)!important}.dark .card:hover{border-color:var(--second-white)!important}.dark .card:hover .lucide-arrow-up-right{color:var(--second-white)!important}.pagination-next:hover,.pagination-prev:hover{border-color:var(--second-black)!important}.dark .pagination-next:hover,.dark .pagination-prev:hover{border-color:var(--second-white)!important}.showcase-tags{font-family:var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:0.75rem;color:var(--second-black);margin-top:0.5rem}.dark .showcase-tags{color:var(--second-white)}#footer{background:var(--second-white);border-top:none}.dark #footer{background:var(--second-black)}#footer a{color:var(--second-black)!important;text-decoration:none!important}#footer a:hover{text-decoration:underline!important}.dark #footer a{color:var(--second-white)!important}#footer a[href*=\"mintlify\"]{color:var(--second-border)!important}#footer a[href*=\"mintlify\"] svg path{fill:var(--second-border)!important}#footer a[href*=\"mintlify\"]:hover{text-decoration:none!important}#footer svg[style*=\"mask-image\"]{background-color:var(--second-muted)!important;transition:background-color 0.15s ease}#footer a:hover svg[style*=\"mask-image\"]{background-color:var(--second-black)!important}.dark #footer a:hover svg[style*=\"mask-image\"]{background-color:var(--second-white)!important}#footer [data-testid^=\"mode-switch-\"]{color:var(--second-muted)!important}#footer [data-testid^=\"mode-switch-\"]:hover{color:var(--second-black)!important}.dark #footer [data-testid^=\"mode-switch-\"]:hover{color:var(--second-white)!important}#footer [data-testid^=\"mode-switch-\"][class*=\"bg-gray-200\"]{background-color:rgba(222, 222, 222, 0.5)!important}.dark #footer [data-testid^=\"mode-switch-\"][class*=\"bg-gray-800\"]{background-color:rgb(22, 23, 23)!important}.chat-assistant-floating-input::before{display:none!important}@media (max-width: 767px){div:has(>.chat-assistant-floating-input){bottom:3.5rem!important}}"}]}
{"page":{"pagePath":"patterns/exits","slug":"/patterns/exits","pageMetadata":{"title":"Handle emergency exits","sidebarTitle":"Exit handling","description":"Start, progress, and claim emergency exits to move users' bitcoin back on-chain without the Ark server's cooperation.","href":"/patterns/exits"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Start, progress, and claim emergency exits to move users’ bitcoin back on-chain without the Ark server’s cooperation.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,CodeBlock,Frame,Heading,OptimizedImage,Step,Steps,Tab,Table,Tabs,Tip,Warning}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Step)_missingMdxReference(`Step`,true);if(!Steps)_missingMdxReference(`Steps`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`An unresponsive Ark server leaves your wallet app one route: an `,_jsx(_components.a,{href:`/learn/exit`,children:`emergency exit`}),`. `,_jsx(_components.a,{href:`/patterns/forced-exits`,children:`Respond to forced exits`}),` covers exits someone else forces.`]}),`\n`,_jsx(Heading,{level:`2`,id:`reach-for-offboarding-first`,children:`Reach for offboarding first`}),`\n`,_jsxs(_components.p,{children:[`Reserve emergency exits for a server that is unresponsive or uncooperative. Under normal conditions, a cooperative `,_jsx(_components.a,{href:`/learn/offboard`,children:`offboard`}),` gets bitcoin back on-chain in a single transaction, cheaper and simpler than an exit (`,_jsx(_components.a,{href:`/patterns/on-chain-payments`,children:`on-chain payments`}),` covers the calls).`]}),`\n`,_jsx(Heading,{level:`2`,id:`start-the-exit`,children:`Start the exit`}),`\n`,_jsx(_components.p,{children:`Starting an exit marks the VTXOs for exit. Nothing reaches the chain yet.`}),`\n`,_jsxs(Tabs,{children:[_jsx(Tab,{title:`Bark SDK`,id:`bark-sdk`,children:_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`startExitForEntireWallet()`}),` exits every VTXO in the wallet.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`startExitForVtxos(vtxoIds)`}),` exits a chosen set.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`cancelExit(vtxoId)`}),` aborts one exit.`]}),`\n`]})}),_jsxs(Tab,{title:`Bark CLI`,id:`bark-cli`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#24292e`,color:`#24292e`,\"--shiki-dark\":`#e1e4e8`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#B392F0`},children:`bark`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` exit`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` start`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#79B8FF`},children:` --all`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Pass `,_jsx(_components.code,{children:`--vtxo \u003cVTXO_ID>`}),` (repeatable) instead of `,_jsx(_components.code,{children:`--all`}),` to exit a chosen set. `,_jsx(_components.code,{children:`bark exit cancel \u003cVTXO_ID>`}),` aborts one exit.`]})]}),_jsx(Tab,{title:`Barkd`,id:`barkd`,children:_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`POST /api/v1/exits/start/all`}),` exits every VTXO in the wallet.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`POST /api/v1/exits/start/vtxos`}),` with a list of VTXO IDs exits a chosen set.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`POST /api/v1/exits/cancel/{vtxo_id}`}),` aborts one exit.`]}),`\n`]})})]}),`\n`,_jsx(_components.p,{children:`Five behaviors to account for:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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 `,_jsx(_components.code,{children:`cancelExit`}),` reports that refusal in its result (`,_jsx(_components.code,{children:`canceled`}),` is `,_jsx(_components.code,{children:`false`}),`, with a `,_jsx(_components.code,{children:`reason`}),`), not as an error. Canceling twice is a no-op.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Movements stay pending until the end:`}),` Starting an exit records one movement per VTXO. It stays `,_jsx(_components.code,{children:`pending`}),` until the exit reaches `,_jsx(_components.code,{children:`claimed`}),`, which finishes it as successful, or `,_jsx(_components.code,{children:`vtxo-already-spent`}),` or `,_jsx(_components.code,{children:`canceled`}),`, which finish it as canceled. An exit that ends in `,_jsx(_components.code,{children:`vtxo-swept`}),` leaves its movement `,_jsx(_components.code,{children:`pending`}),`, so read its outcome from the exit state. Track progress through the exit states below, not through the movements.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`An exit must confirm before the VTXO expires:`}),` After `,_jsx(_components.code,{children:`expiry_height`}),`, the Ark server’s sweep can invalidate any exit transaction that has not confirmed yet (`,_jsx(_components.a,{href:`/learn/lifetime`,children:`VTXO lifetime`}),`). Refresh an expired VTXO instead.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`fund-the-fees-then-progress-until-done`,children:`Fund the fees, then progress until done`}),`\n`,_jsx(_components.p,{children:`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.`}),`\n`,_jsxs(Steps,{children:[_jsxs(Step,{title:`Price the exit with the fee estimate`,children:[_jsx(_components.p,{children:`Price the VTXOs you are about to exit:`}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`Bark SDK`,id:`bark-sdk-2`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`estimateEmergencyExitFee`}),` with the VTXO IDs. Leave the feerate, destination, or fee margin empty (`,_jsx(_components.code,{children:`null`}),`, `,_jsx(_components.code,{children:`nil`}),`, or `,_jsx(_components.code,{children:`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 `,_jsx(_components.code,{children:`exitBroadcastFeeSats`}),`, `,_jsx(_components.code,{children:`claimFeeSats`}),`, and `,_jsx(_components.code,{children:`totalFeeSats`}),`. Ignore the deprecated `,_jsx(_components.code,{children:`fundable`}),`. In Rust, `,_jsx(_components.code,{children:`Wallet::estimate_emergency_exit_fee`}),` prices exactly the IDs you pass, so an empty list returns a zero estimate.`]})}),_jsxs(Tab,{title:`Bark CLI`,id:`bark-cli-2`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#24292e`,color:`#24292e`,\"--shiki-dark\":`#e1e4e8`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#B392F0`},children:`bark`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` exit`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` estimate-fee`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#79B8FF`},children:` --all`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Pass `,_jsx(_components.code,{children:`--vtxo \u003cVTXO_ID>`}),` (repeatable) instead of `,_jsx(_components.code,{children:`--all`}),` to price a chosen set.`]})]}),_jsx(Tab,{title:`Barkd`,id:`barkd-2`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`GET /api/v1/exits/fee`}),`, with a comma-separated `,_jsx(_components.code,{children:`vtxo_ids`}),` for a chosen set or without it for every spendable VTXO, with the same limit as the SDK.`]})})]}),_jsx(_components.p,{children:`Read two fields:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`exit_broadcast_fee_sat`}),`:`]}),` The CPFP fees paid from the confirmed on-chain balance while the exit runs. This is the amount to fund.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`claim_fee_sat`}),`:`]}),` The fee of the final claim transaction, taken out of the recovered bitcoin. It needs no on-chain balance.`]}),`\n`]}),_jsxs(_components.p,{children:[`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 `,_jsx(_components.code,{children:`total_fee_sat`}),` as an estimate. The final cost depends on the feerates when each transaction is broadcast.`]}),_jsx(Tip,{children:_jsxs(_components.p,{children:[`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 `,_jsx(_components.code,{children:`exit_broadcast_fee_sat`}),`.`]})}),_jsx(Frame,{caption:`Bark Wallet disables the start button while the confirmed on-chain balance is below the exit broadcast fee`,children:_jsx(OptimizedImage,{src:`https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=85a48ff7c741b71fce87b088e1a161da`,alt:`Screenshot of the Bark Wallet emergency exit dialog with a confirmed on-chain balance of 0 sats and a disabled Start emergency exit button`,\"data-og-width\":`2864`,width:`2864`,\"data-og-height\":`1456`,height:`1456`,\"data-path\":`images/patterns/exit-dialog-fee-check.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?w=280\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=20d2e0621dff574cb53c1751e85aa136 280w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?w=560\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=9124c6cff1ace9c7cf657e8fb0dba4b1 560w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?w=840\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=3fdc206a3556a02123d343371da3fc39 840w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?w=1100\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=307c164dfb544c4061abf5547776e36b 1100w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?w=1650\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=972274f4f8441b04eed4d2947757fd7f 1650w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/patterns/exit-dialog-fee-check.png?w=2500\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=2b8a36256600a526ed66c75180d3c4cf 2500w`})})]}),_jsx(Step,{title:`Fund the on-chain wallet`,children:_jsxs(_components.p,{children:[`Send at least `,_jsx(_components.code,{children:`exit_broadcast_fee_sat`}),` to the on-chain wallet, and wait for it to confirm. Get the address from `,_jsx(_components.code,{children:`bark onchain address`}),` on the CLI, from `,_jsx(_components.code,{children:`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.`]})}),_jsx(Step,{title:`Progress the exit`,children:_jsxs(Tabs,{children:[_jsx(Tab,{title:`Bark SDK`,id:`bark-sdk-3`,children:_jsxs(_components.p,{children:[`The background daemon progresses exits while it runs. Call `,_jsx(_components.code,{children:`progressExits`}),` to force a step, or on your own schedule while the daemon is off (`,_jsx(_components.a,{href:`/patterns/background-refresh#run-one-pass-per-wake`,children:`background refresh`}),` covers mobile wakes). It takes one setting, a feerate. Leave it empty to use Bark’s default exit feerate.`]})}),_jsxs(Tab,{title:`Bark CLI`,id:`bark-cli-3`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#24292e`,color:`#24292e`,\"--shiki-dark\":`#e1e4e8`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#B392F0`},children:`bark`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` exit`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` progress`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#79B8FF`},children:` --wait`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`The command retries every 60 seconds until `,_jsx(_components.code,{children:`done`}),` turns true, which can take hours or days.`]})]}),_jsx(Tab,{title:`Barkd`,id:`barkd-3`,children:_jsxs(_components.p,{children:[`Barkd progresses registered exits on its own. Call `,_jsx(_components.code,{children:`POST /api/v1/exits/progress`}),` to force a step.`]})})]})}),_jsxs(Step,{title:`Monitor until done`,children:[_jsx(_components.p,{children:`The CLI and Barkd progress responses carry three signals:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`done`}),`:`]}),` True once no exit is left in `,_jsx(_components.code,{children:`start`}),`, `,_jsx(_components.code,{children:`processing`}),`, or `,_jsx(_components.code,{children:`awaiting-delta`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`claimable_height`}),`:`]}),` The latest unlock height among the exits whose transactions have all confirmed. It stays `,_jsx(_components.code,{children:`null`}),` until one reaches `,_jsx(_components.code,{children:`awaiting-delta`}),` and ignores exits still in `,_jsx(_components.code,{children:`start`}),` or `,_jsx(_components.code,{children:`processing`}),`, so read it together with `,_jsx(_components.code,{children:`done`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`error`}),`, per exit:`]}),` How your app tells a failed run from one that made no headway. When the whole run fails, `,_jsx(_components.code,{children:`bark exit progress`}),` fills a top-level `,_jsx(_components.code,{children:`error`}),` and Barkd answers a 500.`]}),`\n`]}),_jsxs(_components.p,{children:[`The Bark SDK returns one status per exit instead. Call `,_jsx(_components.code,{children:`allExitsClaimableAtHeight()`}),` for the unlock height.`]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`track-exit-states-in-the-ui`,children:`Track exit states in the UI`}),`\n`,_jsx(_components.p,{children:`Each exiting VTXO moves through a state machine.`}),`\n`,_jsxs(Frame,{caption:`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`,children:[_jsx(OptimizedImage,{src:`https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=97b52eb0de89a529db5de81324240b37`,alt:`Diagram of the six exit states from start to claimed and the three states where an exit ends early`,className:`mint-block dark:mint-hidden`,\"data-og-width\":`1220`,width:`1220`,\"data-og-height\":`780`,height:`780`,\"data-path\":`images/exit-states.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?w=280\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=5744be040e008988ea8b94ebd810a7c6 280w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?w=560\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=6fe7a56390b0195558651a9402382753 560w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?w=840\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=e67db689cebf61dccd03d88284731700 840w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=e83081044a69ea71b9bca457677e405a 1100w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=e75f1ea29cd05c97d69e9ca49646be15 1650w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=a7031f86208da12bc5d97b1f03fdcd2b 2500w`}),_jsx(OptimizedImage,{src:`https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=e1bed9a156775c15f623f35637fa16c9`,alt:`Diagram of the six exit states from start to claimed and the three states where an exit ends early`,className:`mint-hidden dark:mint-block`,\"data-og-width\":`1220`,width:`1220`,\"data-og-height\":`780`,height:`780`,\"data-path\":`images/exit-states-dark.svg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?w=280\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=4ba860f33e6d8632224ee7c176fddf5f 280w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?w=560\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=45ea90c8dbd7333258debe280db17a48 560w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?w=840\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=3d97809a8b333d533d6d108297fc6e49 840w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?w=1100\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=75802ed48879016b5ce913eb9b99fcf3 1100w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?w=1650\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=f6e1c53adadcae4815992e84017ccb3c 1650w, https://mintcdn.com/second-0659a37d/tQnT1N_qr7W8s6kQ/images/exit-states-dark.svg?w=2500\u0026fit=max\u0026auto=format\u0026n=tQnT1N_qr7W8s6kQ\u0026q=85\u0026s=933262b8e473e706cb46d8a5389e3a35 2500w`})]}),`\n`,_jsxs(Tabs,{children:[_jsx(Tab,{title:`Bark SDK`,id:`bark-sdk-4`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`getExitStatus`}),` takes a VTXO ID and two flags, `,_jsx(_components.code,{children:`includeHistory`}),` and `,_jsx(_components.code,{children:`includeTransactions`}),`, and returns that VTXO’s state. `,_jsx(_components.code,{children:`listClaimableExits()`}),` returns the VTXOs ready to claim.`]})}),_jsx(Tab,{title:`Bark CLI`,id:`bark-cli-4`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`bark exit status \u003cVTXO_ID>`}),` prints one VTXO’s state, and `,_jsx(_components.code,{children:`bark exit list`}),` every live exit. Pass `,_jsx(_components.code,{children:`--include-finished`}),` to include exits that reached `,_jsx(_components.code,{children:`claimed`}),`, `,_jsx(_components.code,{children:`vtxo-already-spent`}),`, `,_jsx(_components.code,{children:`vtxo-swept`}),`, or `,_jsx(_components.code,{children:`canceled`}),`.`]})}),_jsx(Tab,{title:`Barkd`,id:`barkd-4`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`GET /api/v1/exits/status/live`}),` returns every live exit. `,_jsx(_components.code,{children:`/status/finished`}),` returns the exits that reached `,_jsx(_components.code,{children:`claimed`}),`, `,_jsx(_components.code,{children:`vtxo-already-spent`}),`, `,_jsx(_components.code,{children:`vtxo-swept`}),`, or `,_jsx(_components.code,{children:`canceled`}),`. `,_jsx(_components.code,{children:`/status/all`}),` returns both.`]})})]}),`\n`,_jsx(_components.p,{children:`Map the states to labels users understand:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`State`}),_jsx(_components.th,{children:`Suggested label`}),_jsx(_components.th,{children:`What your app does next`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`start`})}),_jsx(_components.td,{children:`Exit requested`}),_jsx(_components.td,{children:`Waits for the next progress run to broadcast the exit transactions.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`processing`})}),_jsx(_components.td,{children:`Broadcasting exit transactions`}),_jsx(_components.td,{children:`Keeps progressing so every transaction gets fee-bumped and confirmed.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`awaiting-delta`})}),_jsx(_components.td,{children:`Timelock counting down`}),_jsxs(_components.td,{children:[`Shows the blocks remaining until `,_jsx(_components.code,{children:`claimable_height`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`claimable`})}),_jsx(_components.td,{children:`Ready to claim`}),_jsx(_components.td,{children:`Prompts for a destination, or claims automatically if that is your exit policy.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`claim-in-progress`})}),_jsx(_components.td,{children:`Claim pending`}),_jsxs(_components.td,{children:[`Waits for the claim transaction to confirm. Returns to `,_jsx(_components.code,{children:`claimable`}),` if that transaction drops out of the mempool.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`claimed`})}),_jsx(_components.td,{children:`Back on-chain`}),_jsx(_components.td,{children:`Nothing more. The bitcoin is a regular on-chain output.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`vtxo-already-spent`})}),_jsx(_components.td,{children:`Nothing to exit`}),_jsx(_components.td,{children:`Drops the entry. The user spent the VTXO off-chain (a refresh or a send) after the exit started.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`vtxo-swept`})}),_jsx(_components.td,{children:`Exit failed`}),_jsxs(_components.td,{children:[`Drops the entry and offers a refresh, which can still work depending on what spent the output. An output the exit chain needs was spent on-chain by someone else, usually the server’s sweep after `,_jsx(_components.code,{children:`expiry_height`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`canceled`})}),_jsx(_components.td,{children:`Exit canceled`}),_jsx(_components.td,{children:`Drops the entry. The user canceled the exit before its final transaction was broadcast. The VTXO is still spendable.`})]})]})]}),`\n`,_jsxs(_components.p,{children:[`From `,_jsx(_components.code,{children:`awaiting-delta`}),` until the claim completes, the exiting sats show in `,_jsx(_components.code,{children:`pending_exit_sat`}),`. `,_jsx(_components.a,{href:`/patterns/balances#hold-the-last-known-figure-when-an-amount-is-unknown`,children:`Balances`}),` covers how to display that field.`]}),`\n`,_jsx(Heading,{level:`2`,id:`claim-to-the-on-chain-wallet`,children:`Claim to the on-chain wallet`}),`\n`,_jsxs(_components.p,{children:[`Once a VTXO is `,_jsx(_components.code,{children:`claimable`}),`, claim it to an on-chain address:`]}),`\n`,_jsxs(Tabs,{children:[_jsx(Tab,{title:`Bark SDK`,id:`bark-sdk-5`,children:_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`drainExits`}),` with `,_jsx(_components.code,{children:`drainAll`}),` set to `,_jsx(_components.code,{children:`true`}),` and an empty `,_jsx(_components.code,{children:`vtxoIds`}),` list to claim every claimable VTXO, or with `,_jsx(_components.code,{children:`vtxoIds`}),` to claim a chosen set. It returns the signed claim transaction as a PSBT. Extract the final transaction with `,_jsx(_components.code,{children:`extractTxFromPsbt`}),` and broadcast it with `,_jsx(_components.code,{children:`broadcastTx`}),`.`]})}),_jsxs(Tab,{title:`Bark CLI`,id:`bark-cli-5`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#24292e`,color:`#24292e`,\"--shiki-dark\":`#e1e4e8`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#B392F0`},children:`bark`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` exit`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:` claim`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F97583`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:`destinatio`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECBFF`},children:`n`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F97583`},children:`>`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#79B8FF`},children:` --all`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Pass `,_jsx(_components.code,{children:`--vtxo \u003cVTXO_ID>`}),` instead of `,_jsx(_components.code,{children:`--all`}),` to claim a chosen set.`]})]}),_jsx(Tab,{title:`Barkd`,id:`barkd-5`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`POST /api/v1/exits/claim/all`}),` claims every claimable VTXO, and `,_jsx(_components.code,{children:`POST /api/v1/exits/claim/vtxos`}),` a chosen set.`]})})]}),`\n`,_jsx(_components.p,{children:`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.`}),`\n`,_jsxs(Warning,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`Until the claim confirms, the exit depends on the wallet database`})}),_jsxs(_components.p,{children:[`Which 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 `,_jsx(_components.a,{href:`/patterns/backups#continuous-backups`,children:`continuous backup`}),` running through the whole exit, and back up anything your app stores outside that database, such as the claim destination. `,_jsx(_components.a,{href:`/patterns/restore`,children:`Restore a wallet`}),` lists what each restore path brings back.`]})]}),`\n`,_jsx(Heading,{level:`2`,id:`keep-automation-and-chain-access-in-place`,children:`Keep automation and chain access in place`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Progress in the background:`}),` Once a user triggers an exit, your app progresses it with no further involvement from them. `,_jsx(_components.a,{href:`/learn/exit#automated-wallet-management`,children:`Automated wallet management`}),` lists what users should never do by hand.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Plan for partial completion:`}),` A `,_jsx(_components.a,{href:`/learn/exit#partially-completed-exits`,children:`partially completed exit`}),` behaves differently from a finished one. Factor it into any cancellation option you offer.`]}),`\n`]}),`\n`,_jsx(Accordion,{title:`How Bark Wallet does it`,id:`how-bark-wallet-does-it`,children:_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Entry points:`}),` “Emergency exit all” in the `,_jsx(_components.a,{href:`/bark-wallet/settings#danger-zone`,children:`Danger zone`}),` of the Settings page, and “Emergency Exit” for VTXOs selected in the VTXOs table. Both open the same start dialog.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.”`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Progress and claim:`}),` While an exit is live, the app polls exit status every 10 seconds on every page and claims each `,_jsx(_components.code,{children:`claimable`}),` VTXO to its stored destination. The installed version leaves progress to `,_jsx(_components.code,{children:`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 (`,_jsx(_components.a,{href:`/bark-wallet/settings#follow-the-exit-to-completion`,children:`Follow the exit to completion`}),`).`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.`]}),`\n`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"github-light","dark":"github-dark"}},"config":{},"pageMetadata":{"title":"Handle emergency exits","sidebarTitle":"Exit handling","description":"Start, progress, and claim emergency exits to move users' bitcoin back on-chain without the Ark server's cooperation.","href":"/patterns/exits"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Reach for offboarding first","slug":"reach-for-offboarding-first","depth":2,"children":[]},{"title":"Start the exit","slug":"start-the-exit","depth":2,"children":[]},{"title":"Fund the fees, then progress until done","slug":"fund-the-fees-then-progress-until-done","depth":2,"children":[]},{"title":"Track exit states in the UI","slug":"track-exit-states-in-the-ui","depth":2,"children":[]},{"title":"Claim to the on-chain wallet","slug":"claim-to-the-on-chain-wallet","depth":2,"children":[]},{"title":"Keep automation and chain access in place","slug":"keep-automation-and-chain-access-in-place","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/docs/_mintlify/custom/second-0659a37d/ed0636a846cd3bb8/video-progress.js"],"dynamicCss":".mint-block {\n display: block\n}\n.mint-hidden {\n display: none\n}\n.dark\\:mint-block:is(.dark *) {\n display: block\n}\n.dark\\:mint-hidden:is(.dark *) {\n display: none\n}","subdomain":"second-0659a37d","siteName":"Second Docs","title":"Handle emergency exits - Second Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-25T04:04:41.813Z","originalFileLocation":"patterns/exits.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Start, progress, and claim emergency exits to move users\u0026#x27; bitcoin back on-chain without the Ark server\u0026#x27;s cooperation.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Second Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Handle emergency exits - Second Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Start, progress, and claim emergency exits to move users\u0026#x27; bitcoin back on-chain without the Ark server\u0026#x27;s cooperation.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Second Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://second.tech/docs/patterns/exits\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://second-0659a37d.mintlify.site/docs/_mintlify/api/og/v2?division=Get+bitcoin+back+on-chain\u0026amp;title=Handle+emergency+exits\u0026amp;description=Start%2C+progress%2C+and+claim+emergency+exits+to+move+users%27+bitcoin+back+on-chain+without+the+Ark+server%27s+cooperation.\u0026amp;theme=4928f82b62d30c85a0911f50\u0026amp;signature=98996c4b1281de702c11b764881b2e36e673a6e2af9af4eb5d632b7439d85eda\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Handle emergency exits - Second Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Start, progress, and claim emergency exits to move users\u0026#x27; bitcoin back on-chain without the Ark server\u0026#x27;s cooperation.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://second-0659a37d.mintlify.site/docs/_mintlify/api/og/v2?division=Get+bitcoin+back+on-chain\u0026amp;title=Handle+emergency+exits\u0026amp;description=Start%2C+progress%2C+and+claim+emergency+exits+to+move+users%27+bitcoin+back+on-chain+without+the+Ark+server%27s+cooperation.\u0026amp;theme=4928f82b62d30c85a0911f50\u0026amp;signature=98996c4b1281de702c11b764881b2e36e673a6e2af9af4eb5d632b7439d85eda\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/second-0659a37d/R0dyIm4bMdcQUJx_/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Second Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#060606\">\u003clink data-mint-head rel=\"canonical\" href=\"https://second.tech/docs/patterns/exits\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/patterns/exits.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://second.tech/#organization\",\"name\":\"Second Docs\",\"url\":\"https://second.tech\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/second-0659a37d/92YUTFvK58wCxpgQ/images/second_logo_dark.svg?fit=max\u0026auto=format\u0026n=92YUTFvK58wCxpgQ\u0026q=85\u0026s=9d392517d5260474f0784083ce6f77bd\"}},{\"@type\":\"WebSite\",\"@id\":\"https://second.tech/docs#website\",\"name\":\"Second Docs\",\"url\":\"https://second.tech/docs\",\"publisher\":{\"@id\":\"https://second.tech/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://second.tech/docs/patterns/exits#webpage\",\"url\":\"https://second.tech/docs/patterns/exits\",\"name\":\"Handle emergency exits\",\"description\":\"Start, progress, and claim emergency exits to move users' bitcoin back on-chain without the Ark server's cooperation.\",\"dateModified\":\"2026-11-25T04:04:41.813Z\",\"isPartOf\":{\"@id\":\"https://second.tech/docs#website\"},\"breadcrumb\":{\"@id\":\"https://second.tech/docs/patterns/exits#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://second.tech/docs/patterns/exits#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Design patterns\",\"item\":\"https://second.tech/docs/patterns\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get bitcoin back on-chain\",\"item\":\"https://second.tech/docs/patterns/on-chain-payments\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Handle emergency exits\",\"item\":\"https://second.tech/docs/patterns/exits\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://second.tech/docs/patterns/exits#article\",\"headline\":\"Handle emergency exits\",\"name\":\"Handle emergency exits\",\"description\":\"Start, progress, and claim emergency exits to move users' bitcoin back on-chain without the Ark server's cooperation.\",\"url\":\"https://second.tech/docs/patterns/exits\",\"mainEntityOfPage\":{\"@id\":\"https://second.tech/docs/patterns/exits#webpage\"},\"dateModified\":\"2026-11-25T04:04:41.813Z\",\"publisher\":{\"@id\":\"https://second.tech/#organization\"},\"isPartOf\":{\"@id\":\"https://second.tech/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Second Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Second Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/patterns/exits.md","siteName":"Second Docs","nav":{"global":null,"tabs":[{"tab":"Docs","groups":[{"group":"Documentation","pages":[{"title":"Add bitcoin payments to your app with Bark","sidebarTitle":"Welcome","href":""},{"group":"Quickstart guide","pages":[{"title":"Install Bark CLI","href":"/getting-started/bark-cli/index"},{"title":"Test on signet","href":"/getting-started/bark-cli/signet"},{"title":"Test on mainnet","href":"/getting-started/bark-cli/mainnet"},{"title":"Configure Bark","href":"/getting-started/bark-cli/configuration"},{"title":"Advanced Bark features","href":"/getting-started/bark-cli/advanced"}]},{"title":"Connection details","href":"/connection-details"},{"title":"Built with Bark","href":"/built-with-bark"},{"title":"MCP server for agents","sidebarTitle":"MCP","href":"/agents"},{"title":"Get support","sidebarTitle":"Support","href":"/support"}]},{"group":"Bark SDK","pages":[{"title":"Bark SDK","sidebarTitle":"Overview","href":"/bark-sdk/index"},{"title":"Get started with Rust","sidebarTitle":"Rust","href":"/bark-sdk/rust"},{"title":"Get started with TypeScript for web apps","sidebarTitle":"Web","href":"/bark-sdk/wasm"},{"title":"Get started with TypeScript for React Native","sidebarTitle":"React Native","href":"/bark-sdk/react-native"},{"title":"Get started with Dart","sidebarTitle":"Dart","href":"/bark-sdk/dart"},{"title":"Get started with Swift","sidebarTitle":"Swift","href":"/bark-sdk/swift"},{"title":"Get started with Kotlin","sidebarTitle":"Kotlin","href":"/bark-sdk/kotlin"},{"title":"Get started with Go","sidebarTitle":"Go","href":"/bark-sdk/go"}]},{"group":"Barkd","pages":[{"title":"Barkd","sidebarTitle":"Overview","href":"/barkd/index"},{"title":"Install Barkd","href":"/barkd/install"},{"title":"Start the daemon","sidebarTitle":"Start the daemon","href":"/barkd/start"},{"title":"Authenticate","sidebarTitle":"Authenticate","href":"/barkd/authenticate"},{"title":"Clients","sidebarTitle":"Clients","href":"/barkd/clients"},{"group":"REST API","pages":[{"group":"bitcoin","pages":[{"title":"Get bitcoin tip height","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/bitcoin/tip","href":"/barkd/api-reference/bitcoin/get-bitcoin-tip-height"}]},{"group":"boards","pages":[{"title":"Board all on-chain bitcoin","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/boards/board-all","href":"/barkd/api-reference/boards/board-all-on-chain-bitcoin"},{"title":"Board a specific amount","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/boards/board-amount","href":"/barkd/api-reference/boards/board-a-specific-amount"},{"title":"List pending boards","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/boards/pending","href":"/barkd/api-reference/boards/list-pending-boards"}]},{"group":"exits","pages":[{"title":"Cancel an exit","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/cancel/{vtxo_id}","href":"/barkd/api-reference/exits/cancel-an-exit"},{"title":"Claim all exited VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/claim/all","href":"/barkd/api-reference/exits/claim-all-exited-vtxos"},{"title":"Claim specific exited VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/claim/vtxos","href":"/barkd/api-reference/exits/claim-specific-exited-vtxos"},{"title":"Estimate emergency exit fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/fee","href":"/barkd/api-reference/exits/estimate-emergency-exit-fee"},{"title":"Presign emergency exit chains","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/presign","href":"/barkd/api-reference/exits/presign-emergency-exit-chains"},{"title":"Progress exits","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/progress","href":"/barkd/api-reference/exits/progress-exits"},{"title":"List remaining exit transactions","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/remaining","href":"/barkd/api-reference/exits/list-remaining-exit-transactions"},{"title":"Start exit for all VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/start/all","href":"/barkd/api-reference/exits/start-exit-for-all-vtxos"},{"title":"Start exit for specific VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/exits/start/vtxos","href":"/barkd/api-reference/exits/start-exit-for-specific-vtxos"},{"title":"List all exit statuses (deprecated)","deprecated":true,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/status","href":"/barkd/api-reference/exits/list-all-exit-statuses-deprecated"},{"title":"List all exit statuses","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/status/all","href":"/barkd/api-reference/exits/list-all-exit-statuses"},{"title":"List finished exits","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/status/finished","href":"/barkd/api-reference/exits/list-finished-exits"},{"title":"List live exit statuses","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/status/live","href":"/barkd/api-reference/exits/list-live-exit-statuses"},{"title":"Get VTXO exit status","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/status/vtxo/{vtxo_id}","href":"/barkd/api-reference/exits/get-vtxo-exit-status"},{"title":"Get exit status (deprecated)","deprecated":true,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/exits/status/{vtxo_id}","href":"/barkd/api-reference/exits/get-exit-status-deprecated"}]},{"group":"fees","pages":[{"title":"Estimate board fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/fees/board","href":"/barkd/api-reference/fees/estimate-board-fee"},{"title":"Estimate Lightning send fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/fees/lightning/pay","href":"/barkd/api-reference/fees/estimate-lightning-send-fee"},{"title":"Estimate Lightning receive fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/fees/lightning/receive","href":"/barkd/api-reference/fees/estimate-lightning-receive-fee"},{"title":"Estimate offboard fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/fees/offboard","href":"/barkd/api-reference/fees/estimate-offboard-fee"},{"title":"Estimate offboard-all fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/fees/offboard-all","href":"/barkd/api-reference/fees/estimate-offboard-all-fee"},{"title":"Get on-chain fee rates","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/fees/onchain","href":"/barkd/api-reference/fees/get-on-chain-fee-rates"},{"title":"Estimate send-onchain fee","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/fees/send-onchain","href":"/barkd/api-reference/fees/estimate-send-onchain-fee"}]},{"group":"history","pages":[{"title":"Get wallet history","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/history","href":"/barkd/api-reference/history/get-wallet-history"},{"title":"Patch movement metadata","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/history/{id}/metadata","href":"/barkd/api-reference/history/patch-movement-metadata"}]},{"group":"lightning","pages":[{"title":"Send a Lightning payment","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/lightning/pay","href":"/barkd/api-reference/lightning/send-a-lightning-payment"},{"title":"List all pending receive statuses","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/lightning/receives","href":"/barkd/api-reference/lightning/list-all-pending-receive-statuses"},{"title":"Create a BOLT11 invoice","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/lightning/receives/invoice","href":"/barkd/api-reference/lightning/create-a-bolt11-invoice"},{"title":"Create a BOLT11 invoice for an Ark address","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/lightning/receives/invoice/for-address","href":"/barkd/api-reference/lightning/create-a-bolt11-invoice-for-an-ark-address"},{"title":"Get receive status","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/lightning/receives/{identifier}","href":"/barkd/api-reference/lightning/get-receive-status"},{"title":"Cancel a pending receive","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json delete /api/v1/lightning/receives/{identifier}","href":"/barkd/api-reference/lightning/cancel-a-pending-receive"},{"title":"Get send status","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/lightning/sends/{identifier}","href":"/barkd/api-reference/lightning/get-send-status"}]},{"group":"message","pages":[{"title":"Sign a message","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/message/sign","href":"/barkd/api-reference/message/sign-a-message"},{"title":"Verify a signed message","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/message/verify","href":"/barkd/api-reference/message/verify-a-signed-message"}]},{"group":"notifications","pages":[{"title":"Long-poll for wallet notifications","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/notifications/wait","href":"/barkd/api-reference/notifications/long-poll-for-wallet-notifications"},{"title":"Create a websocket ticket","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/notifications/ws/ticket","href":"/barkd/api-reference/notifications/create-a-websocket-ticket"}]},{"group":"nwc","pages":[{"title":"List NWC connections","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/nwc/connections","href":"/barkd/api-reference/nwc/list-nwc-connections"},{"title":"Create a NWC connection","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/nwc/connections","href":"/barkd/api-reference/nwc/create-a-nwc-connection"},{"title":"Revoke a NWC connection","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json delete /api/v1/nwc/connections/{client_pubkey}","href":"/barkd/api-reference/nwc/revoke-a-nwc-connection"},{"title":"List NWC relays","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/nwc/relays","href":"/barkd/api-reference/nwc/list-nwc-relays"},{"title":"Add a NWC relay","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/nwc/relays","href":"/barkd/api-reference/nwc/add-a-nwc-relay"},{"title":"Remove a NWC relay","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json delete /api/v1/nwc/relays/{relay}","href":"/barkd/api-reference/nwc/remove-a-nwc-relay"}]},{"group":"onchain","pages":[{"title":"Generate on-chain address","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/onchain/addresses/next","href":"/barkd/api-reference/onchain/generate-on-chain-address"},{"title":"Get on-chain balance","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/onchain/balance","href":"/barkd/api-reference/onchain/get-on-chain-balance"},{"title":"Drain on-chain wallet","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/onchain/drain","href":"/barkd/api-reference/onchain/drain-on-chain-wallet"},{"title":"Send on-chain payment","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/onchain/send","href":"/barkd/api-reference/onchain/send-on-chain-payment"},{"title":"Send to multiple addresses","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/onchain/send-many","href":"/barkd/api-reference/onchain/send-to-multiple-addresses"},{"title":"Sync on-chain wallet","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/onchain/sync","href":"/barkd/api-reference/onchain/sync-on-chain-wallet"},{"title":"List on-chain transactions","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/onchain/transactions","href":"/barkd/api-reference/onchain/list-on-chain-transactions"},{"title":"List on-chain UTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/onchain/utxos","href":"/barkd/api-reference/onchain/list-on-chain-utxos"}]},{"group":"wallet","pages":[{"title":"Get apiv1wallet","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet","href":"/barkd/api-reference/wallet/get-apiv1wallet"},{"title":"Delete the wallet","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json delete /api/v1/wallet","href":"/barkd/api-reference/wallet/delete-the-wallet"},{"title":"Get Ark address by index","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/addresses/index/{index}","href":"/barkd/api-reference/wallet/get-ark-address-by-index"},{"title":"Generate Ark address","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/addresses/next","href":"/barkd/api-reference/wallet/generate-ark-address"},{"title":"Get Ark server info","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/ark-info","href":"/barkd/api-reference/wallet/get-ark-server-info"},{"title":"Get wallet balance","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/balance","href":"/barkd/api-reference/wallet/get-wallet-balance"},{"title":"Build a BIP 321 payment URI","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/bip321","href":"/barkd/api-reference/wallet/build-a-bip-321-payment-uri"},{"title":"Check server connection","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/connected","href":"/barkd/api-reference/wallet/check-server-connection"},{"title":"Create a wallet","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/create","href":"/barkd/api-reference/wallet/create-a-wallet"},{"title":"Get wallet debug info","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/debug-info","href":"/barkd/api-reference/wallet/get-wallet-debug-info"},{"title":"Get wallet history (deprecated)","deprecated":true,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/history","href":"/barkd/api-reference/wallet/get-wallet-history-deprecated"},{"title":"Import a VTXO","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/import-vtxo","href":"/barkd/api-reference/wallet/import-a-vtxo"},{"title":"Get wallet mnemonic","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/mnemonic","href":"/barkd/api-reference/wallet/get-wallet-mnemonic"},{"title":"List movements (deprecated)","deprecated":true,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/movements","href":"/barkd/api-reference/wallet/list-movements-deprecated"},{"title":"Get next round time","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/next-round","href":"/barkd/api-reference/wallet/get-next-round-time"},{"title":"Offboard all VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/offboard/all","href":"/barkd/api-reference/wallet/offboard-all-vtxos"},{"title":"Offboard specific VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/offboard/vtxos","href":"/barkd/api-reference/wallet/offboard-specific-vtxos"},{"title":"Refresh all VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/refresh/all","href":"/barkd/api-reference/wallet/refresh-all-vtxos"},{"title":"Refresh received VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/refresh/counterparty","href":"/barkd/api-reference/wallet/refresh-received-vtxos"},{"title":"Refresh VTXOs in delegated mode","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/refresh/delegated/vtxos","href":"/barkd/api-reference/wallet/refresh-vtxos-in-delegated-mode"},{"title":"Refresh specific VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/refresh/vtxos","href":"/barkd/api-reference/wallet/refresh-specific-vtxos"},{"title":"List round participations","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/rounds","href":"/barkd/api-reference/wallet/list-round-participations"},{"title":"Send a payment","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/send","href":"/barkd/api-reference/wallet/send-a-payment"},{"title":"Send on-chain from Ark balance","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/send-onchain","href":"/barkd/api-reference/wallet/send-on-chain-from-ark-balance"},{"title":"Sync wallet","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/sync","href":"/barkd/api-reference/wallet/sync-wallet"},{"title":"Sync mailbox only","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/sync/mailbox","href":"/barkd/api-reference/wallet/sync-mailbox-only"},{"title":"List VTXOs","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/vtxos","href":"/barkd/api-reference/wallet/list-vtxos"},{"title":"Get VTXO detail","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/vtxos/{id}","href":"/barkd/api-reference/wallet/get-vtxo-detail"},{"title":"Get encoded VTXO","deprecated":null,"version":null,"openapi":"https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json get /api/v1/wallet/vtxos/{id}/encoded","href":"/barkd/api-reference/wallet/get-encoded-vtxo"}]},{"group":"API Reference","pages":[]}]}]},{"group":"Design patterns","pages":[{"title":"Design patterns","sidebarTitle":"Overview","href":"/patterns/index"},{"group":"Keep bitcoin recoverable","pages":[{"title":"Backups","href":"/patterns/backups"},{"title":"Store the mnemonic securely","sidebarTitle":"Mnemonic storage","href":"/patterns/mnemonic-storage"},{"title":"Restore a wallet","sidebarTitle":"Restore","href":"/patterns/restore"}]},{"group":"Keep VTXOs alive","pages":[{"title":"Run wallet maintenance","sidebarTitle":"Maintenance","href":"/patterns/maintenance"},{"title":"Show refresh fees","sidebarTitle":"Refresh fees","href":"/patterns/refresh-fees"},{"title":"Choose a refresh option","sidebarTitle":"Refresh options","href":"/patterns/refresh-options"},{"title":"Run delegated refreshes from background tasks","sidebarTitle":"Background refresh","href":"/patterns/background-refresh"},{"title":"Decide what a delegated refresh trusts","sidebarTitle":"Delegated co-signer","href":"/patterns/delegated-cosigner"}]},{"group":"Show the wallet truthfully","pages":[{"title":"Display wallet balances","sidebarTitle":"Balances","href":"/patterns/balances"},{"title":"Display expired VTXOs and recoverable balance","sidebarTitle":"Expired VTXOs","href":"/patterns/expired-vtxos"},{"title":"Design payment flows","sidebarTitle":"Payment flows","href":"/patterns/payment-flows"},{"title":"Choose the on-chain payment source","sidebarTitle":"On-chain payment source","href":"/patterns/payment-source"}]},{"group":"Get bitcoin back on-chain","pages":[{"title":"Send on-chain payments and offboard","sidebarTitle":"On-chain payments","description":"Choose between an on-chain payment and an offboard, estimate the fee, track the transaction to confirmation, and check for a running attempt before a retry.","href":"/patterns/on-chain-payments"},{"title":"Handle emergency exits","sidebarTitle":"Exit handling","href":"/patterns/exits"},{"title":"Respond to forced exits","sidebarTitle":"Forced exits","description":"Detect emergency exits forced on your users, keep Bark's automatic response running and funded, and tell users what is happening until their bitcoin is claimed.","href":"/patterns/forced-exits"}]},{"title":"Go live with Bark","sidebarTitle":"Production checklist","href":"/patterns/production-checklist"}]},{"group":"Run an Ark server","pages":[{"title":"Run an Ark server","sidebarTitle":"Overview","href":"/ark-server/index"},{"title":"Set up an Ark server manually","sidebarTitle":"Manual setup","href":"/ark-server/manual-setup"},{"title":"Set up an Ark server with Docker Compose","sidebarTitle":"Docker Compose","href":"/ark-server/docker-compose"},{"title":"Connect a wallet","sidebarTitle":"Connect a wallet","href":"/ark-server/connect-wallet"}]}]},{"tab":"Bark SDK","pages":[{"title":"Bark SDK","href":"/bark-sdk"}]},{"tab":"Barkd","pages":[{"title":"Barkd","href":"/barkd"}]},{"tab":"Apps","menu":[{"item":"Bark Wallet","icon":"https://mintlify.s3.us-west-1.amazonaws.com/second-0659a37d/images/built-with-bark/bark-wallet-logo.svg","description":"A self-custodial wallet app for Ark, Lightning, and on-chain payments","pages":[{"title":"Bark Wallet","href":"/bark-wallet"}]},{"item":"BTCPay Server plugin","icon":"https://mintlify.s3.us-west-1.amazonaws.com/second-0659a37d/images/built-with-bark/btcpay-logo.svg","description":"The simplest way to add Lightning to your checkout","pages":[{"title":"BTCPay Server plugin","href":"/btcpay"}]},{"item":"Bark Pay","icon":"https://mintlify.s3.us-west-1.amazonaws.com/second-0659a37d/images/built-with-bark/bark-pay-logo.svg","description":"Self-hosted bitcoin payments for your store or app","pages":[{"title":"Bark Pay","href":"/bark-pay"}]},{"item":"Swaptopia","icon":"https://mintlify.s3.us-west-1.amazonaws.com/second-0659a37d/images/built-with-bark/swaptopia-logo.svg","description":"Swap between on-chain bitcoin and Lightning from a wallet app in your browser","pages":[{"title":"Swaptopia","href":"/swaptopia"}]}],"pages":[{"title":"Apps","href":"/bark-wallet"}]},{"tab":"Learn","pages":[{"title":"Learn","href":"/learn/intro"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Handle emergency exits - Second Docs","deploymentId":"dpl_9NURmhhAnEA2MBJSAbn1GXd2czCa","buildId":"dpl_9NURmhhAnEA2MBJSAbn1GXd2czCa","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-_5hkXGOV.js","DynamicMarkdown-BGCZRsks.js","zoom-image-lightbox-Dbs6ffOg.js","lightbox-handle-r17bVUz3.js"]}