From bcd8adae4551bee636c3390dc9de94a6577b2b86 Mon Sep 17 00:00:00 2001 From: k00b Date: Fri, 18 Oct 2024 20:20:45 -0500 Subject: [PATCH 1/2] fix interval in sql template --- api/resolvers/wallet.js | 2 +- worker/wallet.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index 03945feca..e73da9987 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -482,7 +482,7 @@ const resolvers = { FROM "Withdrawl" WHERE "userId" = ${me.id} AND id = ${Number(id)} - AND now() > created_at + interval '${retention}' + AND now() > created_at + ${retention}::INTERVAL AND hash IS NOT NULL AND status IS NOT NULL ), updated_rows AS ( diff --git a/worker/wallet.js b/worker/wallet.js index 33f6d1a7a..329058e73 100644 --- a/worker/wallet.js +++ b/worker/wallet.js @@ -346,7 +346,7 @@ export async function autoDropBolt11s ({ models, lnd }) { SELECT id, hash, bolt11 FROM "Withdrawl" WHERE "userId" IN (SELECT id FROM users WHERE "autoDropBolt11s") - AND now() > created_at + interval '${retention}' + AND now() > created_at + ${retention}::INTERVAL AND hash IS NOT NULL AND status IS NOT NULL ), updated_rows AS ( From 01580d9ee812f0cb5a1424b62982dad2227c6208 Mon Sep 17 00:00:00 2001 From: k00b Date: Sat, 19 Oct 2024 09:51:24 -0500 Subject: [PATCH 2/2] delete primage when invoice is deleted --- api/resolvers/wallet.js | 4 ++-- worker/wallet.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index e73da9987..daa41ab8f 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -487,7 +487,7 @@ const resolvers = { AND status IS NOT NULL ), updated_rows AS ( UPDATE "Withdrawl" - SET hash = NULL, bolt11 = NULL + SET hash = NULL, bolt11 = NULL, preimage = NULL FROM to_be_updated WHERE "Withdrawl".id = to_be_updated.id) SELECT * FROM to_be_updated;` @@ -499,7 +499,7 @@ const resolvers = { console.error(error) await models.withdrawl.update({ where: { id: invoice.id }, - data: { hash: invoice.hash, bolt11: invoice.bolt11 } + data: { hash: invoice.hash, bolt11: invoice.bolt11, preimage: invoice.preimage } }) throw new GqlInputError('failed to drop bolt11 from lnd') } diff --git a/worker/wallet.js b/worker/wallet.js index 329058e73..57156b9da 100644 --- a/worker/wallet.js +++ b/worker/wallet.js @@ -351,7 +351,7 @@ export async function autoDropBolt11s ({ models, lnd }) { AND status IS NOT NULL ), updated_rows AS ( UPDATE "Withdrawl" - SET hash = NULL, bolt11 = NULL + SET hash = NULL, bolt11 = NULL, preimage = NULL FROM to_be_updated WHERE "Withdrawl".id = to_be_updated.id) SELECT * FROM to_be_updated;` @@ -364,7 +364,7 @@ export async function autoDropBolt11s ({ models, lnd }) { console.error(`Error removing invoice with hash ${invoice.hash}:`, error) await models.withdrawl.update({ where: { id: invoice.id }, - data: { hash: invoice.hash, bolt11: invoice.bolt11 } + data: { hash: invoice.hash, bolt11: invoice.bolt11, preimage: invoice.preimage } }) } }