From 283ffc9d8442ecbbc85c0c40167cc03f20f64a40 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Jan 2023 00:54:08 -0800 Subject: parse ints --- lib/invoices.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/invoices.js') diff --git a/lib/invoices.js b/lib/invoices.js index f17223aa..814e87d9 100644 --- a/lib/invoices.js +++ b/lib/invoices.js @@ -12,9 +12,11 @@ import ln from "$lib/ln"; export let generate = async ({ invoice, user, sender }) => { let { currency, tip, amount, rate, request_id, type } = invoice; + amount = parseInt(amount); + tip = parseInt(tip || 0); + if (amount < 0) fail("amount out of range"); if (tip > 5 * amount || tip < 0) fail("tip amount out of range"); - tip = tip || 0; if (!user) user = sender; let uid = await g(`user:${user.username}`); -- cgit v1.2.3