You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #278: Clean up hashes and related types ahead of bitcoin_hashes 1.0
fa3ea85 address: introduce constructors for (W)ScriptHash (Andrew Poelstra)
b553acb re-export WPubkeyHash and PubkeyHash rather than defining our own (Andrew Poelstra)
5c22659 dynafed: use newtypes for the various merkle roots in dynafed params (Andrew Poelstra)
8153c4a issuance: also back AssetId by [u8; 32] rather than Midstate (Andrew Poelstra)
b985342 issuance: move AssetId boilerplate into macro (Andrew Poelstra)
da8942a issuance: use newtype rather than bare sha256::Midstate for asset entropy (Andrew Poelstra)
5f54fef hash_types: add serde regression tests for all 32-byte hashes (Andrew Poelstra)
90183f4 pset: remove a bunch of other ununused error variants (Andrew Poelstra)
7ec80fe pset: remove unused FromSliceError (Andrew Poelstra)
da967f8 pset: eliminate a use of Hash::from_slice (Andrew Poelstra)
0c006d7 sighash: strongly type leaf_version field in SighashCache (Andrew Poelstra)
dc701a5 taproot: use TapNodeHash for internal hashes in Taptrees (Andrew Poelstra)
dbfbaf8 serde: modernize serde imports (Andrew Poelstra)
Pull request description:
I am going to PR soon to update to bitcoin-hashes 1.0. There are several big changes versus the old version of bitcoin-hashes that we were using:
* Hash wrapper types (like `Txid`, `Blockhash`, etc) no longer have general hashing methods like `hash` that let you hash up arbitrary data; the intention of these types is that they only be constructable from byte slices or by hashing the right kind of data
* We no longer directly support construction from byte slices; instead you must use arrays. stdlib has a `TryFrom<&[u8; N]> for &[u8]` impl which is just a pointer cast, so you can get the old behavior by using this `TryFrom`
* The `sha256::Midstate` type now carries a length with it, so it behaves something like a deconstructed hash engine rather than being a "hash" which is computed from the sha256 compression function; you can no longer effectively wrap a midstate the way you would wrap a sha256 hash, so instead we directly wrap `[u8; 32]`s for the types that did this
* Many changes to make the macros more ergonomic, standard trait impls more consistent and complete, etc
This PR makes a bunch of prepatory changes to make this transition smaller. In particular, it
* eliminate all the bare `sha256::Midstate` uses by introducing newtypes for each midstate (asset entropy, dynafed elided params, etc)
* replace slices with arrays in many places throughout the codebase, eliminating a ton of unreachable panic paths
* **makes `Address::p2wpkh` and `Address::p2shwpkh` panic if you give them uncompressed keys** rather than producing unspendable addresses; later we will clean this up further by type-separating compressed keys, but for now ISTM that a panic is better than silently creating black-hole addresses
* does a whole pile of code cleanups
ACKs for top commit:
stringhandler:
utACK fa3ea85
Tree-SHA512: c051ec3a8578072e612164d39cf07dddbbf50b14a0d9d1ce25f0a57473b9d8d54d897b5f4ecc3ee9687e4f67cb08d4b025a08271a234d7fa5e0060b41fcaa354
0 commit comments