lnbits / lndhub

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

Error importing admin wallet into Bluewallet through LNDhub #9

Closed 20a8vnf30 closed 1 month ago

20a8vnf30 commented 1 year ago

I'm still experiencing this issue with my admin wallet after updating to 0.10.8. I open the LNDhub extension as the admin/superuser, use the Bluewallet import function to scan the admin QR, Bluewallet throws an error: "Import error" "undefined is not a function" The relevant LNbits log lines are below.

My admin/superuser has one wallet, the wallet has had several topups over the last few months, it has done boltcard payments, received some sats and paid some invoices, it has done a total of 20 transactions. Wallets from other users don't have this problem and can be imported into Bluewallet just fine, I'm not sure why because the other wallets have had similar use happening. Is there something special about the admin wallet?

Jun 02 18:46:55 NUC poetry[2184805]: 2023-06-02 18:46:55.65 | INFO | [removed to not dox IP] - "POST /lndhub/ext/auth?type=auth HTTP/1.0" 200
Jun 02 18:46:55 NUC poetry[2184805]: 2023-06-02 18:46:55.67 | INFO | [removed to not dox IP] - "GET /lndhub/ext/gettxs?limit=10&offset=0 HTTP/1.0" 200
Jun 02 18:46:55 NUC poetry[2184805]: Traceback (most recent call last):
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, _send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/bitcoin/lnbits/lnbits/middleware.py", line 131, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/bitcoin/lnbits/lnbits/middleware.py", line 63, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 24, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await responder(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/middleware/gzip.py", line 43, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, self.send_with_gzip)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/middleware/cors.py", line 84, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/exceptions.py", line 93, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     raise exc
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, sender)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     raise e
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/routing.py", line 670, in __call__
Jun 02 18:46:55 NUC poetry[2184805]:     await route.handle(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/routing.py", line 266, in handle
Jun 02 18:46:55 NUC poetry[2184805]:     await self.app(scope, receive, send)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
Jun 02 18:46:55 NUC poetry[2184805]:     response = await func(request)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/fastapi/routing.py", line 231, in app
Jun 02 18:46:55 NUC poetry[2184805]:     raw_response = await run_endpoint_function(
Jun 02 18:46:55 NUC poetry[2184805]:   File "/home/lnbits/.cache/pypoetry/virtualenvs/lnbits-N2LfHUJp-py3.9/lib/python3.9/site-packages/fastapi/routing.py", line 160, in run_endpoint_function
Jun 02 18:46:55 NUC poetry[2184805]:     return await dependant.call(**values)
Jun 02 18:46:55 NUC poetry[2184805]:   File "/bitcoin/lnbits/lnbits/extensions/lndhub/views_api.py", line 181, in lndhub_getuserinvoices
Jun 02 18:46:55 NUC poetry[2184805]:     return [
Jun 02 18:46:55 NUC poetry[2184805]:   File "/bitcoin/lnbits/lnbits/extensions/lndhub/views_api.py", line 183, in <listcomp>
Jun 02 18:46:55 NUC poetry[2184805]:     "r_hash": to_buffer(invoice.payment_hash),
Jun 02 18:46:55 NUC poetry[2184805]:   File "/bitcoin/lnbits/lnbits/extensions/lndhub/utils.py", line 5, in to_buffer
Jun 02 18:46:55 NUC poetry[2184805]:     return {"type": "Buffer", "data": [b for b in bytes.fromhex(payment_hash)]}
Jun 02 18:46:55 NUC poetry[2184805]: ValueError: non-hexadecimal number found in fromhex() arg at position 2
Jun 02 18:46:55 NUC poetry[2184805]: 2023-06-02 18:46:55.70 | ERROR | Exception: non-hexadecimal number found in fromhex() arg at position 2
Jun 02 18:46:55 NUC poetry[2184805]: 2023-06-02 18:46:55.71 | INFO | [removed to not dox IP] - "GET /lndhub/ext/getuserinvoices HTTP/1.0" 500
Jun 02 18:46:55 NUC poetry[2184805]: 2023-06-02 18:46:55.71 | ERROR | Exception in ASGI application
talvasconcelos commented 11 months ago

Does this issue still exist on latest version?

20a8vnf30 commented 11 months ago

Does this issue still exist on latest version?

Yes the same thing still happens in 0.10.9, I checked just now.

dni commented 11 months ago

can you check your db if there is any payment where the payment_hash looks off, we had an issue long time ago with admin topups that generated wrong payment_hash. if so i would delete those and create new topups.

20a8vnf30 commented 11 months ago

I'm not sure I'm doing this right, I run this query: SELECT * FROM apipayments WHERE memo="Admin top up";

It returns two types of transactions, the older ones where the field "hash" has the value "admin_internal", and more recent transactions where the field "hash" is an actual hash.

I'm guessing the older transactions are the problem, should I remove those? Will deleting only the transactions cause any trouble in the DB?

I'm not sure I'm doing this right, I run this query: SELECT * FROM apipayments WHERE memo="Admin top up";

It returns two types of transactions, the older ones where the field "hash" has the value "admin_internal", and more recent transactions where the field "hash" is an actual hash.

I'm guessing the older transactions are the problem, should I remove those? Will deleting only the transactions cause any trouble in the DB?

/EDIT

That fixed it, for future reference I ran this query: DELETE FROM apipayments WHERE memo="Admin top up" AND hash="admin_internal";

The admin wallet can now be successfully imported into Bluewallet through the LNDhub Admin QR. Issue can be closed.