aboutsummaryrefslogtreecommitdiffstats
path: root/lib/invoices.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/invoices.js')
-rw-r--r--lib/invoices.js23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/invoices.js b/lib/invoices.js
index 9e75abcb..031153d0 100644
--- a/lib/invoices.js
+++ b/lib/invoices.js
@@ -10,17 +10,28 @@ import bc from "$lib/bitcoin";
import ln from "$lib/ln";
export let generate = async ({ invoice, user, sender, memo }) => {
- let { currency, tip, amount, rate, request_id, prompt, type } = invoice;
+ let {
+ currency,
+ tip,
+ amount,
+ rate,
+ request_id,
+ prompt,
+ type,
+ webhook,
+ secret
+ } = invoice;
amount = parseInt(amount || 0);
tip = parseInt(tip) || null;
if (amount < 0) fail("amount out of range");
- if (!user) user = sender;
- user = await getUser(user.username);
+ if (user) user = await getUser(user.username);
+ else if (sender) user = await getUser(sender.username);
+ else fail("user not provided");
- if (!user) fail("user not provided");
+ console.log("USER", user);
if (!currency) currency = user.currency;
if (!rate) rate = store.rates[currency];
@@ -61,10 +72,12 @@ export let generate = async ({ invoice, user, sender, memo }) => {
received: 0,
request_id,
prompt,
+ secret,
text,
tip,
type,
- uid: user.id
+ uid: user.id,
+ webhook
};
l("creating invoice", user.username, amount, tip, currency, invoice.hash);