tImplement blockchain.scripthash.unsubscribe - obelisk - Electrum server using libbitcoin as its backend HTML git clone https://git.parazyd.org/obelisk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 176e3362ff4e9d62d07284082977d5eab4fa718c DIR parent 7bf03633848c6e778a20476cefc151d7fb70ef64 HTML Author: parazyd <parazyd@dyne.org> Date: Thu, 8 Apr 2021 15:05:00 +0200 Implement blockchain.scripthash.unsubscribe Diffstat: M electrumobelisk/protocol.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- DIR diff --git a/electrumobelisk/protocol.py b/electrumobelisk/protocol.py t@@ -64,6 +64,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 self.block_queue = None # TODO: Clean up on client disconnect self.tasks = [] + self.sh_subscriptions = {} if chain == "mainnet": self.genesis = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" t@@ -337,7 +338,17 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 Unsubscribe from a script hash, preventing future notifications if its status changes. """ - return + if "params" not in query or len(query["params"]) != 1: + return {"error": "malformed request"} + + scripthash = query["params"][0] + if not is_hash256_str(scripthash): + return {"error": "invalid scripthash"} + + if scripthash in self.sh_subscriptions: + self.sh_subscriptions[scripthash].cancel() + return {"result": True} + return {"result": False} async def blockchain_transaction_broadcast(self, writer, query): # pylint: disable=W0613 """Method: blockchain.transaction.broadcast