aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-10-09 06:24:39 -0700
committerAdam Soltys <[email protected]>2023-10-09 06:24:39 -0700
commit72280846591796e4cce2dc6d826d9a36c152a080 (patch)
tree2f200248b50eb7eebe8f22561a9dc5c0b10736cd /lib
parent4f1605b6cb1c179f747213bfe0c6c1bca68c070f (diff)
downloadcoinos-server-72280846591796e4cce2dc6d826d9a36c152a080.tar.gz
coinos-server-72280846591796e4cce2dc6d826d9a36c152a080.zip
check for invoice hash
Diffstat (limited to 'lib')
-rw-r--r--lib/payments.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/payments.js b/lib/payments.js
index 19cb5ce4..cb9658af 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -39,7 +39,9 @@ export let debit = async (
let rate = store.rates[currency];
let iid = await g(`invoice:${hash}`);
- let invoice = typeof iid === "String" ? await g(`invoice:${iid}`) : iid;
+ if (iid && iid.hash) iid = iid.hash;
+ let invoice = await g(`invoice:${iid}`);
+
if (invoice) {
ref = invoice.uid;
@@ -116,7 +118,9 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
amount = parseInt(amount) || 0;
let iid = await g(`invoice:${hash}`);
- let invoice = typeof iid === "String" ? await g(`invoice:${iid}`) : iid;
+ if (iid && iid.hash) iid = iid.hash;
+ let invoice = await g(`invoice:${iid}`);
+
if (!invoice) return warn("failed to credit", hash, ", invoice not found");
let { tip } = invoice;