aboutsummaryrefslogtreecommitdiffstats
path: root/lib/invoices.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-23 16:23:19 -0700
committerAdam Soltys <[email protected]>2024-09-23 16:23:19 -0700
commit12ad5c9abb74cbe35c5d07233fdd9a7b7f5c2b70 (patch)
tree8e023771abd75a7b70e407c651aed3bcfe426ea3 /lib/invoices.ts
parent01e1686265def675445c0f74a4b92ec4ffd71492 (diff)
downloadcoinos-server-12ad5c9abb74cbe35c5d07233fdd9a7b7f5c2b70.tar.gz
coinos-server-12ad5c9abb74cbe35c5d07233fdd9a7b7f5c2b70.zip
reconcile on-chain balance
Diffstat (limited to 'lib/invoices.ts')
-rw-r--r--lib/invoices.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/invoices.ts b/lib/invoices.ts
index 4626e257..60bcba0f 100644
--- a/lib/invoices.ts
+++ b/lib/invoices.ts
@@ -30,13 +30,16 @@ export let generate = async ({ invoice, user }) => {
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");
+ let account = await g(`account:${aid}`);
+ if (!account) account = await g(`account:${user.id}`);
+ if (!account) fail("account not found");
+
let rates = await g("rates");
if (!currency) currency = user.currency;
if (!rate) rate = rates[currency];