From 6ce0387e1c71dc3ada762458da0b65de30df1858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 25 Jul 2023 15:13:34 +0200 Subject: [PATCH] FEAT: proper failing invoice/payment responses for VoidWallet (#1805) before that change anyone using the api just got a 500 error without any error message. there was also a bug stacetrace in the logs each time. flake8 --- lnbits/wallets/void.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lnbits/wallets/void.py b/lnbits/wallets/void.py index 60f981ea8..1d0ff90a9 100644 --- a/lnbits/wallets/void.py +++ b/lnbits/wallets/void.py @@ -1,4 +1,4 @@ -from typing import AsyncGenerator, Optional +from typing import AsyncGenerator from loguru import logger @@ -7,20 +7,15 @@ from .base import ( PaymentResponse, PaymentStatus, StatusResponse, - Unsupported, Wallet, ) class VoidWallet(Wallet): - async def create_invoice( - self, - amount: int, - memo: Optional[str] = None, - description_hash: Optional[bytes] = None, - **kwargs, - ) -> InvoiceResponse: - raise Unsupported("") + async def create_invoice(self, *_, **__) -> InvoiceResponse: + return InvoiceResponse( + ok=False, error_message="VoidWallet cannot create invoices." + ) async def status(self) -> StatusResponse: logger.warning( @@ -31,13 +26,15 @@ class VoidWallet(Wallet): ) return StatusResponse(None, 0) - async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse: - raise Unsupported("") + async def pay_invoice(self, *_, **__) -> PaymentResponse: + return PaymentResponse( + ok=False, error_message="VoidWallet cannot pay invoices." + ) - async def get_invoice_status(self, checking_id: str) -> PaymentStatus: + async def get_invoice_status(self, *_, **__) -> PaymentStatus: return PaymentStatus(None) - async def get_payment_status(self, checking_id: str) -> PaymentStatus: + async def get_payment_status(self, *_, **__) -> PaymentStatus: return PaymentStatus(None) async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: