Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Universal websockets API for bitcoinSwitch #8

Open
AxelHamburch opened this issue Apr 7, 2023 · 10 comments
Open

Suggestion: Universal websockets API for bitcoinSwitch #8

AxelHamburch opened this issue Apr 7, 2023 · 10 comments

Comments

@AxelHamburch
Copy link

Is it possible to monitor an entire LNbits wallet and whenever a change in wallet balance occurs, trigger an ESP32 via a websockets connection and pass at least the wallet balance?

This would make us independent of the type of payment. No matter if it was a LNURLp, LNURLw or even a payment initiated by another extension, the evaluation can then be done via the ESP32. This would give a much wider scope and simplify the LNbits side. You could write a separate program for each function. Or one writes a comprehensive program with many functions and lets the user select / parameterize the functions later via a web interface. The function of the bitcoinSwitch would be universally applicable.

One could write the program then also in MircoPython with e.g. Thonny. That would extend the Nuterbasis again enormously. It would increase the felxibilität, since one would not have to adapt for each function or change the mother ship LNbits / LNURLDevice. You get an incredible felxibility on the ESP32 side.

With polling, querying the wallet balance is already possible now, but this is not the right way for mass application. If thousands of bitcoinSwitch later poll the server every second, that's a big load. Therefore the way over a websocket API which transmits at least the balance when the wallet balance changes. If possible, even the information whether it is a LNURLp, LNURLw or whatever is possible. The more information, the more options and functions on the EPS32 side.

Is it possible to program such an API?

@arcbtc
Copy link
Member

arcbtc commented May 2, 2023

Damn, I overlooked this. Its a good idea, we should add

@dni
Copy link
Member

dni commented May 3, 2023

i like the concept

@AxelHamburch
Copy link
Author

I have tested the commit lnbits/paymentsocketjson once. Unfortunately, it did not recognize withdrawals, but deposits via an invoice were often, but not always recognized.

Here is a deposit that was also reported to the ESP32 via websocket. You can see that quite well on the PaymentHash.

Zahlung die übermittelt wurde
Zahlung Payment Hash

And here a deposit which was not reported to ESP32.

Zahlung die nicht übermittelt wurde

And this is what a payment to an external wallet looks like. But unfortunately the ESP32 does not get this.

Auszahlung ohne Übermittlung

@arcbtc
Copy link
Member

arcbtc commented May 3, 2023

How big is you json file on the esp?

@arcbtc
Copy link
Member

arcbtc commented May 3, 2023

Also try testing on an online websocket tester

@arcbtc
Copy link
Member

arcbtc commented May 4, 2023

I tested and it seems to work fine for incoming, outgoiing is not working though
https://user-images.githubusercontent.com/33088785/236172063-1b305ce7-8e46-46f3-9179-87a46b435a2a.mp4

@btchans
Copy link

btchans commented May 4, 2023

I tested and it seems to work fine for incoming, outgoiing is not working though https://user-images.githubusercontent.com/33088785/236172063-1b305ce7-8e46-46f3-9179-87a46b435a2a.mp4

Yes, I can confirm that.
All incoming transactions are also output via websocket message.

Only outgoing transactions are not signalled by the WebSocket.

@AxelHamburch
Copy link
Author

I tested and it seems to work fine for incoming, outgoiing is not working though https://user-images.githubusercontent.com/33088785/236172063-1b305ce7-8e46-46f3-9179-87a46b435a2a.mp4

Then maybe I have a problem with my LNbits instance. Maybe the idea of ​​using Python 3.10 wasn't that good, or something didn't go 100% correctly during the installation. I think I'll set it up again and then use Python 3.9.

@AxelHamburch
Copy link
Author

Ok, I did a fresh LNbits instance with pyhton 3.9 and I now alle deposits are reported. Then the problem with the invoice listener might be a problem ob my pyhton 3.10 instance.

I now checkt alle three functions

000

Only deposit triggers the ESP32

2023-05-07 09_30_45-Thonny  -  MicroPython device __ _main py  @  30 _ 17

I also tested the Websocket for me there are deposit and LNURLp was working.

001

@btchans Can you confirm my that?. Why does LNURLp not trigger the ESP32?

@btchans
Copy link

btchans commented May 8, 2023

I can confirm.
No Message on outgoing transactions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants