diff options
| author | Adam Soltys <[email protected]> | 2026-10-08 16:34:06 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-08 16:34:06 -0700 |
| commit | e35764950b59bde6e36bdfad1ca671eef564a6d1 (patch) | |
| tree | a72a950e6e8ffd21312b6e2610ee7c73092026bc /src/app.js | |
| parent | d3a0af140dabdd6b53c1be0532b37f28254633be (diff) | |
| download | coinosv3-e35764950b59bde6e36bdfad1ca671eef564a6d1.tar.gz coinosv3-e35764950b59bde6e36bdfad1ca671eef564a6d1.zip | |
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 <[email protected]>
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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, |
