From 16cb1a80264fc2235addf49235e7e73a04533ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 12 Mar 2024 11:28:42 +0100 Subject: [PATCH] fix: lnbits funding source (#2319) fix a bug where payments are deleted --- lnbits/wallets/lnbits.py | 10 +++++++--- tests/core/views/test_api.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lnbits/wallets/lnbits.py b/lnbits/wallets/lnbits.py index 18e977c0f..0eccda346 100644 --- a/lnbits/wallets/lnbits.py +++ b/lnbits/wallets/lnbits.py @@ -129,12 +129,16 @@ class LNbitsWallet(Wallet): r = await self.client.get(url=f"/api/v1/payments/{checking_id}") if r.is_error: - return PaymentStatus(False) + return PaymentStatus(None) data = r.json() - if "paid" not in data and "details" not in data: + + if "paid" not in data or not data["paid"]: return PaymentStatus(None) - return PaymentStatus(data["paid"], data["details"]["fee"], data["preimage"]) + if "details" not in data: + return PaymentStatus(None) + + return PaymentStatus(True, data["details"]["fee"], data["preimage"]) async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: url = f"{self.endpoint}/api/v1/payments/sse" diff --git a/tests/core/views/test_api.py b/tests/core/views/test_api.py index f3306c49e..7eef8a99b 100644 --- a/tests/core/views/test_api.py +++ b/tests/core/views/test_api.py @@ -763,7 +763,7 @@ async def test_pay_hold_invoice_check_pending_and_fail_cancel_payment_task_in_me # status should still be available and be False status = await payment_db.check_status() - assert status.paid is False + assert not status.paid # now the payment should be gone after the status check # payment_db_after_status_check = await get_standalone_payment(