diff options
| author | Adam Soltys <[email protected]> | 2023-11-30 15:34:45 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-11-30 15:34:45 -0800 |
| commit | a7322928c45848cfb9984454bf8ece6e3439c673 (patch) | |
| tree | 9b1031c31ee1f8160306ac66749afe0802f8aa54 /routes | |
| parent | acb93f29e83b35c0917d88ebbc62812e2dff989f (diff) | |
| download | coinos-server-a7322928c45848cfb9984454bf8ece6e3439c673.tar.gz coinos-server-a7322928c45848cfb9984454bf8ece6e3439c673.zip | |
zaps and emails
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/lnurl.js | 16 | ||||
| -rw-r--r-- | routes/payments.js | 2 | ||||
| -rw-r--r-- | routes/users.js | 18 |
3 files changed, 30 insertions, 6 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js index 6567f0b7..0f760695 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -47,7 +47,7 @@ export default { async lnurlp({ params: { username } }, res) { try { - let { id: uid } = await getUser(username); + let { id: uid, pubkey: nostrPubkey } = await getUser(username); let metadata = JSON.stringify([ ["text/plain", `Paying ${username}@${host}`], @@ -58,9 +58,11 @@ export default { await s(`lnurl:${id}`, uid); res.send({ + allowsNostr: true, minSendable: 1000, maxSendable: 100000000000, metadata, + nostrPubkey, callback: `${URL}/api/lnurl/${id}`, tag: "payRequest" }); @@ -72,12 +74,22 @@ export default { async lnurlw({ params: { k1, pr } }, res) {}, - async lnurl({ params: { id }, query: { amount } }, res) { + async lnurl({ params: { id }, query: { amount, nostr } }, res) { let uid = await g(`lnurl:${id}`); let user = await g(`user:${uid}`); let { username } = user; username = username.replace(/\s/g, "").toLowerCase(); + if (nostr) { + try { + let event = JSON.parse(decodeURIComponent(nostr)); + // TODO: validate the event + await s(`zap:${id}`, event); + } catch (e) { + err("problem handling zap", e.message); + } + } + let metadata = JSON.stringify([ ["text/plain", `Paying ${username}@${host}`], ["text/identifier", `${username}@${host}`] diff --git a/routes/payments.js b/routes/payments.js index b4ac7dfd..84fe4e61 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -13,7 +13,7 @@ import got from "got"; import bc from "$lib/bitcoin"; import ln from "$lib/ln"; -let seen = []; +let seen = await db.sMembers("missing"); let catchUp = async () => { let txns = await bc.listTransactions("*", 50); txns = txns.filter((tx) => tx.category === "receive" && tx.confirmations > 0); diff --git a/routes/users.js b/routes/users.js index 678f0748..41c3bfd5 100644 --- a/routes/users.js +++ b/routes/users.js @@ -327,7 +327,13 @@ export default { async password({ body: { password }, user }, res) { if (!user.password) return res.send(true); - res.send(await bcrypt.compare(password, user.password)); + + try { + if (!password) fail("password not provided"); + res.send(await bcrypt.compare(password, user.password)); + } catch (e) { + bail(res, e.message); + } }, async pin({ body: { pin }, user }, res) { @@ -362,11 +368,11 @@ export default { let u = await g(`user:${ref}`); if (typeof u === "string") u = await g(`user:${ref}`); if (u) contacts.unshift(pick(u, ["id", "profile", "username"])); - } + } await s(`${id}:contacts`, contacts); - res.send(contacts); + res.send(contacts); }, async del({ params: { username }, headers: { authorization } }, res) { @@ -425,5 +431,11 @@ export default { async superuser({ body: { username } }, res) { if (username === config.mqtt2.username) res.send({ ok: true }); else bail(res, "unauthorized"); + }, + + async verify({ body: { test } }, res) { + console.log("test", test); + res.send(test); } + }; |
