aboutsummaryrefslogtreecommitdiffstats
path: root/routes/liquid/receive.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/liquid/receive.js')
-rw-r--r--routes/liquid/receive.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/routes/liquid/receive.js b/routes/liquid/receive.js
index 718feba5..2554904d 100644
--- a/routes/liquid/receive.js
+++ b/routes/liquid/receive.js
@@ -14,6 +14,7 @@ import bitcoin from "bitcoinjs-lib";
import liquidJs from "liquidjs-lib";
import { l, err, warn } from "$lib/logging";
import lq from "$lib/liquid";
+import sendLightning from "$lib/send";
const { Block, networks, Transaction } = liquidJs;
@@ -317,7 +318,7 @@ setInterval(async () => {
for (let i = 0; i < arr.length; i++) {
const hash = arr[i];
- let account, invoice, address, user, total, p;
+ let account, invoice, address, user, total, p, conversions;
await db.transaction(async transaction => {
p = await db.Payment.findOne({
where: { hash, confirmed: 0, received: 1 },
@@ -344,6 +345,7 @@ setInterval(async () => {
if (p && p.account) {
({ account, invoice } = p);
+ conversions = await invoice.getConversions();
total = p.amount + p.tip;
p.confirmed = 1;
await account.save({ transaction });
@@ -381,6 +383,17 @@ setInterval(async () => {
delete queue[hash];
});
+ user.account = p.account;
+
+ console.log("CONVERSIONS", conversions.length)
+
+ for (let i = 0; i < conversions.length; i++) {
+ console.log("sending lightning");
+ let conversion = conversions[i];
+ let result = await sendLightning(p.amount, "", conversion.text, user);
+ console.log("RESULT", result);
+ }
+
let c = store.convert[address];
if (address && c && p.account.asset === network.assetHash) {
l(
@@ -390,8 +403,6 @@ setInterval(async () => {
user.username
);
- user.account = p.account;
-
sendLiquid({
address: c.address,
amount: total - 100,