Merge rust-bitcoin/rust-bitcoin#3221: feat(bip158): compute canonical filter hash
96e0e720fd
feat(bip158): compute canonical filter hash (Rob N) Pull request description: From [BIP-157](https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki#filter-headers) > The canonical hash of a block filter is the double-SHA256 of the serialized filter. If a user forgets the "double" in double-SHA256 they will be computing a nonsensical filter hash when this is easily handled by the API. ACKs for top commit: Kixunil: ACK96e0e720fd
tcharding: ACK96e0e720fd
Tree-SHA512: 5fc0b1632e2327adacbd0ab56b4cd7edce0774f8be2f819782519c51b9691a748f4b3c01887f3bf1146dee49a35f9dfac833f53ae69ee7a53858bd2cedcec01a
This commit is contained in:
commit
b4bda00141
|
@ -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<I>(&self, block_hash: BlockHash, query: I) -> Result<bool, Error>
|
||||
where
|
||||
|
|
Loading…
Reference in New Issue