From a742dbf327e08715e7042099fed7d71dce62eea3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 12 Jul 2020 08:33:54 -0700 Subject: handle zero amount pay request --- routes/lnurl.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routes/lnurl.js b/routes/lnurl.js index 743936bc..74e5cc0a 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -68,11 +68,15 @@ app.get("/pay", auth, async (req, res) => { const { user } = req; const { amount } = req.query; + let minSendable = 1000; + let maxSendable = 1000000000; + if (parseInt(amount)) minSendable = maxSendable = amount * 1000; + try { const result = await lnurlServer.generateNewUrl("payRequest", { - minSendable: amount * 1000, - maxSendable: amount * 1000, - metadata: JSON.stringify([["text/plain", "coinos"]]), + minSendable, + maxSendable, + metadata: JSON.stringify([["text/plain", `fund coinos account ${user.username}`]]), }); recipients[result.secret] = req.user; @@ -177,7 +181,7 @@ lnurlServer.bindToHook( where: { user_id: user.id, asset: config.liquid.btcasset, - } + }, }); if (account.balance < amount) { -- cgit v1.2.3