aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/receive.js
diff options
context:
space:
mode:
authorAdrien Hopkins <[email protected]>2022-06-16 14:48:27 -0500
committerAdrien Hopkins <[email protected]>2022-06-16 14:48:27 -0500
commitc66b9c6b5be4b1b524ee2675dd1f65f425d72ee9 (patch)
treeeba3a920bd31da13e76afea2835c1f6e515d1d11 /routes/lightning/receive.js
parentffbd27b2e9ddcb52a37febc0855e16b4fe09dbdc (diff)
parent67e2ec07cf90cfbd1b5c1cbed18c4dffe38ea4aa (diff)
downloadcoinos-server-c66b9c6b5be4b1b524ee2675dd1f65f425d72ee9.tar.gz
coinos-server-c66b9c6b5be4b1b524ee2675dd1f65f425d72ee9.zip
Merge branch 'feature-withdrawal-fee'
Diffstat (limited to 'routes/lightning/receive.js')
-rw-r--r--routes/lightning/receive.js4
1 files changed, 4 insertions, 0 deletions
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 });