diff options
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/invoices.ts | 17 |
1 files 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); + } }, }; |
