> ## 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.

# Display wallet balances

> Build a balance display users can trust in a wallet app built on Bark: one stable total, labeled sub-balances, and how to show pending and unknown amounts.

A user's bitcoin on Ark is more than one number: spendable sats, an on-chain balance, and amounts locked while a [board](https://second.tech/docs/learn/board.md), round, Lightning payment, or emergency exit runs.

## Put every sat the wallet controls in the total

Make the headline number the sum of everything the wallet controls: the spendable balance, the amount that needs a refresh, and every pending amount. Include the on-chain balance too if your app presents one wallet rather than separate Ark and on-chain views. An operation moves sats between those parts without removing them from the wallet's control, so a total built from all parts holds steady:

* **Board:** Moves on-chain sats into `pending_board_sat`.
* **Refresh:** Moves sats from `spendable_sat` or `needs_refresh_sat` into `pending_in_round_sat` when the wallet locks the inputs. The new VTXOs then arrive in `spendable_sat`.
* **Emergency exit:** Walks sats from `spendable_sat` or `needs_refresh_sat` through `pending_exit_sat` into the on-chain balance. The last step overlaps. Count an exit claim to the wallet's own address once while it shows in both `pending_exit_sat` and the on-chain balance, until Bark marks the exit `claimed`. An exit of the whole wallet also takes the VTXOs that a pending send, Lightning payment, or round has locked. Those sats move from that operation's field to `pending_exit_sat`.

![Diagram of sats moving between the parts of Alice's wallet total during a board, a refresh, and an emergency exit](https://mintcdn.com/second-0659a37d/Gcjn5Ak6i6HjTioT/images/balance-parts.svg?fit=max\&auto=format\&n=Gcjn5Ak6i6HjTioT\&q=85\&s=e364f44db3079298d7fcbf2c960efdc7)

A board, a refresh, and an emergency exit move sats between the on-chain balance and the balance fields, so only their fees change the total

The total moves only when bitcoin enters or leaves the wallet. That happens when a receive arrives, a send goes out, or an operation pays its fee. A board pays an on-chain fee plus the server's board fee. A refresh pays the [refresh fee](https://second.tech/docs/patterns/refresh-fees.md), which leaves the total when the round completes and the wallet receives the new VTXOs. An exit pays CPFP fees plus the claim transaction's fee. While an Ark send runs, `pending_arkoor_send_sat` holds its whole input until the change comes back, so the total holds steady. `pending_offboard_sat` does the same for an on-chain payment or an offboard until its transaction reaches the network.

If your app excludes the on-chain balance from the headline, boards and exit claims move bitcoin between the two displays. Show both totals in that case, so a deposit mid-board never looks like it vanished.

## Break the total into labeled parts

One balance call reports every off-chain part in integer sats: `balance()` in the Bark SDK (`Wallet::balance()` in Rust), `bark balance` on the CLI, or `GET /api/v1/wallet/balance` on Barkd. The wallet computes every field from its local state, so the response is one snapshot, as fresh as the last sync. In the SDK bindings, read each field by its name ending in `Sats`, such as `spendableSats` for `spendable_sat`. Map each field to a label:

| Field | What it holds | Suggested label | What resolves it |
| - | - | - | - |
| `spendable_sat` | Sats your wallet app can spend right now. Expired VTXOs and VTXOs at or above the server's exit depth limit are in `needs_refresh_sat`, not here. Exiting VTXOs stay here, or in `needs_refresh_sat`, until every exit transaction confirms. | Available | Nothing pending. |
| `needs_refresh_sat` | Sats in expired VTXOs and in VTXOs at or above the server's exit depth limit. An Ark send cannot spend them. Your wallet app can still refresh or offboard them. | Needs refresh | Maintenance refreshes them ([expired VTXOs](https://second.tech/docs/patterns/expired-vtxos.md)). |
| `pending_board_sat` | Sats in board transactions waiting for enough confirmations. | Confirming deposit | The server's required confirmations arrive and the next sync registers the board. A board whose funding transaction can no longer confirm fails instead. |
| `pending_in_round_sat` | Sats in the input VTXOs that the wallet has locked for a round that has not completed. | Processing | The round completes and the new VTXOs arrive in `spendable_sat`. If the round fails or is canceled, the inputs return to `spendable_sat` or `needs_refresh_sat`. |
| `pending_arkoor_send_sat` | The whole input of an Ark send that has not completed. | Sending Ark payment | The send finalizes. The change returns to `spendable_sat`, or to `needs_refresh_sat` if it reaches the exit depth limit. |
| `pending_offboard_sat` | Sats locked in an on-chain payment or an offboard whose transaction is not on the network yet. It also holds the change until Bark releases it to `spendable_sat`. | Sending on-chain | The transaction reaches the network. The sent amount leaves the Ark balance. |
| `pending_lightning_send_sat` | Sats locked in an outgoing Lightning payment. | Sending payment | The payment settles, or it fails and the wallet app revokes the HTLC ([payment flows](https://second.tech/docs/patterns/payment-flows.md#set-expectations-when-sending) covers the revocation states). |
| `claimable_lightning_receive_sat` | Sats in the HTLC VTXOs of an incoming Lightning payment, after the wallet reveals the preimage and until the claim completes. The field stays at 0 when the first claim attempt succeeds. | Incoming payment | The wallet app claims the payment during sync. |
| `pending_exit_sat` | Sats whose exit transactions have confirmed, not yet claimed on-chain. | Withdrawing on-chain | The exit delta passes and the wallet app claims the sats into the on-chain balance. |

The on-chain balance is a separate call (`OnchainWallet.balance()` in the SDK, `bark onchain balance`, `GET /api/v1/onchain/balance`). Use its total (`total_sat`, or `totalSats` in the SDK) in a combined headline and label it "On-chain". Cap on-chain spends at `trusted_spendable_sat` (`confirmedSats` in the SDK, which leaves out unconfirmed change).

Two rules keep the breakdown trustworthy:

* **One snapshot per screen:** Fetch the off-chain and on-chain balances together and render every number on screen, headline, breakdown, and charts alike, from that one snapshot. A widget on one fetch and a page on another disagree.
* **Sats in, formatting out:** Every amount in the APIs is an integer number of sats. Sum in sats and convert to BTC or fiat only at the display edge, so rounding cannot feed back into the totals.

Hide sub-balances that are zero. A wallet at rest shows the total and the available amount, nothing else. [Payment flows](https://second.tech/docs/patterns/payment-flows.md) covers the records behind payment history.

To show a user only the headline numbers, call `balanceSummary()` in the Bark SDK (`Balance::summary()` in Rust). It returns the off-chain `spendableSats`, `needsRefreshSats`, `pendingSats`, and `totalSats`. On the CLI and Barkd, sum the fields of the breakdown yourself.

## Show locked sats inside the total, not on top of it

Sats mid-operation are still in the wallet, only not spendable yet. Render each pending amount as a labeled slice of the total, such as a secondary "50,000 sats confirming" line. Never render it as an amount added next to a total that already contains it.

Show the available amount whenever it differs from the total:

* **Cap payment input at `spendable_sat`:** It is the number your send screen validates against.
* **Show `needs_refresh_sat` apart from the available amount:** An Ark send cannot use those VTXOs until a refresh replaces them ([expired VTXOs](https://second.tech/docs/patterns/expired-vtxos.md) covers their display).
* **Expect a withdrawing slice for hours or days:** During an emergency exit, the sats stay in `spendable_sat` or `needs_refresh_sat` until every exit transaction confirms. They then sit in `pending_exit_sat` until the wallet app claims them ([exit handling](https://second.tech/docs/patterns/exits.md) covers the timeline).

> [!NOTE]
>
> **A pending refresh holds only the inputs it has locked**
>
> A participation that still waits for its round locks nothing. Its VTXOs stay in `spendable_sat` or `needs_refresh_sat` until the wallet locks them. The wallet locks them when a round attempt starts (interactive), or once it sees the funding transaction of the round the server issued (delegated). From then on they count once, in `pending_in_round_sat`. Subtract nothing from the total.

## Hold the last known figure when an amount is unknown

A failed or slow fetch is the only unknown. While a sync or balance call is in flight or failing, hold the previous snapshot on screen with a refreshing state instead of flashing zeros. Never substitute zero and never drop a row from the sum. Both make the total dip. `pending_exit_sat` is always present. It reads 0 when no committed exit is waiting for its claim.

> [accordion] How Bark Wallet does it
>
> * **Headline:** [Bark Wallet](https://second.tech/docs/bark-wallet.md) sums the off-chain spendable balance, the amount that needs a refresh, the on-chain balance, unconfirmed on-chain bitcoin, and every pending part into one total. The dashboard shows it in sats with a fiat approximation beneath it.
> * **Breakdown:** The dashboard shows a "Needs refresh" row and the pending parts as [pending sub-balances](https://second.tech/docs/bark-wallet/dashboard.md#pending-sub-balances). It splits the on-chain amount into "On-chain", "Pending on-chain", and "Pending change".
> * **One snapshot:** The headline, the breakdown rows, and the balance chart all read from one function over the same cached data. The balance refreshes every 10 seconds. The on-chain snapshot refreshes every 30 seconds. After an offboard from the VTXOs page, it refreshes every 3 seconds until the transaction shows, for 90 seconds at most.
> * **Zero rows:** The app drops every zero row and hides the whole breakdown while only the off-chain balance is non-zero.


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