aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sync.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-05-18 22:53:43 -0400
committerAdam Soltys <[email protected]>2022-05-18 22:53:46 -0400
commitca7224037fb01ded28b51d765e040d5cad36183b (patch)
treeb9c6c9ffd89278d2a37a1d08de96019ab1f1e139 /lib/sync.js
parent962807d8c7b31a18bbcb6c677047e057c0f519cc (diff)
downloadcoinos-server-ca7224037fb01ded28b51d765e040d5cad36183b.tar.gz
coinos-server-ca7224037fb01ded28b51d765e040d5cad36183b.zip
auto confirm payments
Diffstat (limited to 'lib/sync.js')
-rw-r--r--lib/sync.js12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/sync.js b/lib/sync.js
index fedb6798..e217dcd0 100644
--- a/lib/sync.js
+++ b/lib/sync.js
@@ -116,7 +116,7 @@ const sync = async () => {
preimage,
rate: invoice.rate,
received: true,
- confirmed: false,
+ confirmed: true,
network: "lightning",
tip: invoice.tip,
invoice_id: invoice.id,
@@ -124,7 +124,7 @@ const sync = async () => {
updatedAt: createdAt
});
- // await account.increment({ balance: amount });
+ await account.increment({ balance: amount });
l.info("lightning missing from account", account.id, amount);
}
@@ -152,7 +152,7 @@ const sync = async () => {
const transactions = [
...(await bc.listTransactions("*", 500)),
...(await lq.listTransactions("*", 500))
- ].filter(tx => ["send", "receive"].includes(tx.category));
+ ].filter(tx => ["send", "receive"].includes(tx.category) && new Date(tx.time * 1000) > twoWeeksAgo);
missed = transactions.filter(
tx =>
@@ -163,7 +163,6 @@ const sync = async () => {
for (let i = 0; i < missed.length; i++) {
let p = unconfirmed.find(p => p.hash === missed[i].txid);
- /*
p.confirmed = 1;
await db.transaction(async transaction => {
@@ -175,7 +174,6 @@ const sync = async () => {
emit(p.user.username, "account", p.account);
emit(p.user.username, "payment", p);
- */
l.info("unconfirmed tx", p.user_id, p.hash, p.address);
}
@@ -253,8 +251,7 @@ const sync = async () => {
amount = toSats(amount);
await db.transaction(async transaction => {
- l.info("found pending balance", user.username, amount);
- /*
+ l.info("found pending transaction", user.username, amount, hash);
payments.push(hash);
let p = await db.Payment.create(
{
@@ -278,7 +275,6 @@ const sync = async () => {
emit(user.username, "account", account);
emit(user.username, "payment", p);
- */
});
}
}