From 5d2c06457d018ef75c0fc4fa5fd4e9af266f19d8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 15 Jan 2025 12:48:50 -0800 Subject: sign endpoint --- routes/invoices.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/routes/invoices.ts b/routes/invoices.ts index e7295b6e..a545459a 100644 --- a/routes/invoices.ts +++ b/routes/invoices.ts @@ -5,8 +5,6 @@ import { err } from "$lib/logging"; import { bail, getInvoice, pick } from "$lib/utils"; import rpc from "@coinos/rpc"; -const bc = rpc(config.bitcoin); - export default { async get(req, res) { const { @@ -54,8 +52,17 @@ export default { }, async sign(req, res) { - const { address, message } = req.body; - const signature = await bc.signMessage({ address, message }); - res.send({ signature }); + try { + const { address, message, type = "bitcoin" } = req.body; + const node = rpc(config[type]); + + if (config[type].walletpass) + await node.walletPassphrase(config[type].walletpass, 300); + + const signature = await node.signMessage({ address, message }); + res.send({ signature }); + } catch (e) { + bail(res, e.message); + } }, }; -- cgit v1.2.3