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_satorneeds_refresh_satintopending_in_round_satwhen the wallet locks the inputs. The new VTXOs then arrive inspendable_sat. - Emergency exit: Walks sats from
spendable_satorneeds_refresh_satthroughpending_exit_satinto the on-chain balance. The last step overlaps. Count an exit claim to the wallet’s own address once while it shows in bothpending_exit_satand the on-chain balance, until Bark marks the exitclaimed. 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 topending_exit_sat.
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
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:
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.
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_satapart from the available amount: An Ark send cannot use those VTXOs until a refresh replaces them (expired VTXOs covers their display). - Expect a withdrawing slice for hours or days: During an emergency exit, the sats stay in
spendable_satorneeds_refresh_satuntil every exit transaction confirms. They then sit inpending_exit_satuntil the wallet app claims them (exit handling covers the timeline).
A pending refresh holds only the inputs it has lockedA 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.
How Bark Wallet does it
How Bark Wallet does it
- Headline: Bark Wallet 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. 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.