From 96e0e720fd7ab8e990b2dbadc979e5f0d6599c36 Mon Sep 17 00:00:00 2001 From: Rob N Date: Thu, 22 Aug 2024 10:33:14 -1000 Subject: [PATCH] feat(bip158): compute canonical filter hash --- bitcoin/src/bip158.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bitcoin/src/bip158.rs b/bitcoin/src/bip158.rs index 1e509dba1..414a0457e 100644 --- a/bitcoin/src/bip158.rs +++ b/bitcoin/src/bip158.rs @@ -149,6 +149,12 @@ impl BlockFilter { FilterHash(sha256d::Hash::hash(&self.content)).filter_header(previous_filter_header) } + /// Computes the canonical hash for the given filter. + pub fn filter_hash(&self) -> FilterHash { + let hash = sha256d::Hash::hash(&self.content); + FilterHash(hash) + } + /// Returns true if any query matches against this [`BlockFilter`]. pub fn match_any(&self, block_hash: BlockHash, query: I) -> Result where