aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lnurl.ts
diff options
context:
space:
mode:
Diffstat (limited to 'routes/lnurl.ts')
-rw-r--r--routes/lnurl.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/routes/lnurl.ts b/routes/lnurl.ts
index 7f04db5d..20d795c0 100644
--- a/routes/lnurl.ts
+++ b/routes/lnurl.ts
@@ -5,6 +5,7 @@ import { serverPubkey2 } from "$lib/nostr";
import { SATS, bail, fail, getInvoice, getUser } from "$lib/utils";
import { bech32 } from "bech32";
import { safeGot } from "$lib/safe-fetch";
+import { lnurlPayload } from "$lib/lnurl-payload";
import { verifyEvent } from "nostr-tools";
import { v4 } from "uuid";
@@ -36,6 +37,8 @@ const unauthInvoiceBudget = async (uid: string) => {
fail("Too many payment requests for this user, try again later");
}
};
+import { holderBlocked } from "$lib/names";
+
// v3 payment addresses (coinos v3 / halwallet) are registered here.
const NAMES_URL = process.env.NAMES_URL || "https://names.coinos.io";
@@ -99,7 +102,7 @@ export default {
bech32.fromWords(bech32.decode(text, 20000).words),
).toString();
- const r = await safeGot(url);
+ const r = lnurlPayload(await safeGot(url));
res.send(r);
} catch (e) {
bail(res, e.message);
@@ -134,7 +137,7 @@ export default {
// registrar never queries this endpoint for those. If the registrar is
// unreachable we fall through and serve the local account — a briefly
// stale destination beats an unpayable address.
- const v3 = await registrarLookup(name);
+ const v3 = (await holderBlocked(name)) ? null : await registrarLookup(name);
if (v3) return res.send(v3);
const user = await getUser(name);
@@ -240,11 +243,12 @@ export default {
const { url } = req.query;
if (!url) return bail(res, "url required");
try {
- const r = await safeGot(url);
+ const r = lnurlPayload(await safeGot(url));
res.send(r);
} catch (e) {
- warn("lnurl proxy failed", url, e.message);
- bail(res, e.message);
+ const n = quiet("lnurl-proxy-failure", 5 * 60 * 1000);
+ if (n !== null) warn("lnurl proxy failed", url, e.message, suppressed(n));
+ bail(res, "Unable to resolve a valid LNURL response");
}
},