aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/payments.ts6
-rw-r--r--routes/users.ts8
2 files changed, 11 insertions, 3 deletions
diff --git a/routes/payments.ts b/routes/payments.ts
index b14dc588..f9225b87 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -497,6 +497,12 @@ export default {
const invoice = await getInvoice(address);
if (!hot && aid !== invoice?.aid) continue;
if (sats(amount) < 300) continue;
+
+ const lockKey = `lock:${txid}:${vout}`;
+ const locked = await db.setNX(lockKey, "1");
+ if (!locked) continue;
+ await db.expire(lockKey, 60);
+
await credit({
hash: address,
amount: sats(amount),
diff --git a/routes/users.ts b/routes/users.ts
index a7188552..3d9602cf 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -21,7 +21,7 @@ import { authenticator } from "otplib";
import { v4 } from "uuid";
import { PaymentType } from "$lib/types";
-import { reconcile } from "$lib/payments";
+import { importAccountHistory } from "$lib/payments";
import type { ProfilePointer } from "nostr-tools/nip19";
const { host } = new URL(process.env.URL);
@@ -834,6 +834,9 @@ export default {
for (const id of await db.lRange(`${user.id}:accounts`, 0, -1)) {
const account = await g(`account:${id}`);
if (account) {
+ if (account.seed && account.pubkey && !account.importedAt) {
+ await importAccountHistory(account);
+ }
account.balance = await g(`balance:${id}`);
accounts.push(account);
}
@@ -884,6 +887,7 @@ export default {
nextIndex: 0,
arkAddress,
accountIndex,
+ importedAt: seed ? Date.now() : undefined,
};
// ARK accounts don't need Bitcoin Core wallet setup
@@ -940,8 +944,6 @@ export default {
.lPush(`${user.id}:accounts`, id)
.exec();
- reconcile(account, true);
-
res.send(account);
} catch (e) {
bail(res, e.message);