From 239900ed300a380b66e4044fafbb968d63e3a5da Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Mon, 9 Nov 2020 08:34:47 +0200 Subject: [PATCH] Add blockchain.scripthash.unsubscribe --- electrs_rpc/src/rpc.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/electrs_rpc/src/rpc.rs b/electrs_rpc/src/rpc.rs index 801fdcf..0491ca1 100644 --- a/electrs_rpc/src/rpc.rs +++ b/electrs_rpc/src/rpc.rs @@ -401,6 +401,14 @@ impl Rpc { Ok(json!(hash)) } + fn scripthash_unsubscribe( + &self, + subscription: &mut Subscription, + (scripthash,): (ScriptHash,), + ) -> Result { + Ok(json!(subscription.status.remove(&scripthash).is_some())) + } + fn get_confirmed(&self, scripthash: &ScriptHash) -> Result<(Vec, BlockHash)> { let result = self .index @@ -569,6 +577,9 @@ impl Rpc { "blockchain.scripthash.subscribe" => { self.scripthash_subscribe(sub, from_value(params)?) } + "blockchain.scripthash.unsubscribe" => { + self.scripthash_unsubscribe(sub, from_value(params)?) + } "blockchain.transaction.broadcast" => { self.transaction_broadcast(from_value(params)?) }