aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-02-19 22:13:42 +0000
committerAdam Soltys <[email protected]>2025-02-19 22:13:43 +0000
commit963b86386def62ea5d3098b5f6299721aa127188 (patch)
tree7bfb14f907fa520d8636e999ae94b2da3b2d83d2 /lib
parent65b85fbd74fa7587b3af3d5ae4535dd07ba4efd7 (diff)
downloadcoinos-server-963b86386def62ea5d3098b5f6299721aa127188.tar.gz
coinos-server-963b86386def62ea5d3098b5f6299721aa127188.zip
check created
Diffstat (limited to 'lib')
-rw-r--r--lib/nwc.ts7
1 files changed, 4 insertions, 3 deletions
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",