From 9d4e7bee7d884fba7da27df7180390bad9a80bdc Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 10 Feb 2021 09:57:00 -0500 Subject: amount from pay request should take precedence if provided --- lib/send.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/send.js') diff --git a/lib/send.js b/lib/send.js index 37cbdfdb..98fa4d2c 100644 --- a/lib/send.js +++ b/lib/send.js @@ -1,9 +1,10 @@ const bolt11 = require("bolt11"); +const { Op } = require("sequelize"); send = async (amount, memo, hash, user) => { let payreq = bolt11.decode(hash); - if (!amount) amount = payreq.satoshis; + if (!amount || payreq.satoshis > amount) amount = payreq.satoshis; if (seen.includes(hash)) { l.warn("attempted to pay a paid invoice", user.username); @@ -17,7 +18,10 @@ send = async (amount, memo, hash, user) => { where: { user_id: user.id, asset: config.liquid.btcasset, - pubkey: null + pubkey: null, + balance: { + [Op.gte]: amount + }, }, lock: transaction.LOCK.UPDATE, transaction -- cgit v1.2.3