Skip to content

feat(ecash): introduce custom unit ecash support#325

Open
a1denvalu3 wants to merge 13 commits into
mainfrom
feature/custom-unit-ecash
Open

feat(ecash): introduce custom unit ecash support#325
a1denvalu3 wants to merge 13 commits into
mainfrom
feature/custom-unit-ecash

Conversation

@a1denvalu3

Copy link
Copy Markdown
Collaborator

This PR introduces support for custom unit ecash (units different from sat that mints may advertise).

Objectives:

The core objective is to disable fiat currency conversions and format inputs 1:1 if a unit other than sat is selected as the base unit.

Updates include:

  • MintManager: Added a new setting to store the active preferredBaseUnit to allow selecting and tracking units outside sat.
  • CashuWalletManager: Replaced all hardcoded usages of CurrencyUnit.Sat dynamically with the preferredBaseUnit. Whenever the unit changes, a wallet rebuild is triggered to re-bind the CDK wallet.
  • AmountDisplayManager & TransactionDetailActivity: Hidden UI components for currency switching and fiat conversions when a non-sat unit is active. Implemented verbatim custom unit printing string structures (e.g. 150 mxn).
  • TipSelectionActivity & PaymentRequestActivity: Adjusted the logic to omit the toggle custom currency interactions if we're not operating with standard satoshis.
  • MintsSettingsActivity: Implemented Option B functionality; exposed a new selectable row below the active Lightning Mint card where users can swap their Base Currency Unit (pulling values dynamically from the parsed MintLimits methods).

This commit introduces support for custom unit ecash (units different from "sat" that mints may advertise) across the Numo application. The core objective is to disable fiat currency conversions and format inputs 1:1 if a unit other than "sat" is selected as the base unit.

Updates include:
- `MintManager`: Added a new setting to store the active `preferredBaseUnit` to allow selecting and tracking units outside "sat".
- `CashuWalletManager`: Replaced all hardcoded usages of `CurrencyUnit.Sat` dynamically with the `preferredBaseUnit`. Whenever the unit changes, a wallet rebuild is triggered to re-bind the CDK wallet.
- `AmountDisplayManager` & `TransactionDetailActivity`: Hidden UI components for currency switching and fiat conversions when a non-sat unit is active. Implemented verbatim custom unit printing string structures (e.g. `150 mxn`).
- `TipSelectionActivity` & `PaymentRequestActivity`: Adjusted the logic to omit the toggle custom currency interactions if we're not operating with standard satoshis.
- `MintsSettingsActivity`: Implemented Option B functionality; exposed a new selectable row below the active Lightning Mint card where users can swap their "Base Currency Unit" (pulling values dynamically from the parsed `MintLimits` methods).
If a custom unit is technically a known fiat currency code (like "usd", "eur"), map it using the `Amount.Currency` formatting utility so it displays as "$1.50" rather than verbatim "150 usd". This addresses the edge cases where custom units perfectly map to standard fiat.
All UI components, test suites, and wallet abstractions properly integrate with the newly resolved `Amount.Currency` structures.
This correctly handles the fiat currency preference in `SettingsActivity` to prevent users from interacting with it when a custom base unit is currently set. The row is greyed out (opacity lowered to 0.5f) and tapping it will surface a descriptive Toast letting the user know they must revert back to standard `sat` first.
This replaces hardcoded internal string/formatting references that assumed "₿" with "sat", standardising eCash references safely alongside custom unit implementations. Also fixes the test suites that broke when the number formatting rules adapted.
Use `style="@style/Text.RowSubtitle"` instead of `android:textAppearance` to ensure the subtitle receives the correct text color attributes (grey), matching the other settings rows. Also added the missing 2dp top margin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant