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/features/ark.js | 4 ++-- src/features/gifts.js | 2 +- src/features/zaps.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/features') diff --git a/src/features/ark.js b/src/features/ark.js index 90b2a01..d5b6e7f 100644 --- a/src/features/ark.js +++ b/src/features/ark.js @@ -1223,7 +1223,7 @@ export function arkFeature(ctx) { } return Math.max(0, amt); } - const amountFill = (sat) => (ctx.getUnit() === 'sats' ? String(sat) : (sat / 1e8).toFixed(8)); + const amountFill = (sat) => ctx.amountField(sat); // Auto-pay progress + success as ONE structurally identical card, so the // paying → paid step is a class flip (spinner ring settles into the green @@ -3651,7 +3651,7 @@ export function arkFeature(ctx) { ? (arkBalance()?.spendableSat || 0) : maxBoardSat(); if (!sat) return null; - return ctx.getUnit() === 'sats' ? String(sat) : (sat / 1e8).toFixed(8); + return ctx.amountField(sat); }, sendFormNote(a) { if (!isArkAddress(a)) return null; diff --git a/src/features/gifts.js b/src/features/gifts.js index 052a107..4d68a50 100644 --- a/src/features/gifts.js +++ b/src/features/gifts.js @@ -675,7 +675,7 @@ export function giftsFeature(ctx) { return h('div', { class: 'input-group' }, h('input', { type: 'number', step: getUnit() === 'sats' ? '1' : '0.00000001', min: '0', inputmode: 'decimal', placeholder: t('giftAmountLabel'), disabled: ui.giftMax, - value: ui.giftMax ? (getUnit() === 'sats' ? String(maxVal) : fmtBtc(maxVal)) : ui.giftAmount, + value: ui.giftMax ? ctx.amountField(maxVal) : ui.giftAmount, onInput: (e) => (ui.giftAmount = e.target.value) }), h('button', { type: 'button', class: ui.giftMax ? 'btn-primary' : '', onClick: () => { ui.giftMax = !ui.giftMax; ui.giftError = ''; render(); } }, t('max')), h('div', { style: 'display:flex;align-items:center' }, unitTag()) diff --git a/src/features/zaps.js b/src/features/zaps.js index a23ecdd..d327f9d 100644 --- a/src/features/zaps.js +++ b/src/features/zaps.js @@ -94,7 +94,7 @@ export function zapsFeature(ctx) { const off = target.offer; if (off.currency) throw new Error(t('bolt12Currency', { currency: off.currency })); const fixedSat = off.amountMsat ? Number((off.amountMsat + 999n) / 1000n) : null; - if (fixedSat) z.amount = getUnit() === 'sats' ? String(fixedSat) : (fixedSat / 1e8).toFixed(8); + if (fixedSat) z.amount = ctx.amountField(fixedSat); z.params = { minSendable: 1000, maxSendable: 21e15, commentAllowed: 0, allowsNostr: false, fixedSat }; z.status = 'ready'; render(); @@ -118,7 +118,7 @@ export function zapsFeature(ctx) { return; } const fixedSat = n.priceType === 0 && n.priceSats ? n.priceSats : null; - if (fixedSat) z.amount = getUnit() === 'sats' ? String(fixedSat) : (fixedSat / 1e8).toFixed(8); + if (fixedSat) z.amount = ctx.amountField(fixedSat); z.params = { minSendable: 1000, maxSendable: 21e15, commentAllowed: 100, allowsNostr: false, fixedSat }; z.status = 'ready'; render(); @@ -165,7 +165,7 @@ export function zapsFeature(ctx) { // exactly like a fixed-amount BOLT 12 offer. if (params.minSendable === params.maxSendable && params.minSendable >= 1000) { params.fixedSat = Math.ceil(params.minSendable / 1000); - z.amount = getUnit() === 'sats' ? String(params.fixedSat) : (params.fixedSat / 1e8).toFixed(8); + z.amount = ctx.amountField(params.fixedSat); } z.params = params; z.status = 'ready'; @@ -363,7 +363,7 @@ export function zapsFeature(ctx) { !p.fixedSat && (hook('lnMaxSendSat') || 0) > 0 ? h('button', { type: 'button', onClick: () => { const sat = hook('lnMaxSendSat'); - z.amount = getUnit() === 'sats' ? String(sat) : (sat / 1e8).toFixed(8); + z.amount = ctx.amountField(sat); render(); } }, t('max')) : null, -- cgit v1.2.3