rust-bitcoin / bitcoin_hashes

Simple library which implements a few hashes and does nothing else
Creative Commons Zero v1.0 Universal
66 stars 52 forks source link

Add all_zeros method to Hash trait #148

Closed tcharding closed 2 years ago

tcharding commented 2 years ago

Currently we use Default::default() to get an all zeros hash. This is confusing because an all zeroes hash does not have a real meaning since there is no known input to create it. The all zeros hash is, however used by the Bitcoin network to signify certain things (e.g. the previous blockhash in the genesis block).

Remove the Default implementation from the Hash trait and add a all_zeros method instead. Remove the Default derive from any hash type that has it.

To see the patch to rust-bitcoin that this PR imposes, check out this branch.

Resolves #139

tcharding commented 2 years ago

This is a breaking change and requires a major version bump.

Whats the policy for changes like this across the rust-bitcoin stack? Should this PR have included a change to bump the version number or do we rely on you to work this out when you do the release?

apoelstra commented 2 years ago

@tcharding we don't have an explicit policy ... but yes, "we rely on me to work it out" is usually what we do.

Sometimes people want a minor version bump for some specific feature, in which case I ask them to put the bump into the PR ... but for major ones I don't think we ever do that.

tcharding commented 2 years ago

Friendly bump please review crew.

apoelstra commented 2 years ago

Let's do it. We can bring this into the MSRV-bumping release, this crate is simple enough that I don't worry about breaking too much at once.