removed unincrement
This commit is contained in:
parent
776946603b
commit
8128154492
2 changed files with 1 additions and 11 deletions
7
crud.py
7
crud.py
|
|
@ -116,13 +116,6 @@ async def increment_withdraw_link(link: WithdrawLink) -> None:
|
||||||
open_time=link.wait_time + int(datetime.now().timestamp()),
|
open_time=link.wait_time + int(datetime.now().timestamp()),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def unincrement_withdraw_link(link: WithdrawLink) -> None:
|
|
||||||
await update_withdraw_link(
|
|
||||||
link.id,
|
|
||||||
used=link.used - 1,
|
|
||||||
open_time=link.wait_time + int(datetime.now().timestamp()),
|
|
||||||
)
|
|
||||||
|
|
||||||
async def update_withdraw_link(link_id: str, **kwargs) -> Optional[WithdrawLink]:
|
async def update_withdraw_link(link_id: str, **kwargs) -> Optional[WithdrawLink]:
|
||||||
if "is_unique" in kwargs:
|
if "is_unique" in kwargs:
|
||||||
kwargs["is_unique"] = int(kwargs["is_unique"])
|
kwargs["is_unique"] = int(kwargs["is_unique"])
|
||||||
|
|
|
||||||
5
lnurl.py
5
lnurl.py
|
|
@ -16,7 +16,6 @@ from . import withdraw_ext
|
||||||
from .crud import (
|
from .crud import (
|
||||||
get_withdraw_link_by_hash,
|
get_withdraw_link_by_hash,
|
||||||
increment_withdraw_link,
|
increment_withdraw_link,
|
||||||
unincrement_withdraw_link,
|
|
||||||
remove_unique_withdraw_link,
|
remove_unique_withdraw_link,
|
||||||
delete_hash_check,
|
delete_hash_check,
|
||||||
create_hash_check
|
create_hash_check
|
||||||
|
|
@ -105,8 +104,6 @@ async def api_lnurl_callback(
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.METHOD_NOT_ALLOWED, detail="withdraw is spent."
|
status_code=HTTPStatus.METHOD_NOT_ALLOWED, detail="withdraw is spent."
|
||||||
)
|
)
|
||||||
|
|
||||||
await increment_withdraw_link(link)
|
|
||||||
|
|
||||||
if link.k1 != k1:
|
if link.k1 != k1:
|
||||||
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail="k1 is wrong.")
|
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail="k1 is wrong.")
|
||||||
|
|
@ -134,6 +131,7 @@ async def api_lnurl_callback(
|
||||||
max_sat=link.max_withdrawable,
|
max_sat=link.max_withdrawable,
|
||||||
extra={"tag": "withdraw", "withdrawal_link_id": link.id},
|
extra={"tag": "withdraw", "withdrawal_link_id": link.id},
|
||||||
)
|
)
|
||||||
|
await increment_withdraw_link(link)
|
||||||
# If the payment succeeds, delete the record with the unique_hash. If it has unique_hash, do not delete to prevent the same LNURL from being processed twice.
|
# If the payment succeeds, delete the record with the unique_hash. If it has unique_hash, do not delete to prevent the same LNURL from being processed twice.
|
||||||
if not id_unique_hash:
|
if not id_unique_hash:
|
||||||
await delete_hash_check(unique_hash)
|
await delete_hash_check(unique_hash)
|
||||||
|
|
@ -146,7 +144,6 @@ async def api_lnurl_callback(
|
||||||
await delete_hash_check(id_unique_hash)
|
await delete_hash_check(id_unique_hash)
|
||||||
else:
|
else:
|
||||||
await delete_hash_check(unique_hash)
|
await delete_hash_check(unique_hash)
|
||||||
await unincrement_withdraw_link(link)
|
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST, detail=f"withdraw not working. {str(e)}"
|
status_code=HTTPStatus.BAD_REQUEST, detail=f"withdraw not working. {str(e)}"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue