aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/invoices.ts7
-rw-r--r--routes/invoices.ts5
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts
index b8eedbf6..48eb4879 100644
--- a/lib/invoices.ts
+++ b/lib/invoices.ts
@@ -20,6 +20,7 @@ export const generate = async ({ invoice, user }) => {
currency,
expiry,
fiat,
+ id,
tip,
amount,
items = [],
@@ -55,7 +56,7 @@ export const generate = async ({ invoice, user }) => {
if (rate < 0) fail("invalid rate");
if (memo && memo.length > 5000) fail("memo too long");
- const id = v4();
+ if (!id) id = v4();
let hash;
let text;
@@ -81,7 +82,7 @@ export const generate = async ({ invoice, user }) => {
expiry ||= 60 * 60 * 24 * 30;
r = await ln.invoice({
amount_msat: amount ? `${amount + tip}sat` : "any",
- label: id,
+ label: `${id} ${user.username} ${new Date()}`,
description: memo || "",
expiry,
deschashonly: true,
@@ -95,7 +96,7 @@ export const generate = async ({ invoice, user }) => {
} else if (type === PaymentType.bolt12) {
const r = await ln.offer({
amount: amount ? `${amount + tip}sat` : "any",
- label: id,
+ label: `${id} ${user.username} ${new Date()}`,
description: memo || id,
});
diff --git a/routes/invoices.ts b/routes/invoices.ts
index 37b79e8a..a2bab026 100644
--- a/routes/invoices.ts
+++ b/routes/invoices.ts
@@ -55,9 +55,10 @@ export default {
const { body } = req;
if (!body.invoice?.tip || body.invoice.tip < 0) fail("Invalid tip");
- const invoice = await g(`invoice:${id}`);
+ let invoice = await g(`invoice:${id}`);
+ const user = await g(`user:${invoice.uid}`);
invoice.tip = body.invoice.tip;
- invoice.amount += invoice.tip;
+ invoice = await generate({ invoice, user });
await s(`invoice:${id}`, invoice);
res.send(invoice);