json rpc – How to use `blockchain.scripthash.subscribe` from a tcp socket in Electrum server

Have I understood the concept of address, account and wallet correctly and how the wallet balance is calculated?

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:

  1. 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.

  2. 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

  1. 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.

Source link

What do you think?

Written by BTC Artist

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

It’s Now Too Difficult To Run a Centralized Crypto Exchange, Says Hotbit As It Shuts Down

It’s Now Too Difficult To Run a Centralized Crypto Exchange, Says Hotbit As It Shuts Down

Hong Kong High Court shines a light on crypto’s future 

Coinbase advocates for better crypto regulations in US