lnbits / lndhub

Access lnbits from BlueWallet or Zeus
MIT License
5 stars 6 forks source link

problematic use a fundingsource directly #27

Closed dni closed 3 months ago

dni commented 5 months ago

https://github.com/lnbits/lndhub/blob/main/views_api.py#L13

Amperstrand commented 4 months ago

I think I ran into something that is related to this issue and am leaving some notes to try to diagnose the problem.

Wallets don't implement invoice_status, they only have a get_invoice_status method:

The lndhub plugin tries to call invoice_status

this in turn tries to call invoice_status from the lnbits/wallets/x.py.

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/anyio/streams/memory.py", line 98, in receive
    return self.receive_nowait()
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/anyio/streams/memory.py", line 93, in receive_nowait
    raise WouldBlock
anyio.WouldBlock
2024-05-15 14:23:09.94 | ERROR | lnbits.app:exception_handler:439 | Exception: 'CLNRestWallet' object has no attribute 'invoice_status'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 159, in call_next
    message = await recv_stream.receive()
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/anyio/streams/memory.py", line 118, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/slowapi/middleware.py", line 136, in dispatch
    response = await call_next(request)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/app/lnbits/middleware.py", line 215, in block_allow_ip_middleware
    return await call_next(request)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/app/lnbits/middleware.py", line 215, in block_allow_ip_middleware
    return await call_next(request)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/app/lnbits/middleware.py", line 230, in first_install_middleware
    return await call_next(request)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/app/lnbits/middleware.py", line 230, in first_install_middleware
    return await call_next(request)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/app/lnbits/middleware.py", line 125, in __call__
    await self.app(scope, receive, send)
  File "/app/lnbits/middleware.py", line 61, in __call__
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/sessions.py", line 83, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/app/lnbits/middleware.py", line 104, in __call__
    await super().__call__(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 24, in __call__
    await responder(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 44, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
    await route.handle(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
    await self.app(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 74, in app
    response = await func(request)
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 299, in app
    raise e
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 294, in app
    raw_response = await run_endpoint_function(
  File "/root/.cache/pypoetry/virtualenvs/lnbits-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
  File "/app/lnbits/extensions/lndhub/views_api.py", line 180, in lndhub_getuserinvoices
    (await funding_source.invoice_status(invoice.checking_id)).pending
AttributeError: 'CLNRestWallet' object has no attribute 'invoice_status'. Did you mean: 'get_invoice_status'?

These lines are probably relevant:

https://github.com/lnbits/lnbits/blob/5114bd4a47f3bb6aaaf95b4c9b8722734ec9c5dc/lnbits/settings.py#L558

https://github.com/lnbits/lndhub/commit/75c2b0b7f1d081dca39fa63a473b0d3427245a52

dni commented 3 months ago

fix and released in v0.5.0 https://github.com/lnbits/lndhub/pull/32