aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-12-09 16:45:09 -0800
committerAdam Soltys <[email protected]>2021-12-09 16:55:08 -0800
commitd23f225a306c29fc3416233f98a7316996686c22 (patch)
tree4c4ef883ee3f0b195295b03753befb6a1b8369ec
parentff51e91efafc8f12f303ba1c86a5032d5b963aa1 (diff)
downloadcoinos-server-d23f225a306c29fc3416233f98a7316996686c22.tar.gz
coinos-server-d23f225a306c29fc3416233f98a7316996686c22.zip
signMessage endpoint
-rw-r--r--routes/users.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/routes/users.js b/routes/users.js
index d9a04304..7ea91413 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -770,3 +770,23 @@ app.get(
res.send(invoices);
})
);
+
+app.post(
+ "/signMessage",
+ auth,
+ ah(async function(req, res) {
+ let { address, message } = req.body;
+
+ let invoices = await db.Invoice.findAll({
+ where: { user_id: req.user.id }
+ });
+
+ if (invoices.find(i => i.address === address)) {
+ if (config.bitcoin.walletpass)
+ await bc.walletPassphrase(config.bitcoin.walletpass, 300);
+ return res.send(await bc.signMessage(address, message));
+ }
+
+ res.status(500).send("Address not found for user");
+ })
+);