From 8631c7f3e09b76db0540e1519b0c13dcb9558110 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Sep 2022 19:31:25 -0700 Subject: use integer for sats amount --- src/routes/[username]/receive/+page.svelte | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/routes/[username]/receive/+page.svelte b/src/routes/[username]/receive/+page.svelte index 05ee5758..dd7b3d25 100644 --- a/src/routes/[username]/receive/+page.svelte +++ b/src/routes/[username]/receive/+page.svelte @@ -11,10 +11,10 @@ let amountFiat = 0; let amountSats = 0; - $: amount = useFiat ? Math.round(amountFiat / ($selectedRate / 100000000)) : amountSats; + $: amount = parseInt(useFiat ? Math.round(amountFiat / ($selectedRate / 100000000)) : amountSats); $: $invoiceAmount = parseInt( - amountSats === 0 || amountSats === '0' ? amountFiat / ($selectedRate / 100000000) : amountSats + !amountSats ? amountFiat / ($selectedRate / 100000000) : amountSats ); $: $invoiceAmountFiat = parseInt( @@ -64,11 +64,11 @@ } else { if (value === '.') { return; - } else if (amountSats === '0' && value !== '<' && value !== '0') { - amountSats = value; + } else if (!amountSats && value !== '<' && value !== '0') { + amountSats = parseInt(value); } else if (value === '<') { if (amountSats !== 0) { - amountSats = amountSats.slice(0, amountSats.length - 1); + amountSats = Math.floor(amountSats / 10); if (amountSats.length === 0) { amountSats = 0; amountFiat = 0; @@ -77,7 +77,7 @@ } else if (value !== '<' && parseInt(amountSats + value) > 100000000) { warning($t('user.receive.lessThan1BTCWarning')); } else { - amountSats = amountSats + value; + amountSats = parseInt(amountSats + value); } } }; @@ -132,11 +132,11 @@