Skip to content

Commit

Permalink
Merge pull request #1498 from stackernews/fix-1485
Browse files Browse the repository at this point in the history
premature invoice deletion: fix interval in sql template
  • Loading branch information
huumn authored Oct 19, 2024
2 parents 59a2419 + 01580d9 commit 7aa0d8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions api/resolvers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,12 @@ 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 (
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;`
Expand All @@ -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')
}
Expand Down
6 changes: 3 additions & 3 deletions worker/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ 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 (
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;`
Expand All @@ -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 }
})
}
}
Expand Down

0 comments on commit 7aa0d8f

Please sign in to comment.