From e35764950b59bde6e36bdfad1ca671eef564a6d1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 8 Oct 2026 16:34:06 -0700 Subject: Max fills the amount in the unit the field shows: in fiat that's money floored to the cent (so it never parses back above the maximum), not a BTC figure under a CAD label. One ctx.amountField helper for the ark send/LN Max, the gift Max and fixed-amount zap/BOLT 12 fills Co-Authored-By: Claude Opus 5.5 --- src/app.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/app.js') diff --git a/src/app.js b/src/app.js index 1e77849..122ccfe 100644 --- a/src/app.js +++ b/src/app.js @@ -1151,6 +1151,16 @@ function toggleUnit() { render(); } +// A sats figure as the amount field types it in the current unit — what a +// Max button or a fixed-amount invoice fills in. Fiat is floored to the +// cent so a filled-in maximum never parses back to more than was offered. +function amountField(sat) { + if (unit === 'sats') return String(sat); + const r = unit === 'fiat' && rateNow(); + if (r) return (Math.floor((sat / 1e8) * r * 100) / 100).toFixed(2); + return (sat / 1e8).toFixed(8); +} + const unitLabel = () => (unit === 'sats' ? 'sats' : unit === 'fiat' ? getCurrency() : 'BTC'); // "Worth X then · Y now" for a payment's detail page — the one place both @@ -5951,7 +5961,7 @@ const ctx = { openWalletSettings: (view) => openWalletSettings(view), // one page of the Settings hub, from anywhere (Notifications' gear) openSettingsPage: (page) => { clearFeatureNav(); ui.screen = 'wallet'; ui.tab = 'settings'; ui.settingsPage = page; render(); try { window.scrollTo(0, 0); } catch {} }, - fmtAmount, unitLabel, unitTag, getUnit: () => unit, toggleUnit, download, + fmtAmount, unitLabel, unitTag, getUnit: () => unit, toggleUnit, download, amountField, // in fiat the typed figure is money, so it needs today's price to become sats parseAmount: (v, u) => parseAmount(v, u, rateNow()), worthLine, -- cgit v1.2.3