From 69c8473d7c5989e17576c54bcb7a6d58651e8fef Mon Sep 17 00:00:00 2001 From: John Barratt Date: Thu, 15 Dec 2022 11:38:19 -0800 Subject: decoding invoice endpoint --- routes/invoices.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/routes/invoices.js b/routes/invoices.js index 86836295..d6592d81 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -9,6 +9,7 @@ import bc from "$lib/bitcoin"; import lq from "$lib/liquid"; import { SATS, bip21, deriveAddress, derivePayRequest } from "$lib/utils"; import { emit } from "$lib/sockets"; +import bolt11 from "bolt11"; app.get("/invoice", async (req, res, next) => { try { @@ -211,8 +212,15 @@ app.post( app.post("/conversion", async (req, res, next) => { let { invoice_id, text } = req.body; - + console.log("HERE", invoice_id, text) let conversion = await db.Conversion.create({ invoice_id, text }); res.send(conversion); } ); + +app.post("/invoice/decode", + async (req, res, next) => { + let {text} = req.body; + res.send(bolt11.decode(text)) + } +) \ No newline at end of file -- cgit v1.2.3