diff options
| author | Adam Soltys <[email protected]> | 2021-09-24 02:19:30 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-09-24 02:19:30 -0400 |
| commit | 18814242ad055ecd6f9de1d23209958e12aee69c (patch) | |
| tree | f9abc8b8716b5587c8a71700df62ebfe2098f4f6 /lib/buildliquidtx.js | |
| parent | fd44b77a4ddac5beef34f65be8e5558f4b4291f9 (diff) | |
| download | coinos-server-18814242ad055ecd6f9de1d23209958e12aee69c.tar.gz coinos-server-18814242ad055ecd6f9de1d23209958e12aee69c.zip | |
always create account on issuance
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++) { |
