Commit Graph

1293 Commits

Author SHA1 Message Date
Andrew Poelstra 65a5dfcd6b
Merge rust-bitcoin/rust-bitcoin#2585: Improve array macros
6ba7758b30 Improve array macros (Tobin C. Harding)

Pull request description:

  Currently we have two macros used when creating array wrapper types, one is in `internals` and the other in `bitcoin::internal_macros`. It is not immediately obvious what is what and why there are two.

  Improve the macros by:

  - Move the inherent functions to `impl_array_newtype`
  - Use `*_byte_array` for the names instead of `*_bytes`
  - Re-name the other macro to match what it now does

ACKs for top commit:
  apoelstra:
    ACK 6ba7758b30

Tree-SHA512: 36ed0fae0d28f24d29287062eb05bbc1e9e8b565f4ff41fd893503a25404ed8e185a34d75e398a8a660923ffda3b832b6157011598d5a75a5c4aafdffc74af2a
2024-05-28 16:25:59 +00:00
Andrew Poelstra b31ac0fcb7
Merge rust-bitcoin/rust-bitcoin#2768: Deprecate `to_vec` in favour of `to_bytes`
eda61ddfef Deprecate to_vec in favour of to_bytes (Tobin C. Harding)

Pull request description:

  Currently we have to method names for the same thing "copy this object into a vector". The library is easier to use if we are uniform and just use one.

  Elect to use `to_bytes`, for context see discussion in PR #2585.

ACKs for top commit:
  apoelstra:
    ACK eda61ddfef Nice. IMO we should start deprecating stuff for two releases rather than one, so that people have a year to update.

Tree-SHA512: 0aadd1258a07bfa53806f19a3c41af8d3b1132aa42e7a2015a59c58c4309d7a9b50b86d076c181ce5870ba5acd989feec32669352ecf857ae6fd982873482c34
2024-05-28 15:19:35 +00:00
Andrew Poelstra 6e407e44e4
Merge rust-bitcoin/rust-bitcoin#2809: doc: fix "lazy line continuations" in markdown
1282b7f34b examples: drop a couple allocations (Andrew Poelstra)
45e0241267 doc: fix "lazy line continuations" in markdown (Andrew Poelstra)

Pull request description:

  Rust nightly as of 2024-05-27 has a new lint which detects list items which are continued by a non-indented line. Markdown treats these as single list items, which they sometimes are, but sometimes we intended them to be on a separate line.

  Also changes the docs for `UntweakedKeypair::tap_tweak` because the existing ones were overly technical and out-of-date.

  Also fixes a minor "no need to create a vec then dereference it" lint in the examples.

ACKs for top commit:
  storopoli:
    ACK 1282b7f34b
  tcharding:
    ACK 1282b7f34b

Tree-SHA512: 989c83b6bbbfbf8ddd2ade63b5f590f76810f4ec56fab432b580a40e3cc1468a0ea657dcc7ad0d4a31d49eb1390219616fec5a76b5680d5fddc3a06d81db30d7
2024-05-28 13:34:58 +00:00
Andrew Poelstra 1741229526
Merge rust-bitcoin/rust-bitcoin#2808: Add an `AddressData` type
b5ef7db3c0 api: Run just check-api (Tobin C. Harding)
1b40550ce8 Add an AddressData type (Tobin C. Harding)

Pull request description:

  In the 0.32.0 release we removed the `address::Payload` struct because it was deemed an implementation detail. As a byproduct of doing so we made it impossible for users to match on an enum and get the address payload (or data).

  - Add a public `AddressData` enum that holds an address' encoded data.
  - Add a conversion function to `Address` that returns the data enum.

  This patch is additive and is expected to be backported and release as a `0.32` point release.

ACKs for top commit:
  apoelstra:
    ACK b5ef7db3c0 I still feel a little partial to calling the struct "DecodedAddress" and the method "decode"...but this is good, and I do not want to bikeshed

Tree-SHA512: d97836bb2d7fc0f6e9fbba2afb30eeefefc88e7105d4765a146dd444c8397dd4d1ef4fd3e3eb925589294d46bfc8a66d33797a05dbc2131923534364424c135c
2024-05-27 16:29:06 +00:00
Andrew Poelstra 1282b7f34b
examples: drop a couple allocations
Detected by clippy.
2024-05-27 12:54:22 +00:00
Andrew Poelstra 45e0241267
doc: fix "lazy line continuations" in markdown
Rust nightly as of 2024-05-27 has a new lint which detects list items
which are continued by a non-indented line. Markdown treats these as
single list items, which they sometimes are, but sometimes we intended
them to be on a separate line.

Also changes the docs for `UntweakedKeypair::tap_tweak` because the
existing ones were overly technical and out-of-date.
2024-05-27 12:50:26 +00:00
Tobin C. Harding 1b40550ce8
Add an AddressData type
In the 0.32.0 release we removed the `address::Payload` struct because
it was deemed an implementation detail. As a byproduct of doing so we
made it impossible for users to match on an enum and get the address
payload (or data).

- Add a public `AddressData` enum that holds an address' encoded data.
- Add a conversion function to `Address` that returns the data enum.

This patch is additive and is expected to be backported and release as a
`0.32` point release.
2024-05-27 14:46:25 +10:00
Andrew Poelstra 4fde89f77c
Merge rust-bitcoin/rust-bitcoin#2795: Make `Address:p2sh_from_hash` public
3615410d21 api: Run just check-api (Tobin C. Harding)
a3d2d1a184 Make Address:p2sh_from_hash public (Tobin C. Harding)

Pull request description:

  We previously made this function Private and added a comment that doing so was somehow better to remove the footgun of hashing the wrong length script. However in hindsight this was a bad idea and users want the functionality.

  Make the `Address:p2sh_from_hash` public and document it as we do for `Address::p2sh`.

  This is an additive change and is expected to be backported to `v0.32`, as part of the fix to #2784. Please note it introduces the footgun that is described in the function rustdoc. This will be improved as a separate patch and added to the current release.

ACKs for top commit:
  apoelstra:
    ACK 3615410d21

Tree-SHA512: 535bb7894eeef8ecb5afb7bf6e5c483cd42c6a4282d1c116e5bf86cd1364a8327bbec1efb8634a578f07ad2832c1e5daf7fe7e844574b88b1ad355a443627bef
2024-05-25 21:12:12 +00:00
Andrew Poelstra e96961f333
Merge rust-bitcoin/rust-bitcoin#2798: Standardize rustdoc subheadings
11bb1ff6ff Standardize function doc Safety, Returns and Parameters (jamil.lambert)
df83016c98 Standardize function doc Errors (jamil.lambert)
d219ceb68e Standardize function doc Examples (jamil.lambert)
233a9133d8 Standardize function doc Panics (jamil.lambert)

Pull request description:

  The subheadings in the rustdocs have been standardized according to [./CONTRIBUTING.md](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/CONTRIBUTING.md):
  ```rust
  impl FooBar {
      /// Constructs a `FooBar` from a [`Baz`].
      ///
      /// # Errors
      ///
      /// Returns an error if `Baz` is not ...
      ///
      /// # Panics
      ///
      /// If the `Baz`, converted to a `usize`, is out of bounds.
      pub fn from_baz(baz: Baz) -> Result<Self, Error> {
          ...
      }
  }
  ```

ACKs for top commit:
  apoelstra:
    ACK 11bb1ff6ff
  tcharding:
    ACK 11bb1ff6ff

Tree-SHA512: 163af3cd1cfb47cea3e55eddeaeb6843ff7ec89c57354e3247d6bae85e756b183e8045c2555cfcf87e8c23c1388ff9d7592cfb6a951a37a9ec41d27263e5a2e4
2024-05-25 14:55:16 +00:00
Andrew Poelstra 8d5399f881
Merge rust-bitcoin/rust-bitcoin#2765: Flesh out hex unit parsing API
cf3e1eb198 api: Run just check-api (Tobin C. Harding)
98bf213c52 bitcoin: Remove error module (Tobin C. Harding)
a5b93cb159 Flesh out hex unit parsing API (Tobin C. Harding)

Pull request description:

  Add to `units::parse` the complete suit of hex unit parsing functions:

  - remove prefix
  - assert without prefix
  - parse with or without prefix
  - parse with prefix
  - parse without prefix
  - parse prefix unchecked

  Refactor `bitcoin` to use the exact function we need, removing code duplication.

  This is a breaking change to `units`, it does however keep the current re-exports from the public, now empty, `bitcoin::error` module.

ACKs for top commit:
  apoelstra:
    ACK cf3e1eb198

Tree-SHA512: 1778108d4364e290e8956cfea6f23fcdd82c835844d034a00b4cf5cab5552e3efbe853dfbf8a3e0a4bd53a8e3da9d6f7c7408d332d18cd7090aec16fc1f02fe7
2024-05-25 13:32:52 +00:00
Tobin C. Harding a3d2d1a184
Make Address:p2sh_from_hash public
We previously made this function Private and added a comment that doing
so was somehow better to remove the footgun of hashing the wrong length
script. However in hindsight this was a bad idea and users want the
functionality.

Make the `Address:p2sh_from_hash` public and document it as we do for
`Address::p2sh`.
2024-05-25 07:54:11 +10:00
Andrew Poelstra d994aba063
Merge rust-bitcoin/rust-bitcoin#2586: Hard code genesis script bytes instead of hex
726ff25c46 Hard code genesis script bytes instead of hex (Tobin C. Harding)
6e5592db77 Use test_hex_unwrap in bench code (Tobin C. Harding)

Pull request description:

  Currently we have a dependency on `hex_lit` and it is used in exactly one place outside of test code, if we instead use a hardcoded array instead we can move the `hex_lit` dependency to `dev-dependencies`.

  Hard code the genesis block script bytes as an array of hex digits, link to the blockstream explorer for those interested and comment the bytes liberally since it took me a while to work out what they were.

  Move the `hex_lit` dependency and update the lock files.

ACKs for top commit:
  apoelstra:
    ACK 726ff25c46

Tree-SHA512: 96110332fc24dd5b251150b32737fa198113244c3b51b35453c8c1fcc8386c5a2f68dddb30d78cf2f9e1762550099fdb4109dc550f4c144625795ce60b86e574
2024-05-24 20:43:37 +00:00
Andrew Poelstra 543b387d72
Merge rust-bitcoin/rust-bitcoin#2796: Enable getting the witness program from an address
7f29313d36 Update API (Tobin C. Harding)
4f29adf163 Enable getting the witness program from an address (Tobin C. Harding)

Pull request description:

  We have getters for the pubkey hash and script hash but we forgot one for the witness program - add it.

  Done as part of fixing #2784, this is an additive change and is expected to be backported to `v0.32`

ACKs for top commit:
  apoelstra:
    ACK 7f29313d36

Tree-SHA512: 365aba572eaacb789f5424c233be067500ceff18dc27e28fc3be123c49d27333e95bbf4527469a9caf8cc2fe54f8e13a0fc83bc3fc7c3356aea876c9dd2fa5f0
2024-05-24 20:11:17 +00:00
Andrew Poelstra 613f1fb126
Merge rust-bitcoin/rust-bitcoin#2792: Header change from arguments to parameters
9bb75703a1 Header change from arguments to parameters (jamil.lambert)

Pull request description:

  In a few cases a function header documents the parameters of the following function under the heading "Arguments", this has been changed to "Parameters".

  Since the description is at the level of the function definition and not where it is being called parameters seems the more accurate term.

ACKs for top commit:
  apoelstra:
    ACK 9bb75703a1
  tcharding:
    ACK 9bb75703a1

Tree-SHA512: aa24af3fd6e086c09f5e2605fa58289969fc7188f63d7f53c0e325315644f9704d51d4cf526ebfc51b2cf9216155fc3d48cc6bca759dc14bae15e4770de5116e
2024-05-24 13:14:25 +00:00
jamil.lambert 11bb1ff6ff Standardize function doc Safety, Returns and Parameters
Changed the function docs to have the same format of
///
/// # Safety
///
/// description
2024-05-24 09:59:42 +01:00
jamil.lambert df83016c98 Standardize function doc Errors
Changed the function docs to have the same format of
///
/// # Errors
///
/// description
2024-05-24 09:59:42 +01:00
jamil.lambert d219ceb68e Standardize function doc Examples
Changed the function docs to have the same format of
///
/// # Examples
///
/// description
2024-05-24 09:59:42 +01:00
jamil.lambert 233a9133d8 Standardize function doc Panics
Changed the function docs to have the same format of
///
/// # Panics
///
/// description
2024-05-24 09:59:29 +01:00
Tobin C. Harding 98bf213c52
bitcoin: Remove error module
The `error` module is empty except for public re-exports. We are still
in the "break everything and get the API right" stage so this module
adds no value - remove it.
2024-05-24 14:32:47 +10:00
Tobin C. Harding a5b93cb159
Flesh out hex unit parsing API
Add to `units::parse` the complete suit of hex unit parsing functions:

- remove prefix
- assert without prefix
- parse with or without prefix
- parse with prefix
- parse without prefix
- parse prefix unchecked

Refactor `bitcoin` to use the exact function we need, removing code
duplication.

This is a breaking change to `units`, it does however keep the current
re-exports from the public, now empty, `bitcoin::error` module.
2024-05-24 14:32:47 +10:00
Andrew Poelstra 1142d16192
Merge rust-bitcoin/rust-bitcoin#2785: Whitelist cfg attrs and bump nightly version
30a482504b bump nightly-version (Andrew Poelstra)
5ad7c245e3 cargo: whitelist all cfgs used in this repo (Andrew Poelstra)
814786b0a6 crypto: enable and fix accidentally disabled unit test (Andrew Poelstra)

Pull request description:

  https://github.com/rust-lang/rust/issues/124800 has been fixed and we can update our nightly version by whitelisting all cfgs that are used.

  There was one place where we had an old `cfg(feature = "no-std")` despite having removed the feature. By removing that cfg check we re-enabled a previously disabled test.

ACKs for top commit:
  tcharding:
    ACK 30a482504b

Tree-SHA512: d25bed819091db74b9d47cb2c23caa3ceb0d7be323b37831326e2ec1608cb1577d41aad2e1cdf59d66df69397537bc3e17a3c2872935d5a4f46f4dc55b5e613c
2024-05-23 16:52:22 +00:00
Tobin C. Harding 4f29adf163
Enable getting the witness program from an address
We have getters for the pubkey hash and script hash but we forgot one
for the witness program - add it.
2024-05-23 13:02:12 +10:00
Tobin C. Harding 726ff25c46
Hard code genesis script bytes instead of hex
Currently we have a dependency on `hex_lit` and it is used in exactly
one place outside of test code, if we instead use a hardcoded array
instead we can move the `hex_lit` dependency to `dev-dependencies`.

Hard code the genesis block script bytes as an array of hex digits, link
to the blockstream explorer for those interested and comment the bytes
liberally since it took me a while to work out what they were.

Move the `hex_lit` dependency and update the lock files.
2024-05-23 09:19:24 +10:00
Tobin C. Harding 6e5592db77
Use test_hex_unwrap in bench code
We would like to move the dependency on `hex_lit` to be a
dev-dependency but currently are using it in bench code. The bench
code is enabled if any downstream crate tries to build with
`--cfg=bench` and during such a build our dev-dependencies are not
available.

We also have the `test_hex_unwrap` macro in the `hex` crate and since
the bench code is more or less test code (and the macro call is not
being benchmarked) we can use that macro instead.
2024-05-23 09:19:24 +10:00
Andrew Poelstra d0c1eb138c
Merge rust-bitcoin/rust-bitcoin#2754: Document CompactTarget order/equality
c8caee2b5e Document CompactTarget order/equality (Tobin C. Harding)

Pull request description:

  Add documentation to the `CompactTarget` type explaining the nuance surrounding order/equality.

  Close: #2110

ACKs for top commit:
  apoelstra:
    ACK c8caee2b5e

Tree-SHA512: c724b31ee620ff08d3c8b547250bc7067f875ef6cf4ce9efa082d5a9cfbd8b92620f86034e58caf573c479ce7aaa89bb7e9fa93dc356524663d3ecf583df3507
2024-05-22 19:49:14 +00:00
Andrew Poelstra 5ad7c245e3
cargo: whitelist all cfgs used in this repo 2024-05-22 13:32:24 +00:00
jamil.lambert 9bb75703a1 Header change from arguments to parameters
In a few cases a function header documents the parameters of the following function under the heading"Arguments", this has been changed to "Parameters"
2024-05-22 13:12:44 +01:00
Tobin C. Harding c8caee2b5e
Document CompactTarget order/equality
Add documentation to the `CompactTarget` type explaining the nuance
surrounding order/equality.

Close: #2110
2024-05-22 08:53:25 +10:00
Andrew Poelstra 814786b0a6
crypto: enable and fix accidentally disabled unit test 2024-05-21 17:17:48 +00:00
Tobin C. Harding f6129317bd
Run the formatter
Run `just fmt`, no other changes.
2024-05-20 08:58:48 +10:00
Tobin C. Harding fa4d3d4417
Add whitespace
The formatter lines up comments if they are on consecutive lines even
if the second is supposed to be at the start of the collum and the
first is after code. Putting a line of whitespace between the two
lines stops this from happening.

Add whitespace to stop the formatter doing silly changes.

Whitespace only.
2024-05-20 08:56:58 +10:00
Tobin C. Harding c934d03fcf
p2p: Cleanup test imports
Clean up the test imports in the `p2p` module:

- Use `use super::*` as is conventional.
- Use `sha256d::Hash` as is conventional.

Refactor, no logic changes.
2024-05-17 10:57:54 +10:00
Andrew Poelstra 47527abd53
Merge rust-bitcoin/rust-bitcoin#2776: Fix rustdoc header format
6d0d0fe51f Fix rustdoc header format (jamil.lambert)

Pull request description:

  By convention rustdoc headers should not include a colon.

  Removed colon from rustdoc headers.

ACKs for top commit:
  apoelstra:
    ACK 6d0d0fe51f

Tree-SHA512: 36d5822e80cc86139ce07a1c86681998e1d27549421b9b50589fe4a9a5c860ed47f145d5af9501957f199d0f77df069c2b295d43ed4a15e9b6d98c0edc12abd0
2024-05-16 18:10:39 +00:00
Andrew Poelstra 2fe579bd3f
Merge rust-bitcoin/rust-bitcoin#2772: Removed //! spare line at end of headers
802af8e417 Removed //! spare line at end of headers (jamil.lambert)

Pull request description:

  Some of the headers had a //! at the end but most didn't.  They have all been removed in bitcoin/src/ to make the files consistent

ACKs for top commit:
  apoelstra:
    ACK 802af8e417

Tree-SHA512: a1eb0dda76af68cb96352f6b31231fa5391d49e11df924065e76871f82231ec0d5751190663f142240e5d757975937387243d1fdac3684d9bdbd7e2362dbd0a7
2024-05-16 13:48:15 +00:00
jamil.lambert 6d0d0fe51f Fix rustdoc header format
By convention rustdoc headers should not include a colon.

Removed colon from rustdoc headers.
2024-05-16 10:35:30 +01:00
jamil.lambert 802af8e417 Removed //! spare line at end of headers 2024-05-16 09:59:55 +01:00
Tobin C. Harding f3c80ea820
Use concrete type for all_zeros call
Currently we use the `Hash` trait in a bunch of places to call
`all_zeros`. We are attempting to improve the `hashes` API and this
usage is both unnecessary and also hindering that effort.

Use the concrete type (e.g. `BlockHash`) instead of calling through the
trait method.

Refactor only, no logic changes.
2024-05-16 09:01:37 +10:00
Andrew Poelstra 44a6402875
Merge rust-bitcoin/rust-bitcoin#2740: Add difficulty adjustment calculation
47dc4a3180 feat(pow): add difficulty adjustment calculation (Rob N)

Pull request description:

  Hi, I hit a roadblock with the current `pow` API. As far as I can tell, the only workaround to calculate the next work required similar to `bitcoin/src/pow.cpp` is to use a general big integer library, convert the `Target` to bytes, do the math, and convert back to `Target` from bytes. I have also been working with [Floresta](780ea8d0b0) and their [solution](780ea8d0b0/crates/floresta-chain/src/pruned_utreexo/consensus.rs (L187)) was to fork off and exposed the `U256` struct publicly on their branch. I think these home brewed difficulty adjustment solutions will continually pop up, so I created a `from_next_work_required` method to return a `Target`. My work veers significantly from #2180, as I only provided a single method to do so, without further guidance on when exactly this retarget occurs.

  I am happy to add tests once I get further direction from maintainers if this as a likelihood of being accepted or not. Thanks.

ACKs for top commit:
  tcharding:
    ACK 47dc4a3180
  apoelstra:
    ACK 47dc4a3180 used range-diff

Tree-SHA512: 6d627ce698361afed61c8f2a12a1a96371a7a93118e08a91dae250de4f23d65c615d2654d37d2699c88b7c22f6e4bc2a1195f963c15512d7c0d041498f02dc41
2024-05-15 13:42:25 +00:00
Rob N 47dc4a3180
feat(pow): add difficulty adjustment calculation 2024-05-14 16:49:53 -10:00
Andrew Poelstra 845ae37dbe
Merge rust-bitcoin/rust-bitcoin#2729: bitcoin: Set version number
46e0ce59a3 bitcoin: Set version number (Tobin C. Harding)

Pull request description:

  During the recent release cycle we left `bitcoin` on the last rc version.

  Set the version number to `v0.33.0-unreleased` to make it obvious what it is.

  Close: #2724

ACKs for top commit:
  apoelstra:
    ACK 46e0ce59a3
  sanket1729:
    ACK 46e0ce59a3

Tree-SHA512: 8a1fa062cf0240c5a7e1c05f0378097464423c29827f14068d01ac562d1be571bec2d267a5a12d0828c5a2809ef743f03ef29ccea9a31a5c9e3eefce66b3d30d
2024-05-15 01:50:24 +00:00
Tobin C. Harding eda61ddfef
Deprecate to_vec in favour of to_bytes
Currently we have to method names for the same thing "copy this object
into a vector". The library is easier to use if we are uniform and just
use one.

Elect to use `to_bytes`, for context see discussion in PR #2585.
2024-05-14 10:47:02 +10:00
Tobin C. Harding 6ba7758b30
Improve array macros
Currently we have two macros used when creating array wrapper types,
one is in `internals` and the other in `bitcoin::internal_macros`. It
is not immediately obvious what is what and why there are two.

Improve the macros by:

- Move the inherent functions to `impl_array_newtype`
- Use `*_byte_array` for the names instead of `*_bytes` for functions
  that return arrays
- Add `as_bytes` to return a slice
- Add `to_bytes` to return a vector
- Re-name the other macro to match what it now does
2024-05-14 10:42:40 +10:00
Andrew Poelstra 2ec5a4b03a
Merge rust-bitcoin/rust-bitcoin#2760: bip32: derive_xpriv should not return a Result
d353be4546 bip32: derive_xpriv should not return a Result (Jose Storopoli)

Pull request description:

  We discussed in #2752 that `derive_priv` never fails.

  This PR addresses that issue.

ACKs for top commit:
  apoelstra:
    ACK d353be4546
  tcharding:
    ACK d353be4546
  sanket1729:
    ACK d353be4546

Tree-SHA512: 3a3d09027c6079581636b51a506fac2b325e592d182167c0a3d8676b41fb2bef59a85a404ad12b2e14d73e58fd4b6d8f5923a3dc76a4b9724033097fc08b36ac
2024-05-13 22:35:49 +00:00
Jose Storopoli d353be4546
bip32: derive_xpriv should not return a Result 2024-05-13 20:43:49 +00:00
Andrew Poelstra 4e45950483
Merge rust-bitcoin/rust-bitcoin#2761: psbt: documentation examples for PsbtSighashType
4f0eafa2b1 psbt: documentation examples for PsbtSighashType (Jose Storopoli)

Pull request description:

  Partially addresses #2751 by adding examples (testable code) for `PsbtSighashType`

ACKs for top commit:
  tcharding:
    ACK 4f0eafa2b1
  apoelstra:
    ACK 4f0eafa2b1

Tree-SHA512: 4ba728d2a73f25440bda2c0953ca3bab9e6c97604c3ecd9a564a56f3a685131c6f53366a9c5fad9e237b87f8541fea20e281e3181d864a99651a1a071dcd473a
2024-05-13 13:52:51 +00:00
Jose Storopoli 4f0eafa2b1
psbt: documentation examples for PsbtSighashType 2024-05-12 08:32:03 +00:00
Jose Storopoli 021bea89bb
ci: shellcheck checks 2024-05-11 18:08:53 +00:00
Andrew Poelstra 594eb18728
Merge rust-bitcoin/rust-bitcoin#2707: Default to forward for tagged hashes
7685461e62 Document the sha256t_hash_newtype direction (Tobin C. Harding)
30e91cc766 Default to forward for tagged hashes (Tobin C. Harding)
5ecc69cd28 Add forward/backward unit test (Tobin C. Harding)
9aee65d1ba Refactor tagged hash tests (Tobin C. Harding)
216422dffc Remove schemars impl for test type (Tobin C. Harding)

Pull request description:

  First three patches are preparation, improvements to the units tests in `sha256t`.

  From the final patch:

      Displaying backward is an anomaly of Bitcoin Core's early days and the
      double SHA256 hash type. We should not let this unfortunate beast leak
      out into other places.

      Default to displaying forward when creating a new tagged hash and remove
      all the explicit attributes from `bitcoin` that just clutter the code.

  This is an API break and may quietly break some users downstream - eventually we should stop doing that sort of thing.

ACKs for top commit:
  apoelstra:
    ACK 7685461e62

Tree-SHA512: cb8a41b207aa68ecf63cb7af7f39f7d7c8a3a27f38595867949b288a81a20bff0c17aa4c17bb099e2ecf85194d83bad23c9c9792f511b6c4cd625ff27c1affaa
2024-05-07 14:16:16 +00:00
Tobin C. Harding d094350230
hashes: Modify trait bounds
Currently we require indexing trait bounds as well as `Borrow` on the
`Hash` trait. We also already implement `AsRef`.

It was observed that `Borrow<[u8]>` does not best describe what we want
from the `Hash` trait implementor but rather `AsRef<[u8]>` does.

Remove all the inexing trait bounds. Remove the `borrow::Borrow<[u8]>`
trait bound. Add a `convert::AsRef<[u8]>` trait bound.

This leaves the `Borrow<[u8]>` implementation for hashes created with
`hash_newtype`, I'm not sure if this should be removed or not.
2024-05-06 13:48:26 +10:00
Tobin C. Harding 46e0ce59a3
bitcoin: Set version number
During the recent release cycle we left `bitcoin` on the last rc
version.

Set the version number to `v0.33.0-unreleased` to make it obvious what
it is.

Close: #2724
2024-05-03 07:34:08 +10:00