diff options
Diffstat (limited to 'lib/invoices.js')
| -rw-r--r-- | lib/invoices.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/invoices.js b/lib/invoices.js index 95a81104..74870f82 100644 --- a/lib/invoices.js +++ b/lib/invoices.js @@ -2,7 +2,7 @@ import store from "$lib/store"; import { l } from "$lib/logging"; import { emit } from "$lib/sockets"; import { db, g, s } from "$lib/db"; -import { bip21, fail } from "$lib/utils"; +import { getUser, bip21, fail } from "$lib/utils"; import { types } from "$lib/payments"; import { v4 } from "uuid"; @@ -18,8 +18,7 @@ export let generate = async ({ invoice, user, sender, memo }) => { if (amount < 0) fail("amount out of range"); if (!user) user = sender; - let uid = await g(`user:${user.username.toLowerCase()}`); - user = await g(`user:${uid}`); + user = await getUser(user.username); if (!user) fail("user not provided"); @@ -64,13 +63,13 @@ export let generate = async ({ invoice, user, sender, memo }) => { text, tip, type, - uid, + uid: user.id }; l("creating invoice", user.username, amount, tip, currency, invoice.hash); await s(`invoice:${hash}`, invoice); - await db.lPush(`${uid}:invoices`, hash); + await db.lPush(`${user.id}:invoices`, hash); if (request_id) { let request = await g(`request:${request_id}`); |
