aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-21 15:29:43 -0800
committerAdam Soltys <[email protected]>2023-02-21 15:29:45 -0800
commit681304b3a0ccff942e07d5f889af33898abd4c19 (patch)
tree8487ed2821eda99afd1b5748411aa587fc81a784 /routes
parent983e49a004b9ade1a90ee40d10c557ca7a6fe31e (diff)
downloadcoinos-server-681304b3a0ccff942e07d5f889af33898abd4c19.tar.gz
coinos-server-681304b3a0ccff942e07d5f889af33898abd4c19.zip
squelch invoice errors
Diffstat (limited to 'routes')
-rw-r--r--routes/invoices.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/routes/invoices.js b/routes/invoices.js
index d52b34cc..c7611f54 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -7,7 +7,10 @@ import ln from "$lib/ln";
export default {
async get({ params: { hash } }, res) {
- if (hash.startsWith("ln")) ({ payment_hash: hash } = await ln.decode(hash));
+ let pr;
+ if (hash.startsWith("ln")) {
+ ({ payment_hash: hash } = await ln.decode(hash));
+ }
let invoice = await g(`invoice:${hash}`);
@@ -15,15 +18,17 @@ export default {
invoice.user = await g(`user:${invoice.uid}`);
invoice.id = hash;
} else if (config.classic) {
- invoice = await got(`${config.classic}/invoice/${hash}`).json();
- if (!invoice) fail("invoice not found");
- invoice.id = invoice.uuid;
- invoice.classic = true;
- invoice.user.id = invoice.user.uuid;
- invoice.user.username += "@classic";
+ invoice = await got(`${config.classic}/invoice/${pr}`).json();
+ if (invoice) {
+ invoice.id = invoice.uuid;
+ invoice.classic = true;
+ invoice.user.id = invoice.user.uuid;
+ invoice.user.username += "@classic";
+ }
}
- res.send(invoice);
+ if (invoice) res.send(invoice);
+ else res.code(500).send("invoice not found");
},
async create({ body: { invoice, user }, user: sender }, res) {