From 2bc257004db28c0b801278041759f95b343dd8a1 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sat, 14 Nov 2026 18:20:51 +0000 Subject: [PATCH] Take sats as whole numbers in the browser too --- static/app.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/static/app.js b/static/app.js index ae2a7c6..a17d3bf 100644 --- a/static/app.js +++ b/static/app.js @@ -85,18 +85,17 @@ return parts[2] + "." + parts[1] + "." + parts[0]; } + /* Whole sats, with spaces allowed as thousands separators. Anything carrying + a decimal separator gives null, like the server does. */ function parseSats(text) { - var cleaned = String(text === null || text === undefined ? "" : text) - .split(NARROW_SPACE).join("") - .split(" ").join("") - .replace(",", "."); - if (!/^\d*(\.\d{0,8})?$/.test(cleaned) || cleaned === "" || cleaned === ".") { + var cleaned = String(text === null || text === undefined ? "" : text); + THOUSANDS_SEPARATORS.forEach(function (separator) { + cleaned = cleaned.split(separator).join(""); + }); + if (!/^-?\d+$/.test(cleaned)) { return null; } - var parts = cleaned.split("."); - var whole = parts[0] === "" ? "0" : parts[0]; - var fraction = (parts[1] || "").padEnd(8, "0"); - return Number(whole) * 100000000 + Number(fraction); + return Number(cleaned); } /* The stored type names and what the owner sees, docs/spec.md section 7.3. */