mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-23 22:47:05 +01:00
Fix/duplicate payments (#973)
* check if wallet exists * check wallet existence in key check * fix duplicate removal
This commit is contained in:
parent
232d50baaa
commit
e7a6e86e7a
2 changed files with 11 additions and 2 deletions
|
@ -452,6 +452,15 @@ async def delete_payment(checking_id: str, conn: Optional[Connection] = None) ->
|
|||
)
|
||||
|
||||
|
||||
async def delete_wallet_payment(
|
||||
checking_id: str, wallet_id: str, conn: Optional[Connection] = None
|
||||
) -> None:
|
||||
await (conn or db).execute(
|
||||
"DELETE FROM apipayments WHERE checking_id = ? AND wallet = ?",
|
||||
(checking_id, wallet_id),
|
||||
)
|
||||
|
||||
|
||||
async def check_internal(
|
||||
payment_hash: str, conn: Optional[Connection] = None
|
||||
) -> Optional[str]:
|
||||
|
|
|
@ -28,7 +28,7 @@ from . import db
|
|||
from .crud import (
|
||||
check_internal,
|
||||
create_payment,
|
||||
delete_payment,
|
||||
delete_wallet_payment,
|
||||
get_wallet,
|
||||
get_wallet_payment,
|
||||
update_payment_details,
|
||||
|
@ -221,7 +221,7 @@ async def pay_invoice(
|
|||
logger.warning(f"backend sent payment failure")
|
||||
async with db.connect() as conn:
|
||||
logger.debug(f"deleting temporary payment {temp_id}")
|
||||
await delete_payment(temp_id, conn=conn)
|
||||
await delete_wallet_payment(temp_id, wallet_id, conn=conn)
|
||||
raise PaymentFailure(
|
||||
f"payment failed: {payment.error_message}"
|
||||
or "payment failed, but backend didn't give us an error message"
|
||||
|
|
Loading…
Add table
Reference in a new issue