Skip to content

feat: add getBalance() to WalletCore#5

Open
MatiasJF wants to merge 1 commit intomainfrom
fix/wallet-balance
Open

feat: add getBalance() to WalletCore#5
MatiasJF wants to merge 1 commit intomainfrom
fix/wallet-balance

Conversation

@MatiasJF
Copy link
Copy Markdown
Collaborator

@MatiasJF MatiasJF commented Mar 27, 2026

Summary

  • Add getBalance(basket?) method to WalletCore — available on both browser and server wallets
  • Without basket: uses wallet-toolbox specOpWalletBalance for optimized balance query (computed at storage layer, no output iteration)
  • With basket: iterates outputs to calculate total and spendable satoshis separately
  • Add BalanceResult type exported from all entry points
  • 17 unit tests covering specOp mode, basket mode, edge cases (null results, undefined satoshis, non-spendable outputs), and error propagation
  • Update CLAUDE.md, API reference docs, guides, and test app
  • Bump version 0.2.90.3.0

Test plan

  • All 60 unit tests pass (17 new + 43 existing)
  • npm run build compiles cleanly
  • Test app updated to use getBalance() for both browser and server balance checks
  • Manual verification in payment-test-app

🤖 Generated with Claude Code

Add wallet balance querying to WalletCore, available on both browser and
server wallets. Without a basket argument, uses the wallet-toolbox
specOpWalletBalance optimized query (balance computed at storage layer).
With a basket, iterates outputs to compute total and spendable satoshis.

- Add BalanceResult type (totalSatoshis, totalOutputs, spendableSatoshis, spendableOutputs)
- Export BalanceResult from index.ts and server.ts
- Add 17 unit tests covering specOp mode, basket mode, edge cases, and error handling
- Update CLAUDE.md, docs, and API reference
- Bump version to 0.3.0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants