diff options
| author | Adam Soltys <[email protected]> | 2025-02-19 22:13:42 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-19 22:13:43 +0000 |
| commit | 963b86386def62ea5d3098b5f6299721aa127188 (patch) | |
| tree | 7bfb14f907fa520d8636e999ae94b2da3b2d83d2 | |
| parent | 65b85fbd74fa7587b3af3d5ae4535dd07ba4efd7 (diff) | |
| download | coinos-server-963b86386def62ea5d3098b5f6299721aa127188.tar.gz coinos-server-963b86386def62ea5d3098b5f6299721aa127188.zip | |
check created
| -rw-r--r-- | lib/nwc.ts | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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", |
