Skip to content

Commit e55afdc

Browse files
authored
Merge pull request Blockstream#122 from mempool/junderw/add-unsubscribe
Feat: Add blockchain.scripthash.unsubscribe to Electrum server impl
2 parents 4d1fdaf + 4081edc commit e55afdc

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/electrum/server.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ impl Connection {
308308
Ok(status_hash)
309309
}
310310

311+
fn blockchain_scripthash_unsubscribe(&mut self, params: &[Value]) -> Result<Value> {
312+
let script_hash = hash_from_value(params.first()).chain_err(|| "bad script_hash")?;
313+
314+
let removed = self.status_hashes.remove(&script_hash).is_some();
315+
if removed {
316+
self.stats.subscriptions.dec();
317+
}
318+
Ok(Value::Bool(removed))
319+
}
320+
311321
#[cfg(not(feature = "liquid"))]
312322
fn blockchain_scripthash_get_balance(&self, params: &[Value]) -> Result<Value> {
313323
let script_hash = hash_from_value(params.first()).chain_err(|| "bad script_hash")?;
@@ -446,6 +456,7 @@ impl Connection {
446456
"blockchain.scripthash.get_history" => self.blockchain_scripthash_get_history(params),
447457
"blockchain.scripthash.listunspent" => self.blockchain_scripthash_listunspent(params),
448458
"blockchain.scripthash.subscribe" => self.blockchain_scripthash_subscribe(params),
459+
"blockchain.scripthash.unsubscribe" => self.blockchain_scripthash_unsubscribe(params),
449460
"blockchain.transaction.broadcast" => self.blockchain_transaction_broadcast(params),
450461
"blockchain.transaction.get" => self.blockchain_transaction_get(params),
451462
"blockchain.transaction.get_merkle" => self.blockchain_transaction_get_merkle(params),

0 commit comments

Comments
 (0)