aboutsummaryrefslogtreecommitdiffstats
path: root/lib/invoices.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-20 10:04:08 -0700
committerAdam Soltys <[email protected]>2024-09-20 10:04:08 -0700
commit01e1686265def675445c0f74a4b92ec4ffd71492 (patch)
tree2d90795be17f5d15345540af80b9f2ca5261389c /lib/invoices.ts
parent718e3541cffe2103512b19f4945dfcc79813555d (diff)
downloadcoinos-server-01e1686265def675445c0f74a4b92ec4ffd71492.tar.gz
coinos-server-01e1686265def675445c0f74a4b92ec4ffd71492.zip
rename account id
Diffstat (limited to 'lib/invoices.ts')
-rw-r--r--lib/invoices.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts
index 0094c6d7..4626e257 100644
--- a/lib/invoices.ts
+++ b/lib/invoices.ts
@@ -13,7 +13,7 @@ let lq = rpc(config.liquid);
export let generate = async ({ invoice, user }) => {
let {
bolt11,
- account,
+ aid,
currency,
expiry,
fiat,
@@ -25,19 +25,18 @@ export let generate = async ({ invoice, user }) => {
memo,
memoPrompt,
prompt,
- type,
+ type = types.lightning,
webhook,
secret,
} = invoice;
+ let account = await g(`account:${aid}`);
amount = parseInt(amount || 0);
tip = parseInt(tip) || null;
if (user) user = await getUser(user.username);
if (!user) fail("user not provided");
- if (account === user.id) account = undefined;
-
let rates = await g("rates");
if (!currency) currency = user.currency;
if (!rate) rate = rates[currency];
@@ -51,8 +50,9 @@ export let generate = async ({ invoice, user }) => {
let hash, text;
- if (account) {
- let node = rpc({ ...config.bitcoin, wallet: account });
+ if (account.seed) {
+ type = "bitcoin";
+ let node = rpc({ ...config[type], wallet: aid });
hash = await node.getNewAddress();
text = bip21(hash, invoice);
} else if (type === types.lightning) {
@@ -91,7 +91,7 @@ export let generate = async ({ invoice, user }) => {
invoice = {
amount,
- account,
+ aid,
created: Date.now(),
currency,
hash,