From 963b86386def62ea5d3098b5f6299721aa127188 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 19 Feb 2025 22:13:42 +0000 Subject: check created --- lib/nwc.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/nwc.ts b/lib/nwc.ts index aa69ae75..210639e0 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -56,7 +56,7 @@ export default () => { await nip04.decrypt(serverSecret, pubkey, content), ); - db.sAdd("activeNwc", pubkey); + // db.sAdd("activeNwc", pubkey); if (!methods.includes(method)) return; @@ -105,7 +105,7 @@ const handle = (method, params, ev, app, user) => const { amount_msat, payee } = await ln.decode(pr); const { id } = await ln.getinfo(); const amount = Math.round(amount_msat / 1000); - const { max_amount, budget_renewal, pubkey } = app; + const { max_amount, budget_renewal, pubkey, created } = app; const periods = { daily: 60 * 60 * 24 * 1000, @@ -131,7 +131,8 @@ const handle = (method, params, ev, app, user) => 0, ); - if (spent + amount > max_amount) { + const whitelisted = await db.sIsMember("activeNwc", pubkey); + if ((amount > 1000 && !(whitelisted || created)) || spent + amount > max_amount) { warn("budget exceeded", pubkey, user?.username, spent, amount, max_amount); return error({ code: "QUOTA_EXCEEDED", -- cgit v1.2.3