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 | |
| parent | fd44b77a4ddac5beef34f65be8e5558f4b4291f9 (diff) | |
| download | coinos-server-18814242ad055ecd6f9de1d23209958e12aee69c.tar.gz coinos-server-18814242ad055ecd6f9de1d23209958e12aee69c.zip | |
always create account on issuance
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/buildliquidtx.js | 31 | ||||
| -rw-r--r-- | lib/rates.js | 1 | ||||
| -rw-r--r-- | lib/send.js | 4 |
3 files changed, 28 insertions, 8 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++) { diff --git a/lib/rates.js b/lib/rates.js index 598fc041..55dc1ea5 100644 --- a/lib/rates.js +++ b/lib/rates.js @@ -59,6 +59,7 @@ setInterval(() => { }, 1000); setInterval(() => { + l.info("refreshing binance socket"); binance.terminate(); binance = require("./binance")(); }, 360000); diff --git a/lib/send.js b/lib/send.js index 293473d9..e08e9033 100644 --- a/lib/send.js +++ b/lib/send.js @@ -2,6 +2,8 @@ const bolt11 = require("bolt11"); const { Op } = require("sequelize"); send = async (amount, memo, hash, user) => { + l.info("attempting lightning payment", user.username, amount, hash); + let payreq = bolt11.decode(hash); let routingInfo = payreq.tags.find(t => t.tagName === "routing_info"); if ( @@ -59,7 +61,7 @@ send = async (amount, memo, hash, user) => { fee_limit: { fixed: Math.min(10000, account.balance) }, }); - if (!m) throw new Error("lightning payment failed"); + if (!m) throw new Error(`lightning payment failed ${amount} ${hash}`); if (m.payment_error) throw new Error(m.payment_error); ({ |
