Repository navigation
Description
Background
Flash is a Bitcoin banking platform for Jamaica. Users who have set JMD as their display currency are seeing incorrect amounts across three critical surfaces: their wallet balance, the send/receive flows, and their transaction history. These are not cosmetic issues — users are losing money on precision truncation and seeing a transaction history that changes every time the BTC price moves.
The bugs span the full stack. The backend serves stale/wrong data from its transaction adaptor layer, and the mobile app compounds the problem with its own conversion errors. Both must be fixed for JMD amounts to be trustworthy end-to-end.
Scope
This bounty covers all three affected surfaces:
Wallet Balance
The BTC wallet balance query (me.btcWallet.balance) currently returns a serialized class object ({}) instead of a number, because BtcWallet.balance serializes the WalletBalance class instance rather than its numeric value.
File: src/graphql/shared/types/object/btc-wallet.ts (~line 49)
Fix: Return Number(balance.asCents(8)) — the raw satoshi count as a number.
Send & Receive Flows
When a JMD user enters an amount (e.g., JMD$1,000) to create a Lightning invoice or send a payment via the USD wallet, the conversion from JMD to USD cents produces a JavaScript float (e.g., 625.78...). This float is sent directly to the GraphQL API, which expects an integer. The API truncates (e.g., to 625), and the user receives or sends a slightly different amount than intended — consistently losing a small amount to rounding error on every transaction.
Root cause: convertMoneyAmount() in use-price-conversion.ts only calls Math.round() when the target currency is BTC. USD conversions are left as floats.
Files:
app/hooks/use-price-conversion.ts (lines 74–81) — missing Math.round() for USD target
app/screens/receive-bitcoin-screen/payment/payment-request.ts (lines 155–167) — float passed to lnUsdInvoiceCreate
app/screens/send-bitcoin-screen/payment-details/intraledger.ts (lines 58–78) — float passed to intraLedgerUsdPaymentSend
Fix: Apply Math.round() to all currency conversion results, not just BTC. Additionally, add a defensive Math.round() at the API mutation call sites so the fix survives future refactoring.
Backend dependency: The backend price service (src/services/price/index.ts) currently derives the JMD/USD rate by triangulating through BTC rather than using the static ExchangeRates.jmd.sell value from config/yaml.ts. This compounds the mobile rounding error because the exchange rate itself is imprecise. The price service fix (see item 3 below) must land before mobile amounts can be validated as correct.
Transaction History
Transaction history is broken at two layers:
Backend layer (lnflash/flash repo):
The transaction history adaptor (src/app/wallets/get-transactions-for-wallet.ts) has four compounding bugs:
Hardcodes displayCurrency: "USD" regardless of the user's actual display currency
Uses the wrong exponent offset when converting the price, producing amounts off by a large factor
Calls Math.floor() on the price, which truncates sub-dollar JMD prices to 0
Does not apply the JMD/USD conversion — JMD users receive USD amounts from the API
Additionally, the price service derives JMD rate via BTC triangulation (src/services/price/index.ts) — it should use the static ExchangeRates.jmd.sell value from config/yaml.ts directly.
Files:
src/app/wallets/get-transactions-for-wallet.ts — fix displayCurrency, offset, Math.floor, and JMD conversion
src/services/price/index.ts — use ExchangeRates.jmd.sell instead of BTC triangulation
Mobile layer (lnflash/flash-mobile repo):
The TxItem component ignores the settlementDisplayAmount field already returned by the API (which contains the correct historical JMD amount locked in at settlement time) and instead re-computes the JMD amount using the current BTC price. This means every BTC transaction in history shows a different JMD amount each time the price moves. The transaction detail screen already does this correctly (using settlementDisplayAmount) — the list should match it.
Additionally, for USD wallet transactions, TxItem multiplies settlementAmount by 100 (tx.settlementAmount * 100), but settlementAmount is already in cents. This inflates all USD wallet transaction amounts by 100×.
For BTC wallet transactions from the Breez SDK, useBreezPayments.ts hardcodes settlementDisplayCurrency: "USD" and converts to USD, ignoring the user's JMD preference entirely.
Files:
app/components/transaction-item/TxItem.tsx (lines 42–60) — use settlementDisplayAmount / settlementDisplayCurrency instead of live price reconversion
app/components/transaction-item/TxItem.tsx (line 55) — remove * 100 for USD wallet amounts
app/hooks/useBreezPayments.ts (lines 13–18, 46–48) — use DisplayCurrency target and user's currency code, not hardcoded USD
Activity
linear commentedon Feb 22, 2026
ENG-132
[-][Bug] Systemic JMD currency precision failures across price pipeline, transaction history, and balance resolver[/-][+][Bug] Fix Systemic display currency precision failures[/+]islandbitcoin commentedon Feb 23, 2026
src/app/wallets/get-transactions-for-wallet.ts, lines ~37-50.That's the adaptor that converts Ibex API responses into the domain transaction format. Four separate bugs in one spot:
offset: 0n(should beSAT_PRICE_PRECISION_OFFSETof 12 orUSD_PRICE_PRECISION_OFFSETof 6)displayCurrency: "USD"hardcoded (ignores user's JMD setting)Math.floor(trx.exchangeRateCurrencySats)truncates per-sat prices like0.00000007to0settlementDisplayAmountandsettlementDisplayFeepass through raw Ibex USD strings, never converted to JMD[-][Bug] Fix Systemic display currency precision failures[/-][+][Bug] JMD Currency Precision — Backend[/+]forge0x commentedon Feb 26, 2026
✅ Backend bugs confirmed via production testing + code review
Cross-referencing flash-mobile#555 evidence:
Confirmed via production testing:
displayCurrency: "USD"hardcoded,offset: 0n,Math.floortruncation, raw USDsettlementDisplayAmount— all confirmed. JMD users see "Sent USD" labels and $8.01 in tx detail instead of ~J$1,240. Video evidencesrc/services/price/index.tslines 58-64.Confirmed via code review:
USDAmountobject instead ofNumber(balance.asCents(8)). BTC wallet enabled on test account — shows ₿0, masking the bug. Would fail on any non-zero balance.price.protoline 5 usesfloat(32-bit), limiting JMD prices to ~7 significant digits.MoneyAmount.tstruncates Ibex's 8-decimal precision to 2 decimal places.onchain-payment-send-all.tssends full balance without subtracting miner fee — confirmed in code, not tested (requires on-chain BTC).Dropped:
Bug 3 (100× inflation):TxItem.tsx* 100path only runs for non-BTC settlements. Lightning settles in BTC, so this code path is never hit with current wallet types. Removed from scope.forge0x commentedon Feb 26, 2026
Bug 4 — BtcWallet.balance returns
{}(code trace)Severity: Medium — backend only, mobile app uses Breez SDK locally
Code Trace
src/services/ibex/client.ts:26— Ibex balance is wrapped inUSDAmountdomain class:src/app/wallets/get-balance-for-wallet.ts:19— Returns theUSDAmountobject directly:src/graphql/shared/types/object/btc-wallet.ts:53— GraphQL resolver returns it asFractionalCentAmount:Fix
Add numeric extraction:
return Number(balanceSats.asCents())(or equivalent). TheUSDAmountclass needs either atoJSON()method or the resolver must extract the numeric value before returning.Mobile Impact
None — the mobile app uses
BreezContext.tsx:83(walletInfo.balanceSatfrom Breez SDK) for BTC balance display, bypassing this GraphQL resolver entirely. Only direct API consumers (web apps, third-party integrations) are affected.27 remaining items
onchito-walks commentedon May 12, 2026
PR submitted: #350
This fixes all three precision bugs described in this issue:
10/10 tests passing. Happy to answer any questions or revise.
Payout address:
1Ast5dKr9z1bLWFBnyh6WDQSgyL7EHJospPlease let me know if anything needs adjustment.
zhaog100 commentedon May 20, 2026
🙋 Claiming this bounty. I'll start work within 24-48h.
fix: JMD currency precision — offset, rounding, display currency, and…
onchito-walks commentedon May 21, 2026
Lightning address for bounty payment on merge:
[email protected][-][Bounty] JMD Currency Precision — Full-Stack Fix[/-][+]JMD Currency Precision — Full-Stack Fix[/+]islandbitcoin commentedon Jun 18, 2026
2026-06-18 — Reframe after the USDT Cash Wallet migration
The custodial Cash Wallet migrated from IBEX USD → USDT. IBEX now returns Cash Wallet amounts as native integer micro-USDT (USD-pegged), so the Cash Wallet display path no longer routes through BTC price / satoshis. For Cash Wallet rows the precision risk collapses to integer/USD handling + at most one USD→JMD conversion — the BTC price-point mapping,
Math.floorsat-truncation, and BTC round-trip drift no longer apply to it.The BTC wallet (Breez, self-custodial) stays fiat-displayed (
TxItemprimary =moneyAmountToDisplayCurrencyString, sats secondary;wallet-overviewkeepsbtcDisplayBalance). Showing BTC amounts in sats-only was considered and deemed too large a change for now, so the BTC↔fiat conversion — and its precision work — stays.Net: nothing in this cluster is obsolete. Scope split:
islandbitcoin commentedon Oct 10, 2026
Bounty cancelled (2026-10-10). The bounty program is closed and the reward attached to this issue is withdrawn. No bounty will be paid for work on it. The issue itself stays open as a regular work item and has been re-prioritized by the core team. Thanks to everyone who proposed an approach.
islandbitcoin commentedon Oct 10, 2026
Priority pass 2026-10-10: rank 8 of 13, kept as the tracker only. After the USDT migration the remaining items are: #284 (adaptor display currency), lnflash/flash-mobile#547 (history converts at today's price), and BTC-wallet balance serialization at btc-wallet.ts:65. Everything else in the body is obsolete.