Bitcoin Core getbalances: Trusted, Pending, and Immature Wallet Accounting
Bitcoin Core wallet balances are derived from transactions known to a particular wallet, its ownership information and the active chain. They are not a global account balance maintained by Bitcoin consensus. Applications should understand the categories returned by getbalances before presenting a single available amount.
Reading the wallet balance
Use a loaded wallet and query its wallet-specific RPC endpoint. For example, with a wallet named example:
bitcoin-cli -rpcwallet=example getbalances
The mine object contains wallet-owned balance categories. The trusted field includes confirmed outputs and qualifying trusted unconfirmed outputs, such as eligible wallet-created change. The untrusted_pending field represents untrusted unconfirmed balance. The immature field represents coinbase funds that have not yet matured. A watchonly object may be present when applicable to the wallet type and configuration. Do not assume that every wallet exposes the same optional fields.
Trust is not confirmation depth
A trusted output is not necessarily confirmed. A wallet can consider certain unconfirmed change trustworthy for its own spending policy. An application that promises confirmed-only balances should instead inspect output confirmation depth and apply its own minimum-confirmation rule. Conversely, an incoming unconfirmed payment should not be represented as final settlement simply because it appears in wallet accounting.
Amounts and spending authority
RPC amounts are expressed in BTC. Convert them to integer satoshis using exact decimal arithmetic, multiplying by 100000000. Avoid binary floating-point accumulation. A watch-only wallet may know about funds without possessing signing keys. Even a wallet with signing authority may have locked outputs or other spending restrictions. Balance categories alone cannot establish whether a particular payment can be funded.
Consistent application state
Wallet balances can change when a transaction enters or leaves the mempool, a block arrives, a reorganization occurs, or wallet discovery progresses. Record the wallet identity and observation time alongside each response. Where the RPC version supplies a last processed block marker, use it to help identify the wallet's observed chain state. Separate requests are not a guaranteed atomic snapshot. If chain state changes during reconciliation, refresh the relevant observations rather than combining incompatible results.
A payment service should keep confirmed receipts, pending receipts, reserved funds and spendable funds as distinct application concepts. These categories need not map one-to-one to Bitcoin Core's accounting fields. This separation makes balance displays explainable and prevents accidental promises of funds that cannot yet be spent.
Primary references
https://bitcoincore.org/en/doc/28.0.0/rpc/wallet/getbalances/
https://bitcoincore.org/en/doc/28.0.0/rpc/wallet/listunspent/
https://bitcoincore.org/en/doc/28.0.0/rpc/wallet/getwalletinfo/
