From 55d4763146916e7e168bdc0ffd6d97c0d82f8e83 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Thu, 16 Jun 2022 10:52:56 -0500 Subject: Added Lightning conversion fees (currently 0%) --- routes/lightning/receive.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'routes/lightning/receive.js') diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index 6723d577..6d10eb9b 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -1,3 +1,5 @@ +const { computeConversionFee } = require('./conversionFee.js'); + const handlePayment = async (msg) => { l.info("incoming lightning payment", msg.value, msg.payment_request, msg.settled); if (!msg.settled) return; @@ -60,6 +62,8 @@ const handlePayment = async (msg) => { invoice.received += total; await account.increment({ balance: total }, { transaction }); + // get the # of fee credits you would need to pay off this amount of bitcoin + await account.increment({ btc_credits: computeConversionFee(total) }, { transaction }); await account.reload({ transaction }); await invoice.save({ transaction }); await payment.save({ transaction }); -- cgit v1.2.3