From 5b9f051af683e885cc52d0cfeba1618b670785b0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 1 Mar 2023 13:50:47 -0800 Subject: proxy endpoint --- routes/payments.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'routes') diff --git a/routes/payments.js b/routes/payments.js index 38611d19..307e8ef6 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -348,5 +348,29 @@ export default { } else fail("Card payment failed"); res.send({ status }); + }, + + async proxy({ body: { method, params } }, res) { + try { + let whitelist = [ + "getblock", + "getblockhash", + "estimatesmartfee", + "echo", + "getblockchaininfo", + "getnetworkinfo" + ]; + + if (!whitelist.includes(method)) fail("unsupported method"); + + if (method === "estimatesmartfee" || method === "getblockhash") + params[0] = parseInt(params[0]); + + if (method === "getblock") params[1] = parseInt(params[1]); + + res.send(await bc[method](...params)); + } catch (e) { + bail(res, e.message); + } } }; -- cgit v1.2.3