aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/payments.ts9
-rw-r--r--routes/users.ts5
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index be801622..807c87fa 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -80,6 +80,7 @@ export const debit = async ({
let ref;
const { id: uid, currency } = user;
+ if (!aid) aid = uid;
const rates = await g("rates");
if (!rate) rate = rates[currency];
@@ -119,12 +120,12 @@ export const debit = async ({
? Math.round((amount + fee + tip) * config.fee[creditType])
: 0;
- if (aid && aid !== uid) ourfee = 0;
+ if (aid !== uid) ourfee = 0;
const frozenBalance =
!blacklisted || whitelisted ? 0 : await ga(`balance:${uid}`);
ourfee = await db.debit(
- `balance:${aid || uid}`,
+ `balance:${aid}`,
`credit:${creditType}:${aid !== uid ? 0 : uid}`,
t(user).insufficientFunds,
amount || 0,
@@ -167,9 +168,7 @@ export const debit = async ({
.exec();
l(user.username, "sent", type, amount);
- //emit(user.id, "payment", p);
- if (![PaymentType.lightning, PaymentType.bolt12].includes(type))
- nwcNotify(p, user);
+ if (![PaymentType.lightning, PaymentType.bolt12].includes(type)) nwcNotify(p);
return p;
};
diff --git a/routes/users.ts b/routes/users.ts
index 82bff805..1338c50c 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -209,11 +209,12 @@ export default {
pubkey = pubkey.trim();
if (pubkey.startsWith("npub")) pubkey = nip19.decode(pubkey).data;
exists = await getUser(pubkey);
+ const un = user.username.toLowerCase().replace(/\s/g, "");
const existingUsername = exists?.username
?.toLowerCase()
.replace(/\s/g, "");
- if (exists && username !== existingUsername) {
- warn("key in use", pubkey, existingUsername);
+ if (exists && un !== existingUsername) {
+ warn("key in use", pubkey, username, existingUsername);
if (exists.anon) await db.del(`user:${pubkey}`);
else fail("Key in use by another account");
}