diff --git a/cashu/lightning/nwc.py b/cashu/lightning/nwc.py index 3c61cce4..12c29d82 100644 --- a/cashu/lightning/nwc.py +++ b/cashu/lightning/nwc.py @@ -1,4 +1,4 @@ -from typing import AsyncGenerator +from typing import Optional, AsyncGenerator from bolt11 import decode from loguru import logger @@ -25,20 +25,20 @@ class NWCWallet(LightningBackend): - supported_units = [Unit.sat] + + supported_units = {Unit.sat} def __init__(self, unit: Unit, **kwargs): logger.debug(f"Initializing NWCWallet with unit: {unit}") self.assert_unit_supported(unit) self.unit = unit - self.supported_units = [Unit.sat, Unit.usd, Unit.msat] self.client = NWCClient(nostrWalletConnectUrl=settings.mint_nwc_url) async def status(self) -> StatusResponse: try: res = await self.client.get_balance() balance_msat = res.balance - return StatusResponse(balance=balance_msat // 1000) + return StatusResponse(balance=balance_msat // 1000, error_message=None) except Nip47Error as exc: return StatusResponse( error_message=str(exc), @@ -53,8 +53,9 @@ async def status(self) -> StatusResponse: async def create_invoice( self, amount: Amount, - memo: str | None = None, - description_hash: bytes | None = None, + memo: Optional[str] = None, + description_hash: Optional[bytes] = None, + unhashed_description: Optional[str] = None, ) -> InvoiceResponse: try: res = await self.client.create_invoice( @@ -69,21 +70,11 @@ async def create_invoice( except Nip47Error as exc: return InvoiceResponse( error_message=str(exc), - checking_id="", - bolt11="", - amount=0, - expires_at=0, - created_at=0, ok=False, ) except Exception as exc: return InvoiceResponse( error_message=f"Failed to create invoice due to: {exc}", - checking_id="", - bolt11="", - amount=0, - expires_at=0, - created_at=0, ok=False, ) @@ -168,4 +159,4 @@ async def get_payment_quote( ) async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: - raise NotImplementedError("paid_invoices_stream not implemented") + raise NotImplementedError("paid_invoices_stream not implemented") \ No newline at end of file