You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Transaction history adaptor shows wrong settlement display price for JMD users #284
The transaction history adaptor (src/app/wallets/get-transactions-for-wallet.ts) serves incorrect display amounts for JMD users. Since Ibex IS the ledger and Flash has no server-side ledger for Ibex-settled transactions, this adaptor is the only place to fix display amounts — if it's wrong, every historical transaction displays wrong, retroactively.
The Bugs
1. Hardcoded USD instead of user display currency
The adaptor returns USD as the display currency and does not convert the settlement amount to the user's configured currency (JMD). This means both the currency label and the numeric value are wrong — JMD users see raw USD amounts labeled as their display currency. One fix: pass the user's display currency into the adaptor and apply the conversion.
2. Wrong offset in pagination/conversion
An offset error causes transactions to map to incorrect price points, shifting which rate gets applied to which transaction.
3. Math.floor truncates fractional amounts
Math.floor on converted amounts silently drops fractional JMD cents. For small BTC transactions, this can truncate the display amount to 0.
Why This Matters
Flash has no server-side ledger for Ibex-settled transactions — Ibex is the ledger
Transaction history is fetched live from the Ibex API every time
This adaptor is the single point of truth for display amounts
Every JMD user sees wrong amounts on every historical transaction, retroactively
File
src/app/wallets/get-transactions-for-wallet.ts
Fix Approach
Pass the user's configured display currency into the adaptor; use it for both the label and the USD→JMD conversion
Fix the offset logic for correct price mapping
Replace Math.floor with proper rounding (Math.round)
Priority
Urgent — this affects every JMD user's transaction history on every page load.
I'd like to work on this issue as part of the JMD currency precision bundle (#282).
Approach for src/app/wallets/get-transactions-for-wallet.ts:
Hardcoded USD fix: Pull the authenticated user's displayCurrency setting from the user resolver and thread it into the adaptor call. In the adaptor, replace the hardcoded 'USD' string with the user's actual currency code. If displayCurrency === 'JMD', apply the JMD/USD exchange rate from config/yaml.ts.
Offset fix: Apply the correct precision offset constant (SAT_PRICE_PRECISION_OFFSET = 12 for BTC→USD, USD_PRICE_PRECISION_OFFSET = 6 for USD→JMD) when computing settlementDisplayAmount. The current offset: 0n skips this scaling entirely.
Math.floor → Math.round: Replace truncation with rounding so small BTC transactions don't silently round to 0 JMD.
ETA: 1–2 days for the backend fix with tests. I'll coordinate with the mobile companion fix (#555 on flash-mobile) so both land together.
Proposing to fix the transaction history adaptor for JMD users.
Root Cause (confirmed from analysis):
The adaptor in src/app/wallets/get-transactions-for-wallet.ts has multiple compounding bugs for JMD users. This is a subset of the full-stack fix in #282, but isolated to the backend adaptor layer.
Specific fixes needed:
1. Hardcoded USD display currency:
// Current (wrong):
displayCurrency: 'USD'// Fix:
displayCurrency: user.displayCurrency||'USD'
2. Wrong exponent offset in price conversion:
The price conversion uses an incorrect power-of-10 offset. JMD/USD rates are ~140, so the exponent shift produces values off by orders of magnitude.
Fix: verify the correct satoshi → JMD conversion: (satsAmount / 1e8) * btcPriceUSD * jmdRate
3. Math.floor() truncating sub-dollar JMD values to 0:
Replace Math.floor(price) with Math.round(price * 100) / 100 (preserve 2 decimal places for JMD)
4. Missing JMD conversion:
After computing the USD amount, apply: usdAmount * ExchangeRates.jmd.sell for JMD users
5. Price service (src/services/price/index.ts):
Use config.ExchangeRates.jmd.sell directly instead of BTC triangulation to avoid compounding precision errors.
Timeline: Backend fix + tests within 48 hours. This is well-scoped to the adaptor layer. Ready to start immediately.
I've analyzed the source code in src/app/wallets/get-transactions-for-wallet.ts and identified the root causes. Here's my fix proposal:
Root Cause Analysis
Bug 1 — Hardcoded displayCurrency: "USD" toWalletTransactions() hardcodes displayCurrency: "USD" as DisplayCurrency in the settlementDisplayPrice object. JMD users see "USD" labels.
Bug 2 — offset: 0n breaks exchange rate representation
The offset: 0n combined with BigInt(Math.floor(trx.exchangeRateCurrencySats)) means small exchange rates (< 1 sat per unit) floor to 0n, making the price zero. For JMD, exchangeRateCurrencySats ≈ 0.00065, so BigInt(Math.floor(0.00065)) = 0n.
Bug 3 — Math.floor truncates to zero
For any exchangeRateCurrencySats < 1, BigInt(Math.floor(...)) yields 0n. The codebase already handles this correctly in priceAmountFromNumber() (src/domain/fiat/display-currency.ts) using 10 ** offset scaling.
Fix
The fix follows the existing pattern in display-currency.ts:priceAmountFromNumber():
2026-06-18 — Reframe (USDT migration): this shrinks. The IBEX adaptor (src/app/wallets/get-transactions-for-wallet.ts) handles only USD/USDT accounts, and with the Cash Wallet now USDT it no longer routes display through BTC price. So bug #2 (price-point offset) and #3 (Math.floor truncation) are now obsolete for this adaptor. What remains is #1: use the user's display currency for the primary amount + a single USD→JMD conversion on Cash/IBEX rows. The BTC wallet's JMD display is a separate path (Breez) and is unchanged.
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. (This issue was part of the #282 bundle.)
Priority pass 2026-10-10: rank 3 of 13. Remaining scope after the Jun 18 reframe is bug 1 only: get-transactions-for-wallet.ts:69 hardcodes displayCurrency USD and does no USD to JMD conversion. Pairs with lnflash/flash-mobile#547 on the client side. Most visible correctness bug left for JMD users.
Activity
linear commentedon Feb 23, 2026
ENG-137
chengyixu commentedon Mar 21, 2026
Proposal — Transaction History Adaptor Fix
I'd like to work on this issue as part of the JMD currency precision bundle (#282).
Approach for
src/app/wallets/get-transactions-for-wallet.ts:Hardcoded USD fix: Pull the authenticated user's
displayCurrencysetting from the user resolver and thread it into the adaptor call. In the adaptor, replace the hardcoded'USD'string with the user's actual currency code. IfdisplayCurrency === 'JMD', apply the JMD/USD exchange rate fromconfig/yaml.ts.Offset fix: Apply the correct precision offset constant (
SAT_PRICE_PRECISION_OFFSET = 12for BTC→USD,USD_PRICE_PRECISION_OFFSET = 6for USD→JMD) when computingsettlementDisplayAmount. The currentoffset: 0nskips this scaling entirely.Math.floor → Math.round: Replace truncation with rounding so small BTC transactions don't silently round to 0 JMD.
ETA: 1–2 days for the backend fix with tests. I'll coordinate with the mobile companion fix (#555 on flash-mobile) so both land together.
Lightning address: [email protected]
Please confirm and I'll open a draft PR.
chengyixu commentedon Mar 21, 2026
Proposing to fix the transaction history adaptor for JMD users.
Root Cause (confirmed from analysis):
The adaptor in
src/app/wallets/get-transactions-for-wallet.tshas multiple compounding bugs for JMD users. This is a subset of the full-stack fix in #282, but isolated to the backend adaptor layer.Specific fixes needed:
1. Hardcoded USD display currency:
2. Wrong exponent offset in price conversion:
The price conversion uses an incorrect power-of-10 offset. JMD/USD rates are ~140, so the exponent shift produces values off by orders of magnitude.
Fix: verify the correct satoshi → JMD conversion:
(satsAmount / 1e8) * btcPriceUSD * jmdRate3. Math.floor() truncating sub-dollar JMD values to 0:
Replace
Math.floor(price)withMath.round(price * 100) / 100(preserve 2 decimal places for JMD)4. Missing JMD conversion:
After computing the USD amount, apply:
usdAmount * ExchangeRates.jmd.sellfor JMD users5. Price service (src/services/price/index.ts):
Use
config.ExchangeRates.jmd.selldirectly instead of BTC triangulation to avoid compounding precision errors.Timeline: Backend fix + tests within 48 hours. This is well-scoped to the adaptor layer. Ready to start immediately.
xyaz1313 commentedon Apr 15, 2026
I've analyzed the source code in
src/app/wallets/get-transactions-for-wallet.tsand identified the root causes. Here's my fix proposal:Root Cause Analysis
Bug 1 — Hardcoded
displayCurrency: "USD"toWalletTransactions()hardcodesdisplayCurrency: "USD" as DisplayCurrencyin thesettlementDisplayPriceobject. JMD users see "USD" labels.Bug 2 —
offset: 0nbreaks exchange rate representationThe
offset: 0ncombined withBigInt(Math.floor(trx.exchangeRateCurrencySats))means small exchange rates (< 1 sat per unit) floor to0n, making the price zero. For JMD,exchangeRateCurrencySats≈ 0.00065, soBigInt(Math.floor(0.00065))=0n.Bug 3 —
Math.floortruncates to zeroFor any
exchangeRateCurrencySats< 1,BigInt(Math.floor(...))yields0n. The codebase already handles this correctly inpriceAmountFromNumber()(src/domain/fiat/display-currency.ts) using10 ** offsetscaling.Fix
The fix follows the existing pattern in
display-currency.ts:priceAmountFromNumber():Changes summary:
displayCurrencyparam (default:"USD") to both functionsBigInt(Math.floor(...))withMath.round(exchangeRate * 10^12)— preserves precisionoffset: BigInt(SAT_PRICE_PRECISION_OFFSET)instead of0n— followspriceAmountFromNumber()patterndisplayCurrencyinstead of hardcoded"USD"Happy to submit a PR if this approach looks right.
fix: JMD transaction display currency - hardcoded USD, offset, and Ma…
fix: Transaction history adaptor - hardcoded USD, wrong offset, Math.…
islandbitcoin commentedon Jun 18, 2026
2026-06-18 — Reframe (USDT migration): this shrinks. The IBEX adaptor (
src/app/wallets/get-transactions-for-wallet.ts) handles only USD/USDT accounts, and with the Cash Wallet now USDT it no longer routes display through BTC price. So bug #2 (price-point offset) and #3 (Math.floortruncation) are now obsolete for this adaptor. What remains is #1: use the user's display currency for the primary amount + a single USD→JMD conversion on Cash/IBEX rows. The BTC wallet's JMD display is a separate path (Breez) and is unchanged.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. (This issue was part of the #282 bundle.)
islandbitcoin commentedon Oct 10, 2026
Priority pass 2026-10-10: rank 3 of 13. Remaining scope after the Jun 18 reframe is bug 1 only: get-transactions-for-wallet.ts:69 hardcodes displayCurrency USD and does no USD to JMD conversion. Pairs with lnflash/flash-mobile#547 on the client side. Most visible correctness bug left for JMD users.
nul-quill commentedon Oct 11, 2026
Handle: nul-quill. Payout wallets: Solana USDC BdznDjc4xwt5Y6WJT5UnrFQzDptka8YnC9oqmmkKpwkd, TRC20 TNEHCVwR2aPMrj5AKfWCQ2rFL3bEDQmsg7.