mirror of
https://github.com/lnbits/lnbits.git
synced 2025-05-05 01:00:17 +02:00
Changed api to check lnurl exists and checking hash sent
This commit is contained in:
parent
ddb277ff92
commit
fa383ced1c
@ -118,11 +118,17 @@ async def create_hash_check(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
hashCheck = await get_hash_check(the_hash, lnurl_id)
|
hashCheck = await get_hash_check(the_hash, lnurl_id)
|
||||||
row = await db.fetchone("SELECT * FROM hash_check WHERE id = ?", (the_hash,))
|
return hashCheck
|
||||||
return HashCheck.from_row(row) if row else None
|
|
||||||
|
|
||||||
|
|
||||||
async def get_hash_check(the_hash: str, lnurl_id: str) -> Optional[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,))
|
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,))
|
||||||
return HashCheck.from_row(row) if row else None
|
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}
|
@ -119,9 +119,4 @@ async def api_link_delete(link_id):
|
|||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
async def api_hash_retrieve(the_hash, lnurl_id):
|
async def api_hash_retrieve(the_hash, lnurl_id):
|
||||||
hashCheck = await get_hash_check(the_hash, lnurl_id)
|
hashCheck = await get_hash_check(the_hash, lnurl_id)
|
||||||
|
return jsonify(hashCheck), HTTPStatus.OK
|
||||||
if not hashCheck:
|
|
||||||
hashCheck = await create_hash_check(the_hash, lnurl_id)
|
|
||||||
return jsonify({"status": False}), HTTPStatus.OK
|
|
||||||
|
|
||||||
return jsonify({"status": True}), HTTPStatus.OK
|
|
Loading…
x
Reference in New Issue
Block a user