[PR #6044] [CLOSED] Add BTC currency #40719

Closed
opened 2026-04-23 13:32:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/6044
Author: @StephenBrown2
Created: 10/31/2025
Status: Closed

Base: masterHead: add-bitcoin-currency


📝 Commits (2)

  • 316029d Adds Bitcoin currency support
  • 25a0c67 Adds support for Bitcoin currency formatting

📊 Changes

7 files changed (+465 additions, -24 deletions)

View changed files

📝 packages/desktop-client/src/components/settings/Currency.tsx (+1 -0)
📝 packages/desktop-client/src/hooks/useFormat.ts (+7 -16)
📝 packages/loot-core/src/shared/currencies.ts (+1 -0)
📝 packages/loot-core/src/shared/util.test.ts (+228 -0)
📝 packages/loot-core/src/shared/util.ts (+220 -6)
📝 tsconfig.json (+2 -2)
upcoming-release-notes/6044.md (+6 -0)

📄 Description

This pull request adds support for Bitcoin (BTC) as a currency, including custom formatting for Bitcoin and satoshi amounts using the Satcomma standard. It introduces a new number format ("sat-comma") that improves readability for Bitcoin fractions and ensures correct display in both the UI and formatting utilities. Comprehensive tests have been added to verify the new formatting logic and currency handling.

The "Satcomma" formatting is for convenience, but if it adds too much complexity since I wanted a full drop-in replacement for Intl.NumberFormat, we can drop all commits but the first and rely on the regular comma-dot format instead.

Bitcoin currency support and formatting:

  • Added Bitcoin (BTC) to the currency selection UI (CurrencySettings component) and to the currencies list with appropriate symbol, 8 decimal places, and the new sat-comma number format. [1] [2]
  • Introduced the sat-comma number format to the available formats and UI labels, following the Satcomma standard for grouping fractional digits in Bitcoin amounts. [1] [2]

Custom number formatting for Bitcoin:

  • Implemented the SatNumberFormat class to handle Bitcoin/Satoshi formatting, including grouping fractional digits with narrow non-breaking spaces and converting amounts to satoshis when fractions are hidden.
  • Updated the getNumberFormat function to use SatNumberFormat for sat-comma formatting and ensured correct integration with existing formatting logic. [1] [2]

Formatting logic and utility updates:

  • Adjusted formatting utilities (integerToCurrency, integerToCurrencyWithDecimal) to support 8 decimal places for Bitcoin and correctly handle sat-comma formatting.
  • Refactored formatting logic in useFormat hook to properly use the new hideFraction and decimal place rules for financial types, including support for Bitcoin. [1] [2]

Testing enhancements:

  • Added comprehensive tests for sat-comma formatting, Bitcoin currency display, and related utility functions to ensure correctness across various scenarios. [1] [2] [3]

Bitcoin compatibility with existing MAX_SAFE_NUMBER

The app's existing architecture using 2^51 - 1 (approximately 2.25 quadrillion) as MAX_SAFE_NUMBER is sufficient for Bitcoin without modification.

Key Facts:

  • 1 BTC = 100,000,000 satoshis (smallest unit: 0.00000001 BTC)
  • Bitcoin total supply = 21 million BTC = 2.1 quadrillion satoshis
  • App can handle: 2.25 quadrillion satoshis = 22.5 million BTC

Conclusion: The existing MAX_SAFE_NUMBER exceeds Bitcoin's total supply by ~7%, providing adequate headroom. No changes to MAX_SAFE_NUMBER are required.

Screenshots

With just the basic currency details added (88045c4):
Screenshot from 2025-11-03 12-10-22

With the custom SatComma formatting, which adds spaces among the fractional part:
Screenshot from 2025-11-03 12-11-37
Screenshot from 2025-11-03 12-12-32


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/6044 **Author:** [@StephenBrown2](https://github.com/StephenBrown2) **Created:** 10/31/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `add-bitcoin-currency` --- ### 📝 Commits (2) - [`316029d`](https://github.com/actualbudget/actual/commit/316029d65ddd96b2d013eb8b00e378384d17848c) Adds Bitcoin currency support - [`25a0c67`](https://github.com/actualbudget/actual/commit/25a0c67f58c504d8d976beec8c17fb28106e25ba) Adds support for Bitcoin currency formatting ### 📊 Changes **7 files changed** (+465 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/settings/Currency.tsx` (+1 -0) 📝 `packages/desktop-client/src/hooks/useFormat.ts` (+7 -16) 📝 `packages/loot-core/src/shared/currencies.ts` (+1 -0) 📝 `packages/loot-core/src/shared/util.test.ts` (+228 -0) 📝 `packages/loot-core/src/shared/util.ts` (+220 -6) 📝 `tsconfig.json` (+2 -2) ➕ `upcoming-release-notes/6044.md` (+6 -0) </details> ### 📄 Description This pull request adds support for Bitcoin (BTC) as a currency, including custom formatting for Bitcoin and satoshi amounts using the Satcomma standard. It introduces a new number format ("sat-comma") that improves readability for Bitcoin fractions and ensures correct display in both the UI and formatting utilities. Comprehensive tests have been added to verify the new formatting logic and currency handling. The "Satcomma" formatting is for convenience, but if it adds too much complexity since I wanted a full drop-in replacement for Intl.NumberFormat, we can drop all commits but the first and rely on the regular comma-dot format instead. **Bitcoin currency support and formatting:** * Added Bitcoin (`BTC`) to the currency selection UI (`CurrencySettings` component) and to the `currencies` list with appropriate symbol, 8 decimal places, and the new `sat-comma` number format. [[1]](diffhunk://#diff-9b0bd6bc744bfd4afac03d8e6db423fa69216ff2dac2272f2a5dba73494e14ccR28) [[2]](diffhunk://#diff-e58604b34393a62d237d3e6c3c8f02502c9c3857eabb3be763b2e5a47c185068R28) * Introduced the `sat-comma` number format to the available formats and UI labels, following the Satcomma standard for grouping fractional digits in Bitcoin amounts. [[1]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfL263-R263) [[2]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfR287-R291) **Custom number formatting for Bitcoin:** * Implemented the `SatNumberFormat` class to handle Bitcoin/Satoshi formatting, including grouping fractional digits with narrow non-breaking spaces and converting amounts to satoshis when fractions are hidden. * Updated the `getNumberFormat` function to use `SatNumberFormat` for `sat-comma` formatting and ensured correct integration with existing formatting logic. [[1]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfR497-R501) [[2]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfR523-R533) **Formatting logic and utility updates:** * Adjusted formatting utilities (`integerToCurrency`, `integerToCurrencyWithDecimal`) to support 8 decimal places for Bitcoin and correctly handle sat-comma formatting. * Refactored formatting logic in `useFormat` hook to properly use the new `hideFraction` and decimal place rules for financial types, including support for Bitcoin. [[1]](diffhunk://#diff-4d927b5c3d05bf6ad49d88bb4c2d0fe771895e381ef4b5746846055871b73959L167-R174) [[2]](diffhunk://#diff-4d927b5c3d05bf6ad49d88bb4c2d0fe771895e381ef4b5746846055871b73959R226) **Testing enhancements:** * Added comprehensive tests for sat-comma formatting, Bitcoin currency display, and related utility functions to ensure correctness across various scenarios. [[1]](diffhunk://#diff-80112f2782bc3272bb7e0252d315d508cc0e449e7a6f4cf077d11c03245b5dc7R7-R9) [[2]](diffhunk://#diff-80112f2782bc3272bb7e0252d315d508cc0e449e7a6f4cf077d11c03245b5dc7R100-R112) [[3]](diffhunk://#diff-80112f2782bc3272bb7e0252d315d508cc0e449e7a6f4cf077d11c03245b5dc7R200-R247) **Bitcoin compatibility with existing MAX_SAFE_NUMBER** The app's existing architecture using **2^51 - 1** (approximately **2.25 quadrillion**) as MAX_SAFE_NUMBER is sufficient for Bitcoin without modification. **Key Facts:** - 1 BTC = 100,000,000 satoshis (smallest unit: 0.00000001 BTC) - Bitcoin total supply = 21 million BTC = 2.1 quadrillion satoshis - App can handle: 2.25 quadrillion satoshis = **22.5 million BTC** **Conclusion:** The existing MAX_SAFE_NUMBER exceeds Bitcoin's total supply by ~7%, providing adequate headroom. No changes to MAX_SAFE_NUMBER are required. **Screenshots** With just the basic currency details added ([88045c4](https://github.com/actualbudget/actual/pull/6044/commits/88045c465c309a3f482a884c339f73bad5561855)): <img width="778" height="416" alt="Screenshot from 2025-11-03 12-10-22" src="https://github.com/user-attachments/assets/41b935dc-4010-46ce-a320-8def3b4b726f" /> With the custom SatComma formatting, which adds spaces among the fractional part: <img width="778" height="416" alt="Screenshot from 2025-11-03 12-11-37" src="https://github.com/user-attachments/assets/30ceef8a-0f36-4ee7-8bc4-bcfc4257fcaf" /> <img width="269" height="178" alt="Screenshot from 2025-11-03 12-12-32" src="https://github.com/user-attachments/assets/fc3eacab-c18a-41e9-bb32-c5f6c40399cb" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 13:32:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#40719