diff options
Diffstat (limited to 'lib/buildliquidtx.js')
| -rw-r--r-- | lib/buildliquidtx.js | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/buildliquidtx.js b/lib/buildliquidtx.js index 7bebb548..aab8e000 100644 --- a/lib/buildliquidtx.js +++ b/lib/buildliquidtx.js @@ -7,6 +7,7 @@ const api = prod : "http://localhost:3002"; const SATS = 100000000; const network = prod ? liquid.networks["liquid"] : liquid.networks["regtest"]; +const { Op } = require("sequelize"); module.exports = async ({ address, @@ -26,13 +27,29 @@ module.exports = async ({ feeRate = Math.round(feeRate / 100); if (asset !== btc) feeRate = 0; - const payments = await db.Payment.findAll({ - where: { - received: true, - account_id: user.account_id, - network: "liquid" - } - }); + let payments; + if (asset === btc) { + payments = await db.Payment.findAll({ + where: { + received: true, + account_id: user.account_id, + network: "liquid" + } + }); + } else { + payments = await db.Payment.findAll({ + where: { + "$account.pubkey": { [Op.ne]: null }, + received: true, + user_id: user.id, + network: "liquid" + }, + include: { + model: db.Account, + as: "account" + } + }); + } let utxos = []; for (let i = 0; i < payments.length; i++) { |
