|
| 1 | +# primitives 1.0.0 |
| 2 | + |
| 3 | +Design considerations and TODOs for the `bitcoin-primitives 1.0.0` release. |
| 4 | + |
| 5 | +## TODOs |
| 6 | + |
| 7 | +### consensus encoding |
| 8 | + |
| 9 | +GitHub discussion: https://github.com/rust-bitcoin/rust-bitcoin/discussions/4856 |
| 10 | + |
| 11 | +Pull encoding done in: https://github.com/rust-bitcoin/rust-bitcoin/pull/4912 |
| 12 | + |
| 13 | +<!-- TODO: Add a consenus-encoding.md file? --> |
| 14 | + |
| 15 | +### Remove `hashes` from the public API. |
| 16 | + |
| 17 | +Required due to [C-STABLE](https://rust-lang.github.io/api-guidelines/necessities.html#c-stable). |
| 18 | + |
| 19 | +Currently `hashes` shows up in the public API in all of our hash wrapper types. This can be seen by |
| 20 | +grepping the API text files introduced in |
| 21 | +[#4792](https://github.com/rust-bitcoin/rust-bitcoin/issues/4792) |
| 22 | + |
| 23 | +The wrapper types are: |
| 24 | + |
| 25 | +```bash |
| 26 | +$ grep hashes api/primitives/all-features.txt | grep impl | awk '{print $NF}' |
| 27 | + |
| 28 | +bitcoin_primitives::block::BlockHash |
| 29 | +bitcoin_primitives::block::WitnessCommitment |
| 30 | +bitcoin_primitives::merkle_tree::TxMerkleNode |
| 31 | +bitcoin_primitives::merkle_tree::WitnessMerkleNode |
| 32 | +bitcoin_primitives::script::ScriptHash |
| 33 | +bitcoin_primitives::script::WScriptHash |
| 34 | +bitcoin_primitives::transaction::Ntxid |
| 35 | +bitcoin_primitives::transaction::Txid |
| 36 | +bitcoin_primitives::transaction::Wtxid |
| 37 | +``` |
| 38 | + |
| 39 | +Using `Txid` as an example, `hashes` appears in the following places: |
| 40 | + |
| 41 | +```bash |
| 42 | +$ grep hashes api/primitives/all-features.txt | grep Txid |
| 43 | + |
| 44 | +impl bitcoin_hashes::Hash for bitcoin_primitives::transaction::Txid |
| 45 | +pub const fn bitcoin_primitives::transaction::Txid::as_byte_array(&self) -> &<bitcoin_hashes::sha256d::Hash as bitcoin_hashes::Hash>::Bytes |
| 46 | +pub const fn bitcoin_primitives::transaction::Txid::from_byte_array(bytes: <bitcoin_hashes::sha256d::Hash as bitcoin_hashes::Hash>::Bytes) -> Self |
| 47 | +pub const fn bitcoin_primitives::transaction::Txid::to_byte_array(self) -> <bitcoin_hashes::sha256d::Hash as bitcoin_hashes::Hash>::Bytes |
| 48 | +pub type bitcoin_primitives::transaction::Txid::Bytes = <bitcoin_hashes::sha256d::Hash as bitcoin_hashes::Hash>::Bytes |
| 49 | +``` |
| 50 | + |
| 51 | +All these come from the `hash_newtype` macro. |
| 52 | + |
| 53 | +Usage of `hash_newtype` in `bitcoin` (i.e. other usage outside of `primitives`): |
| 54 | + |
| 55 | +- `bip158::{FilterHash, FilterHeader}` |
| 56 | +- `bip32::XKeyIdentifier` |
| 57 | +- `crypto::key::{PubkeyHash, WPubkeyHash}` |
| 58 | +- `crypto::sighash::{LegacySighash, SegwitV0Sighash}` |
| 59 | +- `taproot::{TapLeafHash, TapNodeHash, TapTweakHash}` |
0 commit comments