Commit Graph

4584 Commits

Author SHA1 Message Date
Martin Habovstiak c72069e921 Bump MSRV to 1.63
The version 1.63 satisfies our requirements for MSRV and provides
significant benefits so this commit bumps it. This commit also starts
using some advantages of the new MSRV, namely namespaced features, weak
dependencies and the ability to use trait bounds in `const` context.

This however does not yet migrade the `rand-std` feature because that
requires a release of `secp256k1` with the same kind of change - bumping
MSRV to 1.63 and removing `rand-std` in favor of weak dependency.
2024-07-27 07:24:32 +02:00
merge-script 1276a99061
Merge rust-bitcoin/rust-bitcoin#3092: Direct link to ./CONTRIBUTING.md
82a0656b57 Direct link to ./CONTRIBUTING.md (Joao Leal)

Pull request description:

  For convenience.

ACKs for top commit:
  tcharding:
    ACK 82a0656b57
  Kixunil:
    ACK 82a0656b57

Tree-SHA512: ef2e0941dfb5d9c341be2f8f80286e8d8d654728262a6324a8bfdef81cfa62cc1b3f864b8926d90205b9d1deac4a7805cf70fe4a9ebd68dc58200586cec8a204
2024-07-26 22:13:44 +00:00
Jose Storopoli f76f68217b
ci: pin cargo-semver-checks version and cron job 2024-07-26 09:06:45 -03:00
Jose Storopoli 8a91015769
ci: harden zip command with -n
from the man unzip:

 -n stands for never overwrite existing files.  If a file already exists,
 skip the extraction of that file without prompting.
2024-07-26 09:05:35 -03:00
Jose Storopoli 4edd504cb6
ci: pin stable in semver-checks and updates weekly 2024-07-26 09:05:30 -03:00
merge-script d5149c1f54
Merge rust-bitcoin/rust-bitcoin#3065: Move `validation` module to `consensus_validation`
29b213daca Move validation module to consensus_validation (Tobin C. Harding)

Pull request description:

  The `consensus` module is currently doing two things, validation and encoding. These two things are orthogonal.

  Move the `consensus::validation` module to `consensus_validation`. Remove the function re-exports from `consensus`.

  This was originally discussed here: https://github.com/rust-bitcoin/rust-bitcoin/issues/2779

ACKs for top commit:
  Kixunil:
    ACK 29b213daca
  apoelstra:
    ACK 29b213daca

Tree-SHA512: 3bd0e43c220b0d89a47e9df0e0c92b776ccc65f5f60d57f413db834acc8e86269379bc9fdd688f8c4f0138db22f8eb8983770afa2d7d53d51acf063f2302121c
2024-07-26 11:26:36 +00:00
Jose Storopoli 1948995443
ci: semver-check for non-additive cargo features
Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
2024-07-25 12:19:54 -03:00
Jose Storopoli b5180732e6
io: add not_unwind_safe as PhantomData 2024-07-25 12:19:48 -03:00
merge-script d218848b36
Merge rust-bitcoin/rust-bitcoin#3037: `primitives`: Re-export `units` types
991c73cdf9 primitives: Re-export everything from units (Tobin C. Harding)
7a44908aee primitives: Use wildard re-export in locktimes (Tobin C. Harding)
d1c876eda5 Remove rustfmt attribute (Tobin C. Harding)
e3d9376a9b units: Remove serde re-export (Tobin C. Harding)

Pull request description:

  Re-export `units` types by doing:

  - Patch 1: Remove the public re-export of `serde` so that it does not shadow the private one in `primitives`
  - Patch2: Fix formatting (remove attribute and format)
  - Patch 3 and 4: Use wildcard re-exports

ACKs for top commit:
  Kixunil:
    ACK 991c73cdf9
  apoelstra:
    ACK 991c73cdf9

Tree-SHA512: dd71aa97fe5718a1229bfe26b776a72ebdd745a15a0e8ce8dae421c3a4c49f0f1e27d676056b24c35318cc3643a2ce712b4a69cc09f42b7c43259680bea931f3
2024-07-25 14:16:54 +00:00
Tobin C. Harding 6e6a0578de
Merge rust-bitcoin/rust-bitcoin#3101: Automated daily update to rustc (to nightly-2024-07-24)
33d0a95b8c Automated update to Github CI to rustc nightly-2024-07-24 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 33d0a95b8c

Tree-SHA512: a33ed623396222f73f145187297a7f6f44532790328d4d6d6821067e6d5fa3a21d7d285e420aec5101af9e5b54c778f12812cfff418bc1526d63000f007e3c26
2024-07-24 22:39:31 -05:00
Update Nightly Rustc Bot 33d0a95b8c Automated update to Github CI to rustc nightly-2024-07-24 2024-07-25 01:33:20 +00:00
Ryan Breen a7fa237d32 githooks: Added post-merge githook to check if hooks changed 2024-07-24 19:59:39 -04:00
Tobin C. Harding feef34fdea
Make ScriptBuf::p2wpkh_script_code stand alone
We would like to move the `Script` type to `primitives` without moving
any key stuff, including pubkey hashes. We may later, before releasing
`primitives`, move the `WPubkeyHash` at which time this patch can be
reverted or re-implemented on `ScriptBuf`.

The `ScriptBuf::p2wpkh_script_code` function does not take `self` as a
parameter but it does return `Self` - this can trivially be made into a
standalone function.

Make `ScriptBuf::p2wpkh_script_code` a standalone function.
2024-07-23 11:24:31 -05:00
merge-script 1b83763cdc
Merge rust-bitcoin/rust-bitcoin#3083: Fix rustdocs in `blockdata`
3b15ef6d27 Fix rustdocs in `blockdata` (Jamil Lambert, PhD)

Pull request description:

  Following up on the [comment](https://github.com/rust-bitcoin/rust-bitcoin/pull/2646#discussion_r1548848611) in #2646 the rustdocs formatting was fixed in `blockdata`.

ACKs for top commit:
  Kixunil:
    ACK 3b15ef6d27
  tcharding:
    ACK 3b15ef6d27

Tree-SHA512: 509aa2b8ae559f5a7f8230c016c0866f468cc147773238e226b9a975784d7a424c41a5d966ddcf9b3f8f8d4fe197a4f272b5777c61f3cc53051803abb520b95e
2024-07-23 13:29:27 +00:00
Tobin C. Harding 991c73cdf9
primitives: Re-export everything from units
We recently decided to make everything in `units` available at the same
path as in `primitives` and not re-export the actual `units` crate.

Re-export everything from the `units` crate root at the `primitives`
crate root using a wildcard.
2024-07-23 02:04:11 -05:00
Tobin C. Harding 7a44908aee
primitives: Use wildard re-export in locktimes
We recently decided to use wildcard re-exports when re-exporting things
from an identically named module in a sub crate, ie. to mirror the
directory structure structure ala core/std.

In the `primitives::locktime` modules re-export everything from the
`units::locktime` modules using a wildcard.
2024-07-23 01:50:44 -05:00
Tobin C. Harding d1c876eda5
Remove rustfmt attribute
There are no other use statements so we do not need to keep the public
ones separate with a `rustfmt` attribute.

Remove the attribute and run the formatter.
2024-07-23 01:48:20 -05:00
Tobin C. Harding e3d9376a9b
units: Remove serde re-export
We re-export to help users keep their dependencies in sync but `serde`
is at `v1.0` so this is not really a problem.

Remove the public re-export of `serde` (and with current MSRV we don't
need the `extern crate` at all).
2024-07-23 01:41:41 -05:00
merge-script e7af76f1cd
Merge rust-bitcoin/rust-bitcoin#2936: Bump honggfuzz version
43360bdd74 Bump honggfuzz version (yancy)

Pull request description:

  Bump hongfuzz version

ACKs for top commit:
  apoelstra:
    ACK 43360bdd74
  tcharding:
    ACK 43360bdd74

Tree-SHA512: fe0e9e5a54fa2d4205a3d9974c19b86e57bfd5e525cd7f379c3c1b7ed15d37b03e6808a7cbf5c15b35bf69df820bd302fb81b5a8525fd3a09102aef13f3abf0d
2024-07-22 21:57:14 +00:00
Joao Leal 82a0656b57
Direct link to ./CONTRIBUTING.md 2024-07-22 18:16:25 -03:00
Tobin C. Harding c82c052407
Merge rust-bitcoin/rust-bitcoin#3089: Automated daily update to rustc (to nightly-2024-07-21)
dbb5917128 Automated update to Github CI to rustc nightly-2024-07-21 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK dbb5917128

Tree-SHA512: 6f9a7939ff2eea6d07338cb75e393e319b2d38009dbad35e408bd23534e6240ef8c95a268b2316f7b81045eba7031e4269918a3841fe3353da966605ea752407
2024-07-22 14:26:55 -05:00
merge-script 5d20f2ec4c
Merge rust-bitcoin/rust-bitcoin#3085: Automated nightly rustfmt (2024-07-21)
61d46fffa8 2024-07-21 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 61d46fffa8
  apoelstra:
    ACK 61d46fffa8

Tree-SHA512: 405120e45a94687504796c0cfcfa613eb4b29037a5a10d263dccc22f501a6e8f91ddb832964fc8eac804c3007b73bddbbd41c14356647d14c15a81b5da0c0829
2024-07-22 19:20:03 +00:00
Update Nightly Rustc Bot dbb5917128 Automated update to Github CI to rustc nightly-2024-07-21 2024-07-22 01:36:12 +00:00
Fmt Bot 61d46fffa8 2024-07-21 automated rustfmt nightly 2024-07-21 01:11:38 +00:00
merge-script 84ed27b194
Merge rust-bitcoin/rust-bitcoin#3056: CONTRIBUTING: error/expect messages
0beefda7ea CONTRIBUTING: error/expect messages (Jose Storopoli)

Pull request description:

  - adds an item that all error messages
    should be lower case, except for proper nouns and variable names.
  - adds a section on expect messages,
    following discussion in #3019 and #3053.

  Closes #3053.

ACKs for top commit:
  tcharding:
    ACK 0beefda7ea
  Kixunil:
    ACK 0beefda7ea
  apoelstra:
    ACK 0beefda7ea

Tree-SHA512: b924245e5d18d4f627d4998073422003def789c87502bca121d5db443f5bbe387bfe951664458c9495a6ea0995b6ccf6e28d1784e19dfb876d7eddf3c6209727
2024-07-19 17:07:01 +00:00
merge-script e1478b1802
Merge rust-bitcoin/rust-bitcoin#3069: Remove re-export of `ParseIntError`
ab581a90f8 Remove re-export of ParseIntError (Tobin C. Harding)

Pull request description:

  In d242125 I claimed that `ParseIntError` was somehow special, I no longer thing this is the case. As we pin down the re-export policy (for errors and other types) it is hard if we have one non-typical re-export.

  We have https://github.com/rust-bitcoin/rust-bitcoin/issues/3068 to discuss the policy, for now just remove the unusual re-export.

ACKs for top commit:
  Kixunil:
    ACK ab581a90f8
  shinghim:
    ACK ab581a90f8
  apoelstra:
    ACK ab581a90f8

Tree-SHA512: 5ac4123aeb27c8cee78e5760f21e70be8035d526ba7e14e72759cba27f98b51cc2cba9b2bf0eeb99e0f6b7210ec4a750986bb6c5dc0725ed892730fdec8a7e06
2024-07-19 15:36:21 +00:00
merge-script ff5d437d42
Merge rust-bitcoin/rust-bitcoin#3067: Move `params` to the `network` module
54c30556a2 Move params to network module (Tobin C. Harding)
045a661ebe Create network directory (Tobin C. Harding)

Pull request description:

  Discussed in #2779. Patch one moves `network.rs` to `network/mod.rs`, and patch 2 moves the `params` module over there.

ACKs for top commit:
  apoelstra:
    ACK 54c30556a2 Yeah, this seems like a good place for it
  Kixunil:
    ACK 54c30556a2

Tree-SHA512: 134813419db21323d303d465b12fcbf37fd61dc1baf3305e156d324eafd822379e63dede02877ee99dce41540193a29e6e13acd13f9121f3e2fe11096524aa5e
2024-07-19 14:10:26 +00:00
Tobin C. Harding 29b213daca
Move validation module to consensus_validation
The `consensus` module is currently doing two things, validation and
encoding. These two things are orthogonal.

Move the `consensus::validation` module to `consensus_validation`.

Remove the function re-exports from `consensus`.
2024-07-19 14:28:31 +10:00
Tobin C. Harding 1c3f39e99e
Merge rust-bitcoin/rust-bitcoin#3080: Automated daily update to rustc (to nightly-2024-07-17)
04bcb7950d Automated update to Github CI to rustc nightly-2024-07-17 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 04bcb7950d

Tree-SHA512: 2b2a02fd5eb5dfcc1e8b1551ef66180d76019655262a5eebeb6e849885db5e37c495cd9d1108ce550b9401c446a5abf2ca30508eb3d1139a807188b668d232ef
2024-07-19 08:06:42 +10:00
merge-script 128684e0da
Merge rust-bitcoin/rust-bitcoin#3058: Improve `define_extension_trait`
386ad93253 Manually format function parameters (Tobin C. Harding)
871f4398b9 Add optional comma to function parameter list (Tobin C. Harding)

Pull request description:

  During #2955 I was lazy and did not think through why the macro didn't handle function parameters on individual lines, I just manually re-formatted all function calls onto a single LOC. This was a bit slack of me.

  - Patch 1: Fix the macro.
  - Patch 2: Revert the manual formatting.

ACKs for top commit:
  jamillambert:
    ACK 386ad93253
  Kixunil:
    ACK 386ad93253
  apoelstra:
    ACK 386ad93253

Tree-SHA512: 577154668a4cd0bad225a5b306193a5cd3d38d275dd5df22b4a29737e0d2c910c695da33c0ed77265f6c5d876c162316e444f8eca80f9c30788d110d989493e3
2024-07-18 21:48:19 +00:00
merge-script 8804fa63b4
Merge rust-bitcoin/rust-bitcoin#3064: Remove public error re-export
beea3c1e5d Remove public error re-export (Tobin C. Harding)

Pull request description:

  We do not have a policy to re-export things from other modules just because they are in the public API - I don't see any other reason to re-export this error, users should go to the `validation` module directly to get the error type.

  Raising this trivial change as a separate PR so that we can really pin down our re-export policy. Please review the policy implications as well as the code change.

  Note please that this change was introduced in 7d695f6b4 by me, and buried in a PR that did not mention the change. This was wrong, as in the code change was wrong and also the patching method was wrong.

ACKs for top commit:
  Kixunil:
    ACK beea3c1e5d

Tree-SHA512: 5fc072f3fb8a727f30751211c6bc85dc268d413ee62937c714bdf9f47405dfdbc93cfff3df76c201493c39f49d5d315907fc9e7e4fa0d927652c01038815fdc5
2024-07-18 15:48:47 +00:00
merge-script a28f11c9fb
Merge rust-bitcoin/rust-bitcoin#3062: Add more unit test coverage for relative LockTime
a76c13f675 Add more unit test coverage for relative LockTime (Shing Him Ng)

Pull request description:

  Adding some test cases for `from_seconds_floor` and one more for `from_seconds_ceil`

ACKs for top commit:
  tcharding:
    ACK a76c13f675
  Kixunil:
    ACK a76c13f675

Tree-SHA512: 5d773a30fa56842af21109d232ec3eae7fde7ce38aca93dadccc7bfbf14d5207ea329ef737f847e45ba755fd22e1862c3e78e7e64a8a0babebcb0e27a2bb7a90
2024-07-18 14:21:46 +00:00
Jamil Lambert, PhD 3b15ef6d27 Fix rustdocs in `blockdata`
Following up on the comment in #2646 the rustdocs formatting was fixed.
2024-07-18 11:04:35 +01:00
Update Nightly Rustc Bot 04bcb7950d Automated update to Github CI to rustc nightly-2024-07-17 2024-07-18 01:25:40 +00:00
Tobin C. Harding 98fe6179db
Use "unfinalized" in header of Midstate
The midstate has not been finalized [0], so use the term in the struct
header.

FTR I don't know _exactly_ what "finalized" means in the context of
sha256 hashing (or hashing in general). This change came from a review
suggestion and we have other mentions of "finalized" in the code.
2024-07-18 06:16:46 +10:00
Tobin C. Harding 86de586898
Use const to construct Midstate
As a bit more of an example of how to use the `sha256::Midstate` use a
`static` in one of the unit tests.
2024-07-18 06:16:46 +10:00
Tobin C. Harding dcb18bfa7a
Add length to sha256::Midstate
In a `HashEngine` the `length` field represents number of bytes
input into the hash engine.

Note also:

> the midstate bytes are only updated when the compression function is
run, which only happens every 64 bytes.

Currently our midstate API allows extracting the midstate after any
amount of input bytes, this is probably not what users want.

Note also that most users should not be using the midstate API anyways.

With all this in mind, add a private `length` field to the `Midstate`
struct and enforce an invariant that it is modulo 64.

Add a single const `Midstate` constructor that panics if the invariant
is violated. The `Midstate` is niche enough that panic is acceptable.

Remove the `from_slice`, `from_byte_array`, and `to_byte_array`
functions because they no longer make sense. Keep `AsRef<[u8]>` for
cheap access to the midstate's inner byte slice.

Note change to `Debug`: `bytes` field now does not include the `0x`
prefix because `as_hex` because of the use of `debug_struct`.

Enjoy nice warm fuzzy feeling from hacking on crypto code.
2024-07-18 06:16:45 +10:00
Tobin C. Harding db0502d3cd
Use third person in rustdoc
As is convention in this repo use the third person when describing the
`sha256::HashEngine::from_midstate` function.
2024-07-18 06:13:26 +10:00
Tobin C. Harding 34dd95f909
Debug Midstate forwards
Done in preparation for adding a `length` field to `Midstate` and also
in preparation for removing the `Display` implementation (will be
justified in the patch that does it).

Currently in the `Debug` impl of `Midstate` we are calling through to
`Display` using the alternate form of printing, we can use `as_hex` to
achieve almost the same thing. Note that in `LowerHex` we use the
`fmt_hex_exact` macro that allows us to reverse the iterator however
when we later attempt to use `f.debug_struct` we cannot use the macro.

Elect to change the current behaviour to `Debug` forwards, shown by the
change to the regression test.
2024-07-18 06:13:24 +10:00
Tobin C. Harding 1d0e70b1da
Add regression test for Midstate debug output
In preparation for patching the `Debug` implementation of `Midstate` and
a regression test.
2024-07-18 06:12:53 +10:00
Jose Storopoli 0beefda7ea
CONTRIBUTING: error/expect messages
- adds an item that all error messages
  should be lower case, except for proper nouns and variable names.
- adds a section on expect messages,
  following discussion in #3019 and #3053.
2024-07-17 16:07:05 -03:00
Tobin C. Harding ca823945fc
Manually implement AsRef (remove Borrow)
Currently we are using a macro to implement `AsRef` and `Borrow` for
`sha256::Midstate`.

In preparation for adding a length field to the `Midstate` remove the
implementation of `Borrow` but keep `AsRef`.

API breaking change.
2024-07-17 08:47:38 +10:00
Tobin C. Harding 7dc68b62e9
Remove serde from sha256::Midstate
The `sha256::Midstate` is a niche use case type, there is no real reason
we need to support serialization/deserialization. If people really want
this they can just get the byte array and serialize it themselves.

API breaking change.
2024-07-17 08:47:38 +10:00
Tobin C. Harding 07e8e5d3a6
Stop using macro for Midstate
In preparation for changing the `sha256::Midstate` internals stop using
the `arr_newtype_fmt_impl` macro and implement the `fmt` traits
manually.

In doing so, remove the `DISPLAY_BACKWARDS` const but keep the current
behaviour of displaying the midstate backwards.
2024-07-17 08:47:38 +10:00
Tobin C. Harding 37b54dd54c
Move from_midstate function
Move the `sha256::HashEngine::from_midstate` function to be in the same
impl block as `midstate`.

Refactor only, no logic change.
2024-07-17 08:47:38 +10:00
Tobin C. Harding 9efe4cea9d
Move impl block under struct
Put the impl block for `Midstate` under the struct, as is customary.

(Note the diff shows moving some other code around the impl block not
the impl block itself.)

Code move only.
2024-07-17 08:47:38 +10:00
Tobin C. Harding 5941008733
Import sha256t in docs builds
Explicitly import `sha256t` in docs builds and remove explicit link
target. This patch is code churn on its own but the `sha256t` module
will be used again in proceeding patches, done separately to reduce the
size/complexity of proceeding patches.
2024-07-17 08:47:37 +10:00
Tobin C. Harding ab581a90f8
Remove re-export of ParseIntError
In d242125 I claimed that `ParseIntError` was somehow special, I no
longer thing this is the case. As we pin down the re-export policy (for
errors and other types) it is hard if we have one non-typical re-export.

We have https://github.com/rust-bitcoin/rust-bitcoin/issues/3068 to
discuss the policy, for now just remove the unusual re-export.
2024-07-17 08:01:32 +10:00
Tobin C. Harding 54c30556a2
Move params to network module
The `Params` struct is currently defined in the `consensus` module which
has become a collection of orthogonal consensus-ish things. We would
like to put things in more descriptive places.

The `Params` struct defines constants that are network specific so it
makes sense to put it in the `network` module. As soft proof of this
argument note in this patch how often the `Params` type is imported
along with the `Network` type.

API break:

The type is no longer available at `bitcoin::consensus::Params` but
rather is re-exported at `bitcoin::network::Params`.
2024-07-17 07:39:34 +10:00
Tobin C. Harding 045a661ebe
Create network directory
In preparation for moving the `Params` struct to the `network` module
add a directory and move `network.rs` to `network/mod.rs`.
2024-07-17 07:19:27 +10:00