aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-01-15 12:48:50 -0800
committerAdam Soltys <[email protected]>2025-01-15 12:48:50 -0800
commit5d2c06457d018ef75c0fc4fa5fd4e9af266f19d8 (patch)
tree72dbc39859546e6e454f274306bc764a15a6ba25 /routes
parent273afd10bb321c1ac23ce14aba9f61b6ffe1e910 (diff)
downloadcoinos-server-5d2c06457d018ef75c0fc4fa5fd4e9af266f19d8.tar.gz
coinos-server-5d2c06457d018ef75c0fc4fa5fd4e9af266f19d8.zip
sign endpoint
Diffstat (limited to 'routes')
-rw-r--r--routes/invoices.ts17
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);
+ }
},
};