As a personal exercise I want to write a minimal copy of BTCPayServer. I decided to use Electrum server instead of a node to fetch information from the network. My final goal is to be able to track the transactions received by an address, but so far I’m stuck. I was able to use
blockchain.scripthash.get_balance after some work, but now I’m having issues with
blockchain.scripthash.subscribe. There are 2 things that confuse me:
This method is supposed to establish a subscription and return a notification every time the scripthash changes, as explained here. How are these notifications returned? If I keep the tcp socket open for too long, the connection is eventually closed. When I read the jsonrpc spec, notifications are more akin to something the client sends to the server, not the other way around.
How can I decode the returned status? I’ve read the electrumx’s docs, but I’m not sure how to reverse this last step
- The status of the script hash is the sha256() hash of the full string expressed as a hexadecimal string, or null if the string is empty because there are no transactions.
I’d really appreciate it if anyone has any experience, or can point me to some code/articles that explain in detail how to properly integrate electrum.