From c6dc858ee5491e6c584d94d702438e9b24adbfc7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 30 Aug 2021 14:48:26 -0700 Subject: handle conversions for internal payments --- routes/send.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'routes/send.js') diff --git a/routes/send.js b/routes/send.js index e8fdb79c..cdaa8a9b 100644 --- a/routes/send.js +++ b/routes/send.js @@ -158,7 +158,28 @@ module.exports = ah(async (req, res, next) => { received: true, }; - if (invoice) params.invoice_id = invoice.id; + if (invoice) { + params.invoice_id = invoice.id; + + let c = convert[invoice.text]; + if (c) { + l.info( + "internal payment detected for conversion", + invoice.text, + c.address, + recipient.username + ); + + recipient.account = a2; + + sendLiquid({ + address: c.address, + amount: amount - 100, + user: recipient, + limit: amount, + }).catch(console.log); + } + } let p2 = await db.Payment.create(params, { transaction }); -- cgit v1.2.3