diff --git a/lnbits/extensions/withdraw/crud.py b/lnbits/extensions/withdraw/crud.py index 18f77db0..3fc90f81 100644 --- a/lnbits/extensions/withdraw/crud.py +++ b/lnbits/extensions/withdraw/crud.py @@ -118,11 +118,17 @@ async def create_hash_check( ), ) hashCheck = await get_hash_check(the_hash, lnurl_id) - row = await db.fetchone("SELECT * FROM hash_check WHERE id = ?", (the_hash,)) - return HashCheck.from_row(row) if row else None + return hashCheck async def get_hash_check(the_hash: str, lnurl_id: str) -> Optional[HashCheck]: - row = await db.fetchone("SELECT * FROM hash_check WHERE id = ?", (the_hash,)) - - return HashCheck.from_row(row) if row else None \ No newline at end of file + rowid = await db.fetchone("SELECT * FROM hash_check WHERE id = ?", (the_hash,)) + rowlnurl = await db.fetchone("SELECT * FROM hash_check WHERE lnurl_id = ?", (the_hash,)) + if not rowlnurl: + return {"lnurl": False, "hash": False} + else: + if not rowid: + await create_hash_check(the_hash, lnurl_id) + return {"lnurl": True, "hash": False} + else: + return {"lnurl": True, "hash": True} \ No newline at end of file diff --git a/lnbits/extensions/withdraw/views_api.py b/lnbits/extensions/withdraw/views_api.py index 2f80aab5..2b6cb600 100644 --- a/lnbits/extensions/withdraw/views_api.py +++ b/lnbits/extensions/withdraw/views_api.py @@ -119,9 +119,4 @@ async def api_link_delete(link_id): @api_check_wallet_key("invoice") async def api_hash_retrieve(the_hash, lnurl_id): hashCheck = await get_hash_check(the_hash, lnurl_id) - - if not hashCheck: - hashCheck = await create_hash_check(the_hash, lnurl_id) - return jsonify({"status": False}), HTTPStatus.OK - - return jsonify({"status": True}), HTTPStatus.OK + return jsonify(hashCheck), HTTPStatus.OK \ No newline at end of file