Skip to content

Commit

Permalink
add support for blockchain.scripthash.unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
rikublock committed May 24, 2024
1 parent 5db7d2b commit 25396a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/electrum/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ impl Connection {
Ok(status_hash)
}

fn blockchain_scripthash_unsubscribe(&mut self, params: &[Value]) -> Result<Value> {
let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?;

match self.status_hashes.remove(&script_hash) {
None => Ok(json!(false)),
Some(_) => {
self.stats.subscriptions.dec();
Ok(json!(true))
}
}
}

#[cfg(not(feature = "liquid"))]
fn blockchain_scripthash_get_balance(&self, params: &[Value]) -> Result<Value> {
let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?;
Expand Down Expand Up @@ -430,6 +442,7 @@ impl Connection {
"blockchain.scripthash.get_history" => self.blockchain_scripthash_get_history(&params),
"blockchain.scripthash.listunspent" => self.blockchain_scripthash_listunspent(&params),
"blockchain.scripthash.subscribe" => self.blockchain_scripthash_subscribe(&params),
"blockchain.scripthash.unsubscribe" => self.blockchain_scripthash_unsubscribe(&params),
"blockchain.transaction.broadcast" => self.blockchain_transaction_broadcast(&params),
"blockchain.transaction.get" => self.blockchain_transaction_get(&params),
"blockchain.transaction.get_merkle" => self.blockchain_transaction_get_merkle(&params),
Expand Down

0 comments on commit 25396a9

Please sign in to comment.