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(
|
async def check_internal(
|
||||||
payment_hash: str, conn: Optional[Connection] = None
|
payment_hash: str, conn: Optional[Connection] = None
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from . import db
|
||||||
from .crud import (
|
from .crud import (
|
||||||
check_internal,
|
check_internal,
|
||||||
create_payment,
|
create_payment,
|
||||||
delete_payment,
|
delete_wallet_payment,
|
||||||
get_wallet,
|
get_wallet,
|
||||||
get_wallet_payment,
|
get_wallet_payment,
|
||||||
update_payment_details,
|
update_payment_details,
|
||||||
|
|
@ -221,7 +221,7 @@ async def pay_invoice(
|
||||||
logger.warning(f"backend sent payment failure")
|
logger.warning(f"backend sent payment failure")
|
||||||
async with db.connect() as conn:
|
async with db.connect() as conn:
|
||||||
logger.debug(f"deleting temporary payment {temp_id}")
|
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(
|
raise PaymentFailure(
|
||||||
f"payment failed: {payment.error_message}"
|
f"payment failed: {payment.error_message}"
|
||||||
or "payment failed, but backend didn't give us an error message"
|
or "payment failed, but backend didn't give us an error message"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue