All lessons · Wallets and signing · Start here · Glossary
Count only empty, typeless lock cells as spendable balanceWorkingFrom one fix
From one fix · Check: partly right · Checked 2026-11-19
When computing a wallet's spendable balance from indexer cells under a lock, count only cells with empty output data and no type script as available. A cell with data or any type script (UDT, DOB, profile or attachment cells, not just your own type) holds state, so its capacity stays in the total but is reported as reserved, because spending it would destroy that state. In cemp-mobile this is `const hasData = cell.data !== "0x" && cell.data !== ""; const isProtocol = hasData || type !== null;`.
Why it matters: Without it, data-bearing or typed cells under the wallet's lock are counted as free capacity, so the available balance is overstated and spends or capacity checks can pick cells that hold protocol state.
A test changed in the same commit
It sits next to the fix. We did not run it.
- toastmanAu/cemp-mobile:
packages/cemp-ckb/src/wallet.test.ts,packages/cemp-database/src/lifecycle.test.ts
- Concepts
- Indexer queries and cell collection, Capacity and cell size
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-10-31
- Last changed
- 2026-10-31
- Last checked
- 2026-11-19
- Check against the commit
- partly right: a true core, with a part that is loose or too wide
Sources (1)
- 2026-10-31 · toastmanAu/cemp-mobile · more from this project
More about Wallets and signing
- Address balance via get_cells_capacity with snake_case lock script
- DAO compensation must use the deposit cell's occupied capacity (102 CKB), not 61
- Devnet tests need a real secp256k1 lock to exercise signing
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Count only empty, typeless lock cells as spendable balance", CKB lessons, https://pulse.lusocryptolabs.com/learned/wallets/count-only-empty-typeless-lock-cells-as-spendable-balance, CC BY 4.0, last changed 2026-10-31.