aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-10-10 23:26:47 -0700
committerAdam Soltys <[email protected]>2023-10-10 23:26:47 -0700
commitc6f1fc33dd7e6670a8d07928b812b9e340c7970e (patch)
treef4bbe69267b75146d992410d4c7221a84b761917
parent72280846591796e4cce2dc6d826d9a36c152a080 (diff)
downloadcoinos-server-c6f1fc33dd7e6670a8d07928b812b9e340c7970e.tar.gz
coinos-server-c6f1fc33dd7e6670a8d07928b812b9e340c7970e.zip
handle invoice objects
-rw-r--r--routes/payments.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/routes/payments.js b/routes/payments.js
index 87096bdd..9d9877ec 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -61,7 +61,9 @@ export default {
let total = amount;
let { amount_msat, payment_hash } = await ln.decode(payreq);
if (amount_msat) total = Math.round(amount_msat / 1000);
- let iid = await g(`invoice:${payreq}`);
+
+ let iid = await g(`invoice:${hash}`);
+ if (iid && iid.hash) iid = iid.hash;
let invoice = await g(`invoice:${iid}`);
if (invoice) {
@@ -89,10 +91,7 @@ export default {
l("checking", payreq, recordExists, paymentFailed);
- if (
- recordExists &&
- paymentFailed
- ) {
+ if (recordExists && paymentFailed) {
await db.del(`payment:${p.id}`);
let credit = Math.round(total * config.fee) - p.ourfee;
@@ -321,7 +320,7 @@ export default {
`${txid}:${vout}`,
types.bitcoin
);
- } else if(confirmations >= 1) {
+ } else if (confirmations >= 1) {
await confirm(address, txid, vout);
}
}
@@ -404,10 +403,7 @@ export default {
} of tx.vout) {
total += sats(value);
let iid = await g(`invoice:${address}`);
- if (
- (await bc.getAddressInfo(address)).ismine &&
- !iid
- )
+ if ((await bc.getAddressInfo(address)).ismine && !iid)
change += sats(value);
}