diff options
| author | Adam Soltys <[email protected]> | 2023-10-09 06:24:39 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-10-09 06:24:39 -0700 |
| commit | 72280846591796e4cce2dc6d826d9a36c152a080 (patch) | |
| tree | 2f200248b50eb7eebe8f22561a9dc5c0b10736cd /lib/payments.js | |
| parent | 4f1605b6cb1c179f747213bfe0c6c1bca68c070f (diff) | |
| download | coinos-server-72280846591796e4cce2dc6d826d9a36c152a080.tar.gz coinos-server-72280846591796e4cce2dc6d826d9a36c152a080.zip | |
check for invoice hash
Diffstat (limited to 'lib/payments.js')
| -rw-r--r-- | lib/payments.js | 8 |
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; |
