From adfa707554d8f7dc95f832af5635bad9912b6ce5 Mon Sep 17 00:00:00 2001 From: Arc <33088785+arcbtc@users.noreply.github.com> Date: Sun, 23 Feb 2020 00:16:13 +0000 Subject: [PATCH] Update __init__.py --- lnbits/__init__.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lnbits/__init__.py b/lnbits/__init__.py index fdac129..9f15e64 100644 --- a/lnbits/__init__.py +++ b/lnbits/__init__.py @@ -380,22 +380,14 @@ def api_checkinvoice(payhash): if request.headers["Content-Type"] != "application/json": return jsonify({"ERROR": "MUST BE JSON"}), 400 - with open_db() as db: - payment = db.fetchone( - """ - SELECT pending - FROM apipayments - INNER JOIN wallets AS w ON apipayments.wallet = w.id - WHERE payhash = ? - AND (w.adminkey = ? OR w.inkey = ?) - """, - (payhash, request.headers["Grpc-Metadata-macaroon"], request.headers["Grpc-Metadata-macaroon"]), - ) + with open_db() as db: + payment = db.fetchall("SELECT * FROM apipayments WHERE payhash = ?", (payhash,)) + if not payment: return jsonify({"ERROR": "NO INVOICE"}), 404 - if not payment["pending"]: # pending + if not payment[0][4]: # pending return jsonify({"PAID": "TRUE"}), 200 if not WALLET.get_invoice_status(payhash).settled: