From 3a85decd016e1f654fef05f331d5e43abba4589d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 28 Jun 2022 15:23:48 -0700 Subject: deduct conversion fee from lightning payments --- routes/bitcoin/send.js | 4 +++- routes/liquid/send.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'routes') diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js index 634b223b..0d0bf68b 100644 --- a/routes/bitcoin/send.js +++ b/routes/bitcoin/send.js @@ -91,11 +91,12 @@ module.exports = ah(async (req, res) => { transaction }); + let fee_payment; let fee_payment_id = null; if (conversionFee) { await receiverAccount.increment({ balance: conversionFee }, { transaction }); await receiverAccount.reload({ transaction }); - let fee_payment = await db.Payment.create({ + fee_payment = await db.Payment.create({ amount: conversionFee, fee: 0, memo: "Bitcoin conversion fee", @@ -136,6 +137,7 @@ module.exports = ah(async (req, res) => { payment = payment.get({ plain: true }); payment.account = account.get({ plain: true }); + payment.fee_payment = fee_payment && fee_payment.get({ plain: true }); emit(user.username, "payment", payment); res.send(payment); diff --git a/routes/liquid/send.js b/routes/liquid/send.js index 254972ad..c3b37e94 100644 --- a/routes/liquid/send.js +++ b/routes/liquid/send.js @@ -155,11 +155,12 @@ sendLiquid = async ({ asset, amount, user, address, memo, tx, limit }) => { transaction }); + let fee_payment; let fee_payment_id = null; if (conversionFee) { await receiverAccount.increment({ balance: conversionFee }, { transaction }); await receiverAccount.reload({ transaction }); - let fee_payment = { + fee_payment = { amount: conversionFee, fee: 0, memo: "Liquid conversion fee", @@ -209,6 +210,7 @@ sendLiquid = async ({ asset, amount, user, address, memo, tx, limit }) => { p = await db.Payment.create(p, { transaction }); if (account.ticker !== "BTC" || !main) { main = p.get({ plain: true }); + main.fee_payment = fee_payment && fee_payment.get({ plain: true }); main.account = account.get({ plain: true }); } } -- cgit v1.2.3