> ## Documentation Index
> Fetch the complete documentation index at: https://second.tech/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Design patterns

> Design patterns for production wallet apps built on Bark: backups, maintenance, refreshes, truthful balances, payment flows, exits, and a launch checklist.

Design patterns are opinionated answers to the problems every wallet app built on Bark runs into. Each pattern page states one problem, gives the solution with concrete examples, and shows how [Bark Wallet](https://second.tech/docs/bark-wallet.md), Second's reference wallet app, handles it.

## Keep bitcoin recoverable

> [card] [Backups](https://second.tech/docs/patterns/backups.md)
>
> The mnemonic alone recovers a balance only with the server's cooperation. Back up the wallet database continuously to restore everything without it.

> [card] [Mnemonic storage](https://second.tech/docs/patterns/mnemonic-storage.md)
>
> Bark never stores the mnemonic for an SDK app. Store it in each platform's secure storage, or encrypt it in the browser, preferably with a user password.

> [card] [Restore](https://second.tech/docs/patterns/restore.md)
>
> A user reinstalls or changes devices. Restore from the mnemonic or the database backup, and tell them what came back.

## Keep VTXOs alive

> [card] [Maintenance](https://second.tech/docs/patterns/maintenance.md)
>
> VTXOs expire if nobody refreshes them. Keep Bark's background daemon running so it refreshes them in time.

> [card] [Refresh fees](https://second.tech/docs/patterns/refresh-fees.md)
>
> A maintenance refresh can charge a fee users never asked for. Show it on the movement and label it honestly.

> [card] [Refresh options](https://second.tech/docs/patterns/refresh-options.md)
>
> Users are not online when a refresh is due. Pick between interactive, delegated, and scheduled delegated refresh on liveness, trust, and fees.

> [card] [Background refresh](https://second.tech/docs/patterns/background-refresh.md)
>
> iOS and Android suspend a mobile app shortly after the user leaves it. Wake it every few hours and run one delegated pass per wake.

> [card] [Delegated co-signer](https://second.tech/docs/patterns/delegated-cosigner.md)
>
> A delegated refresh runs without the user. Know who they trust while they hold its VTXO, and what a wallet app can recover afterwards.

## Show the wallet truthfully

> [card] [Balances](https://second.tech/docs/patterns/balances.md)
>
> A single number misleads. Show one stable total with labeled pending slices, and never render an unknown amount as zero.

> [card] [Expired VTXOs](https://second.tech/docs/patterns/expired-vtxos.md)
>
> Refreshes get missed. Show users what expired and what they can still recover instead of a silently shrinking balance.

> [card] [Payment flows](https://second.tech/docs/patterns/payment-flows.md)
>
> Payments settle at different speeds per rail. Detect the rail and track each payment until it settles.

> [card] [On-chain payment source](https://second.tech/docs/patterns/payment-source.md)
>
> An on-chain address says nothing about which balance pays. Pick one selection design and apply it to every on-chain send.

## Get bitcoin back on-chain

> [card] [On-chain payments](https://second.tech/docs/patterns/on-chain-payments.md)
>
> The server cooperates. Your app pays an on-chain address or offboards the balance in one transaction: estimate the fee, send, track.

> [card] [Exit handling](https://second.tech/docs/patterns/exits.md)
>
> The server stops cooperating. Your app moves bitcoin back on-chain without it: start, fund, progress, claim.

> [card] [Forced exits](https://second.tech/docs/patterns/forced-exits.md)
>
> A user's VTXO can land on-chain without the user asking. Detect it during sync, fund the exit, and claim the bitcoin.

## Before you launch

> [card] [Production checklist](https://second.tech/docs/patterns/production-checklist.md)
>
> Verify every duty on your own app before you go live: backups restored, refreshes scheduled, balances honest, exits funded.

## Brief your coding agent

Hand this prompt to your coding agent so the duties make it into your implementation plan.

Paste this prompt into your coding agent.

Before you plan this wallet app built on Bark, read [https://second.tech/docs/patterns/production-checklist.md](https://second.tech/docs/patterns/production-checklist.md) and the page each item links to.

Check the finished app against the same checklist.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.