diff options
| author | Adam Soltys <[email protected]> | 2020-07-12 08:33:54 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-07-12 08:38:42 -0700 |
| commit | a742dbf327e08715e7042099fed7d71dce62eea3 (patch) | |
| tree | 4a6c2c4a2a36288b9633afb0836f76253a80843b | |
| parent | 29063c8982442fddc015c7a9fd79feb4ba7c0c47 (diff) | |
| download | coinos-server-a742dbf327e08715e7042099fed7d71dce62eea3.tar.gz coinos-server-a742dbf327e08715e7042099fed7d71dce62eea3.zip | |
handle zero amount pay request
| -rw-r--r-- | routes/lnurl.js | 12 |
1 files 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) { |
