Commit Graph

355 Commits

Author SHA1 Message Date
merge-script 28b867d8de
Merge rust-bitcoin/rust-bitcoin#3966: Change `#[must_use]` to be the same as stdlib
cb5ffde9ee Change `#[must_use]` to be the same as stdlib (Jamil Lambert, PhD)

Pull request description:

  Change the iterator `#[must_use]` message to be the same as stdlib uses.

  Message taken from https://doc.rust-lang.org/src/core/iter/traits/iterator.rs.html#38

  Close #3962

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

Tree-SHA512: 4866d9bddccdc28e2ba2b15cb4041851abb1512cea0317f20d2e2306df6dcd1addb828d61a84a2083d3ef47abb5cf9276e857cf098de2d28b4706ecd0a1f24fa
2025-01-28 16:53:58 +00:00
Jamil Lambert, PhD cb5ffde9ee
Change `#[must_use]` to be the same as stdlib 2025-01-27 20:13:29 +00:00
Jamil Lambert, PhD bc8a378187
Rename `day_` variables to `time_`
To be consistent with similar lock height test function rename
`day_after/before` to `time_after/before` and change the same `time` to
`time_same`.
2025-01-27 16:45:24 +00:00
Jamil Lambert, PhD 922392268f
Combine satisfied by into singe tests
Include the satisfied by same time/height into the previous test that
checks above and below.
2025-01-27 16:44:41 +00:00
Jamil Lambert, PhD 33a7a35bbb
Make naming consistent in tests
Rename all occurrences of LockTime to specify if it is by height or
time.
2025-01-27 16:42:45 +00:00
Fmt Bot a3d2b2a93a 2025-01-26 automated rustfmt nightly 2025-01-26 01:16:37 +00:00
Jamil Lambert, PhD 40dc896932
Improve relative::LockTime tests
Cargo mutants found some untested mutants.

Add test cases to kill the mutants.
2025-01-23 19:29:42 +00:00
Jamil Lambert, PhD 2c73546454
Improve absolute::LockTime tests
Cargo mutants found some untested mutants.

Add test cases and refactor to improve readability.
2025-01-23 19:29:35 +00:00
Tobin C. Harding 7277092af4
Remove mutagen
Back in 2022 we elected to use `mutagen` for mutation testing. Since
then `cargo mutants` has progressed to a point where we would now like
to use it instead.

Remove all the `mutagen` stuff and update the lock files.

Close: #2829
2025-01-21 09:43:12 +11:00
Tobin C. Harding 39523ea1f5
units: Remove InputString from the public API
Currently `InputString` is in the public API of `units` because of the
trait bound on `parse::int()`. We can just do the monomorphisisation
manually to remove it.

This patch renames `int` to have three different names, one for `&str`
one for `String`, and one for `Box<str>`.
2025-01-15 08:09:38 +11:00
Fmt Bot 762f6630fe 2025-01-05 automated rustfmt nightly 2025-01-05 01:22:00 +00:00
merge-script 3b2363b2c6
Merge rust-bitcoin/rust-bitcoin#3846: Remove `test_` prefix from unit tests
85e04315d5 Remove test_ prefix from unit tests (Tobin C. Harding)

Pull request description:

  There is a loose convention in Rust to not use `test_` prefix. The reason being that `cargo test` outputs 'test <test name>' using the prefix makes the output stutter.

  This patch smells a bit like code-churn but having the prefix in some places and not others is confusing to new contributors and is leading me to explain this many times now. Lets just fix it.

  Remove the prefix unless doing so breaks the code.

ACKs for top commit:
  shinghim:
    ACK 85e04315d5
  apoelstra:
    ACK 85e04315d5eb90075ce55bf18fab8876a4583def; successfully ran local tests

Tree-SHA512: d90ae5ef75cc5e5a8f43f60819544f1a447f13cbe660ba71e84b8f27bfcc04a11d3afde0ed56e4eea5c73ebc3925024b800a1b995f73142cab892f97a414f14a
2025-01-04 00:23:46 +00:00
merge-script dddb63f4ad
Merge rust-bitcoin/rust-bitcoin#3842: Remove usage of impl_from_infallible in leaf crates
0d8e9ef096 Remove usage of impl_from_infallible in leaf crates (Tobin C. Harding)

Pull request description:

  Rust macros, while at times useful, are a maintenance nightmare. And we have been bitten by calling macros from other crates multiple times in the past.

  In a push to just use less macros remove the usage of the `impl_from_infallible` macro in all the leaf crates and just write the code.

ACKs for top commit:
  apoelstra:
    ACK 0d8e9ef096fd60fcdb7928697c8f554bf428b754; successfully ran local tests; this is a great change

Tree-SHA512: c4cff4517f7846d91142f26d451c2bcafc014a0921d11ac1487eab087449f12023c3b4fc57e1bc72ed3ea58406b4c3d24bbd846df21353f5d7ecb4a4b8bfb0b2
2025-01-03 23:42:21 +00:00
merge-script 192ea44d87
Merge rust-bitcoin/rust-bitcoin#3841: Remove macro `debug_from_display`
fd8d563b87 Remove macro debug_from_display (Tobin C. Harding)

Pull request description:

  Rust macros, while at times useful, are a maintenance nightmare. And we have been bitten by calling macros from other crates multiple times in the past.

  In a push to just use less macros remove the `debug_from_display` macro and just write the code.

  This is an API breaking change to `internals` but an internal change only to any of the _real_ crates.

ACKs for top commit:
  apoelstra:
    ACK fd8d563b873c87a996d82062285169e16e3f0c13; successfully ran local tests; this is a great change

Tree-SHA512: 26faa6645d010c1b5873d584c36d0fc52b73553d88be3226937431210ccc2479548757593b8a151936e9fa280cb3c604b241511f24ef0aa5cbf3f424d7ecf215
2025-01-03 23:01:11 +00:00
merge-script 93241c3cc8
Merge rust-bitcoin/rust-bitcoin#3838: primitives: Add core re-exports
79791e7444 primitives: Add core re-exports (Tobin C. Harding)

Pull request description:

  This is not strictly needed but we would like to copy the public macros from `units` to primitives and they use `$crate::_export` paths.

ACKs for top commit:
  apoelstra:
    ACK 79791e7444326d284bdf42c40926f6b05a6b65f7; successfully ran local tests; sure, lgtm

Tree-SHA512: cdf683041dca07bc53ae8e70806cfb74ef79e94b8699112774e3bfb3efd29cc270bd24ab03a448197edd1d143dec07d18d9a3a92d74097d87478d40954392ee4
2025-01-03 17:53:22 +00:00
Tobin C. Harding 85e04315d5
Remove test_ prefix from unit tests
There is a loose convention in Rust to not use `test_` prefix. The
reason being that `cargo test` outputs 'test <test name>' using the
prefix makes the output stutter.

This patch smells a bit like code-churn but having the prefix in some
places and not others is confusing to new contributors and is leading me
to explain this many times now. Lets just fix it.

Remove the prefix unless doing so breaks the code.
2025-01-02 10:06:50 +11:00
Tobin C. Harding 0d8e9ef096
Remove usage of impl_from_infallible in leaf crates
Rust macros, while at times useful, are a maintenance nightmare. And
we have been bitten by calling macros from other crates multiple times
in the past.

In a push to just use less macros remove the usage of the
`impl_from_infallible` macro in all the leaf crates and just write the
code.
2025-01-02 07:51:21 +11:00
Tobin C. Harding fd8d563b87
Remove macro debug_from_display
Rust macros, while at times useful, are a maintenance nightmare. And
we have been bitten by calling macros from other crates multiple times
in the past.

In a push to just use less macros remove the `debug_from_display`
macro and just write the code.

This is an API breaking change to `internals` but an internal change
only to any of the _real_ crates.
2025-01-02 07:31:13 +11:00
Tobin C. Harding 1a8f5b19fb
Update to rust-ordered 0.4.0
We just released a version of `ordered` that makes `ArbitraryOrd` object
safe - use it.

Upgrade to the latest version of `rust-ordered` - `v0.4.0`.
2024-12-31 10:42:24 +11:00
Tobin C. Harding 20b798175c
Update to latest rust-ordered
I just went to town on the `rust-ordered` crate to get it ready for
releasing a `1.0` version. None of the changes effect our usage here in
`rust-bitcoin`.

Upgrade to the latest version of `rust-ordered` - `v0.3.0`.
2024-12-30 08:35:01 +11:00
Tobin C. Harding 79791e7444
primitives: Add core re-exports
This is not strictly needed but we would like to copy the public macros
from `units` to primitives and they use `$crate::_export` paths.
2024-12-28 09:03:42 +11:00
merge-script f4069fcd61
Merge rust-bitcoin/rust-bitcoin#3780: Use uniform capitalisation of SegWit in rustdocs
e56f461916 Make capitalization of SegWit uniform in strings (Jamil Lambert, PhD)
3520e832ac Make capitalization of SegWit uniform in rustdocs (Jamil Lambert, PhD)

Pull request description:

  Fixes #3770

  - Searched and replaced all occurrences of `//` * `segwit` (case insensitive) with `//` * `SegWit`
  - Searched and replaced all occurrences of `"` * `segwit` (case insensitive) with `"` * `SegWit`

ACKs for top commit:
  apoelstra:
    ACK e56f461916b85928139950074d0df52caf4f919b; successfully ran local tests

Tree-SHA512: c56704102d8e86f26378bb302d5fdc7ea21d41fd49f55606e589ec32ff896f1adfb1960d8fb29abccfbf298b90fc357ed609d80fd0163dcb4ff01573646b02c3
2024-12-17 18:10:44 +00:00
Jamil Lambert, PhD 3520e832ac
Make capitalization of SegWit uniform in rustdocs 2024-12-17 14:28:28 +00:00
Tobin C. Harding b5f553d866
hashes: Bump version to 0.16.0
We need to do a quick release because it turns out I was wrong in
thinking that making `hex` an optional dependency is not a breaking
change.

```
the package `bitcoin` depends on `bitcoin_hashes`, with features: `hex`
but `bitcoin_hashes` does not have these features. It has a required
dependency with that name, but only optional dependencies can be used as
features.
```

Add a changelog, bump the version, depend on the new version repo wide,
and update the lock files - like its our job.
2024-12-16 12:41:17 +11:00
merge-script fcbe970ddb
Merge rust-bitcoin/rust-bitcoin#3734: Move script hash types to `primitives`
6e01383f16 api: Run just check-api (Tobin C. Harding)
3855d3cc83 Move script hashes to primitives (Tobin C. Harding)
d1dd63d6d4 Remove wildcard in script re-exports (Tobin C. Harding)

Pull request description:

  Woops, this should have been done before v0.101.0 was released.

  Move the `ScriptHash` and `WScriptHash` types to `primitives`.

  Requires moving constants and error types as well. We re-export the errors because they are in the `mod.rs` file so they should appear in both `primitives::script::FooError` and `bitcoin::script::FooError`.

ACKs for top commit:
  apoelstra:
    ACK 6e01383f162307a573c3454733ccae0596d3eaf6; successfully ran local tests

Tree-SHA512: 4ef838ee9c4cb3eb308ffa855ea5d6f5ad46f81c17b9413faa493a46a262afc18b47f28a0fdd5fc675eea31b895d0eb0e2505a523e820504ec88d9334d6874b4
2024-12-14 06:14:39 +00:00
merge-script 3c25a8acbc
Merge rust-bitcoin/rust-bitcoin#3753: Update to arbitrary v1.4
463fbd16f1 Update to arbitrary v1.4 (Tobin C. Harding)

Pull request description:

  Out with the old in with the new, update to the latest minor version of arbitrary.

  No real reason to do this except that I wanted to add the minor version instead of using just `1` so that we don't accidentally pull a new minor version in during a patch release (after we 1.0).

  (I'm unsure if this is necessary and did not test it against MSRV.)

ACKs for top commit:
  apoelstra:
    ACK 463fbd16f1431febe7e4fc50abd7415886542109; successfully ran local tests

Tree-SHA512: 88913f993b97abba224ba94ee9d5057894bb7142fef07e557de03a423da314a9f21632932fb64c4c27c676051bbb6e90d9b90bfa944af810e834bf42707d3cff
2024-12-14 01:39:38 +00:00
Tobin C. Harding 463fbd16f1
Update to arbitrary v1.4
Out with the old in with the new, update to the latest minor version of
arbitrary.

No real reason to do this except that I wanted to add the minor version
instead of using just `1` so that we don't accidentally pull a new minor
version in during a patch release (after we 1.0).
2024-12-12 15:44:45 +11:00
Tobin C. Harding 38c329c1b7
Add additional catagories
Add `no-std` category to the soon-to-be-released leaf crates.
Also add `cryptography` to the `bitcoin_hashes` crate.

Close: #3731
2024-12-12 15:14:26 +11:00
Tobin C. Harding 3855d3cc83
Move script hashes to primitives
Woops, this should have been done before v0.101.0 was released.

Move the `ScriptHash` and `WScriptHash` types to `primitives`.

Requires moving constants and error types as well. We re-export the
errors because they are in the `mod.rs` file so they should appear in
both `primitives::script::FooError` and `bitcoin::script::FooError`.
2024-12-12 15:14:00 +11:00
merge-script 33f6d028ab
Merge rust-bitcoin/rust-bitcoin#3722: clippy: Set avoid-breaking-exported-api to false
adaf4ac086 Set avoid-breaking-exported-api to false (Tobin C. Harding)

Pull request description:

  These lints are valuable, lets get at em.

ACKs for top commit:
  apoelstra:
    ACK adaf4ac086553674803fadfde776d6dd013a7964; successfully ran local tests; will probably be a problem repeatedly for the next few days until we get through all currently-open PRs

Tree-SHA512: 56617a2f4aeafceef72008232cee817d45b62c040d7f1938631291c5d73627851cfbefc4b4000cd380ecb5c7e1379d1022f6cc90a4b68c819c78fb883bee0b3a
2024-12-11 15:41:06 +00:00
merge-script 540c712dc7
Merge rust-bitcoin/rust-bitcoin#3712: primitives: Add `must_use`
549be547ac primitives: Add must_use (Tobin C. Harding)

Pull request description:

  Enable lint `clippy::return_self_not_must_use` and add attribute `must_use` as required.

  Also run the linter with `clippy::must_use_candidate` enabled and manually check every warning site.

  Done as part of #3185

ACKs for top commit:
  apoelstra:
    ACK 549be547accdb13037bf3ef60310ca30d045dce0; successfully ran local tests; nice! will one-ACK merge
  sanket1729:
    ACK 549be547ac

Tree-SHA512: b22a6849fd0f4a7b65e1a9816efd47d411dcf2a5d5d46ae75b2b4d2389d3c9f46ab271314b112de9cd6fdc52cac7b53a632642e9bd90092d7065a8646e1362ec
2024-12-11 12:55:48 +00:00
Tobin C. Harding adaf4ac086
Set avoid-breaking-exported-api to false
These lints are valuable, lets get at em.

Changes are API breaking but because the changes make functions consume
self for types that are `Copy` downstream should not notice the breaks.
2024-12-11 10:11:50 +11:00
Tobin C. Harding 549be547ac
primitives: Add must_use
Enable lint `clippy::return_self_not_must_use` and add attribute
`must_use` as required.

Also run the linter with `clippy::must_use_candidate` enabled and
manually check every warning site.

While we are at it change the current `must_use` usages to have no
message. We can always add a message later if needed.
2024-12-10 11:02:06 +11:00
Tobin C. Harding 6ae35be0db
primitives: Reduce alloc requirements
Recently we reduced the `alloc` requirements in `units` but we did not
propagate these changes up to `primitives`.

Remove a bunch of `alloc` feature gating from `primitives`.
2024-12-09 13:57:26 +11:00
Tobin C. Harding 77085a1fa1
units: Remove serde from amounts
The `Amount` and `SignedAmount` were not supposed to implement `serde`
traits by design because doing so implicitly uses sats. We provide two
modules `as_sat` and `as_btc` to allow users to explicitly serialize in
their preferred format.

In commit: `d57ec019d5 Use Amount type for TxOut value field` derives
were added for `serde` and we did not notice it during review.
2024-11-28 12:55:43 +11:00
Fmt Bot 500cd10802 2024-11-17 automated rustfmt nightly 2024-11-17 01:23:55 +00:00
merge-script d32422cdb7
Merge rust-bitcoin/rust-bitcoin#3611: Hashes: Make `hex` dependency optional
ec06028f63 hashes: Make hex dependency optional (Tobin C. Harding)
9dce0b4b8c Remove hex string trait bounds from GeneralHash (Tobin C. Harding)
766f498b33 Pull serde stuff out of impl_bytelike_traits macro (Tobin C. Harding)

Pull request description:

  This is done in 3 parts:

  1. Pull the `serde` stuff out of `impl_bytelike_traits` to fix the bug described here: https://github.com/rust-bitcoin/rust-bitcoin/issues/2654#issuecomment-2470716693
  2. Prepare the `hashes` trait by removing string/hex trait bounds from `GeneralHash` and also pull the hex/string stuff out of `impl_bytelike_traits`
  3. Make hex optional, including adding custom debug logic when `hex` feature is not enabled

  Patch 3 is tested in `hashes/embedded`, by the new `debug` unit test, and there is a `Midstate` unit test as well that covers the `Debug` impl.

  Close: #2654 - BOOM!

ACKs for top commit:
  apoelstra:
    ACK ec06028f63ba591a14c3a15cdfd410bb5ff1c09b; successfully ran local tests; nice!

Tree-SHA512: 85eb10d36a4581af6cd700f7ff876585bcc114c60e9864906e65659f3b3ee550fe6d9f40ca4230d870a9e23f0720723e11443ec329f16e40259a259b9be57466
2024-11-15 18:31:42 +00:00
Tobin C. Harding 53d3ab18b9
Bump version of bitcoin-primitives to 0.101.0
In preparation for releasing `primitives v0.101.0` bump the version
number, add a changelog entry, update the lock files, and depend on the
new version in all crates that depend on `primitives`.
2024-11-15 10:58:46 +11:00
Tobin C. Harding 175171d339
Make primitives re-exports uniform
Remove the whitespace, it should never have been there and put the
attributes in the same order.

Internal change only.
2024-11-15 10:58:46 +11:00
Tobin C. Harding 3e9267071f
primitives: Update crate level docs re allocator
We slightly improved the situation but much of the functionality is
still behind the `alloc` feature.
2024-11-15 10:58:45 +11:00
Tobin C. Harding 7819e50055
Move Block to primitives
On the way re-design the API by doing:

- Introduce `Checked` and `Unchecked` tags
- Rename the `txdata` field to `transactions`
- Make the `Block` fields private
- Add getters for `header` and `transactions` fields
- Move the various `compute_` methods to be free standing functions
- Make the `check_` functions private
- Introduce extension traits
2024-11-15 07:16:21 +11:00
Tobin C. Harding ec06028f63
hashes: Make hex dependency optional
The only reason we need `hex-conservative` is to parse strings and
format them as hex. For users that do not require this functionality we
can make the `hex-conservative` crate an optional dependency.

The `serde` feature requires `Display` so we enable `hex` from the
`serde` feature.

If `hex` feature is not enabled we still need to be able to debug so
provide `fmt::Debug` functionality by way of macros.

Close: #2654
2024-11-14 09:36:55 +11:00
merge-script 3d17ec962f
Merge rust-bitcoin/rust-bitcoin#3576: transaction: Add plural field getters
be553217f1 transaction: Add plural field getters (Tobin C. Harding)

Pull request description:

  The `Transaction` type was created way back when, and the field names were named using singular (`input` and `output`). In hindsite plural probably should have been used since its more idiomatic Rust but the fields have been around so long now that re-naming them is going annoy a whole bunch of people.

  As a compromise add getters that use plural, immutable and mutable versions, for both the `input` and `output` fields.

  Close: #822

ACKs for top commit:
  apoelstra:
    ACK be553217f19069dd9ca28c3ba5953059df9caa1b; successfully ran local tests; though will let this sit a couple days before merging
  sanket1729:
    ACK be553217f1

Tree-SHA512: 4df9db179a69c9eea2940008c9eca9f9b9b9d9f27e2a174db39bfb3d5c32a9d06b26e5349e5baf5af78600ae128d1b534559baf7335aec6df1238de96a508764
2024-11-13 17:42:55 +00:00
Tobin C. Harding 9dce0b4b8c
Remove hex string trait bounds from GeneralHash
For the `hashes` crate we would like to make `hex` an optional
dependency. In preparation for doing so do the following:

- Remove the trait bounds from `GeneralHash`
- Split the hex/string stuff out of `impl_bytelike_traits` into a
  separate macro.
2024-11-13 14:01:13 +11:00
Tobin C. Harding 766f498b33
Pull serde stuff out of impl_bytelike_traits macro
The `impl_bytelike_traits` macro is public and it is used in the
`hash_newtype` macro, also public.

Currently if a user calls the `hash_newtype` macro in a crate that
depends on `hashes` without the `serde` feature enabled and with no
`serde` dependency everything works. However if the user then adds a
dependency that happens to enable the `serde` feature in `hashes` their
build will blow up because `serde` code will start getting called from
the original crate's call to `hash_newtype`.

Pull the serde stuff out of `hash_newtype` and provide a macro to
implement it `impl_serde_for_newtype`.
2024-11-13 12:28:47 +11:00
Tobin C. Harding 195615c14d
Fix bug in witness stack getters
In #2646 we introduced a bug in the taproot witness stack getter
functions, of which we have three:

- `tapscript`
- `taproot_control_block`
- `taproot_annex`

Each returns `Some` if a possible bytes slice is found (with no other
guarantees).

Use `taproot_annex` combined with getters from `primitives` to implement
the other two getters. This simplifies the code and fixes the bug.

Add an additional getter to `primitives` `Witness::third_from_last`.

Fix: #3598
2024-11-13 10:55:51 +11:00
Tobin C. Harding 727c519efa
Re-export amount from primitives
We are trying to make it so that what ever crate a user uses they see
the same module/type tree (if the module or type exists).

E.g., one can do either of these.

If they use `bitcoin`:

```
use bitcoin::{
    amount, block, fee_rate, weight, merkle_tree, opcodes,
    pow, script, sequence, transaction, witness,
};
```

Or if they use `primitives`:

```
use bitcoin_primitives::{amount, block, fee_rate, weight};
```

The above imports were tested and `amount` was found to be missing.
2024-11-11 14:21:47 +11:00
Jamil Lambert, PhD 1649b68589
Standardize wording to `constructs a new`
There is a range of different wordings used in the docs of constructor
type functions.

Change all to start with `Constructs a new` or `Constructs an empty`.
2024-11-05 13:02:26 +00:00
Jamil Lambert, PhD 27f94d5540
Replace `creates` with `constructs`
In functions that act like constructors there is a mixture of the usage
of `creates` and `constructs`.

Replace all occurrences of `creates` with `constructs` in the first line
of docs of constructor like functions.
2024-11-05 12:47:28 +00:00
Tobin C. Harding be553217f1
transaction: Add plural field getters
The `Transaction` type was created way back when, and the field names
were named using singular (`input` and `output`). In hindsite plural
probably should have been used since its more idiomatic Rust but the
fields have been around so long now that re-naming them is going annoy a
whole bunch of people.

As a compromise add getters that use plural, immutable and mutable
versions, for both the `input` and `output` fields.

Close: #822
2024-11-04 15:07:54 +11:00
Tobin C. Harding 6555143478
bitcoin: Re-format crate level re-exports
Is there any advantage trying to lay out the re-exports to give users an
idea of the crate structure?

We have the explicit aim that users who depend on `bitcoin` do not ever
need to reach directly into `primitives` (or `units`) however it is kind
of nice to know where things come from, saves jumping to multiple files
looking for them (for those of us that jump to files manually).

I do not know how all the re-exports interact with other folks IDEs, I
personally open files manually and just remember where stuff is.
2024-11-04 08:49:03 +11:00
merge-script 794fb75497
Merge rust-bitcoin/rust-bitcoin#3562: Re-export `block::Header` as `BlockHeader`
85942c355d Re-export block::Header as BlockHeader (Tobin C. Harding)

Pull request description:

  For users who want to just grab stuff from the crate root it makes total sense for there to be a `BlockHeader`.

  Another nice thing, in the HMTL docs it makes BlockHeader be in the struct list right along with `Block`, `BlockHash`, and `BlockHeight`.

  Close: #3548

ACKs for top commit:
  apoelstra:
    ACK 85942c355dfdcf9ddf9a46202f4db56794dcc85d; successfully ran local tests
  jamillambert:
    ACK 85942c355d

Tree-SHA512: 6fbaf7936062323d31940179ffcbc62951b21f53955a42dca2e28476bda0cebeb041db0e1b4f1ceeac32e43d94fe5476ef055595ae88dc6cfc266d32082bdf4d
2024-11-03 17:02:38 +00:00
Fmt Bot 5ecf7f2d67 2024-11-03 automated rustfmt nightly 2024-11-03 01:21:14 +00:00
Tobin C. Harding 32bc68d4dc
primitives: Add rustdoc links back in
During move of code to `primitives` we removed a few links to types that
were not yet moved, we can now put these back in.

Feature all rustdoc imports on `alloc` and `doc`.

Close: #2997
2024-11-02 08:26:39 +11:00
Tobin C. Harding 85942c355d
Re-export block::Header as BlockHeader
For users who want to just grab stuff from the crate root it makes total
sense for there to be a `BlockHeader`.

Another nice thing, in the HMTL docs it makes BlockHeader be in the
struct list right along with `Block`, `BlockHash`, and `BlockHeight`.
2024-11-02 07:38:10 +11:00
merge-script c46171899a
Merge rust-bitcoin/rust-bitcoin#3551: primitives: Add missing re-exports
2b7cb04265 primitives: Add missing re-exports (Tobin C. Harding)

Pull request description:

  Add re-exports of types from `taproot` and `merkle_tree`.

ACKs for top commit:
  jamillambert:
    ACK 2b7cb04265
  apoelstra:
    ACK 2b7cb04265cdb2d62c1bcc645e19d8bafa132b4b; successfully ran local tests

Tree-SHA512: e837c8e7bfda3e8c5510a15ba19b2b0b433e9e87c961ab9ab81d134288b70bc98364007e8e610e7066732e16f72ea990a782cade9ead6b71ddc9b843753fa0ee
2024-11-01 15:23:39 +00:00
Tobin C. Harding 6aa8c2b023
Remove needless_borrows_for_generic_args
This has been fixed and we use nightly to lint so we have access to the
merged fix.

Removing the attribute uncovers a bunch of real lint warnings, fix
them while we are at it.
2024-11-01 14:30:45 +11:00
merge-script 4c8347a7ac
Merge rust-bitcoin/rust-bitcoin#3544: Favour `to_vec` over `to_bytes`
a51768af3f key: Deprecate to_bytes (Tobin C. Harding)
3af3239ad0 script: Re-order functions (Tobin C. Harding)
db40297f87 script: deprecate to_bytes (Tobin C. Harding)
c5cd0db493 Revert the change to to_bytes (Tobin C. Harding)
dc2ca785d2 Add to_vec and deprecate to_bytes for array types (Tobin C. Harding)
a6b7ab32a8 Move impl_array_newtype to internal_macros (Tobin C. Harding)

Pull request description:

  Use `to_vec` and deprecate `to_bytes`, the opposite of what we did in #2585.

  For functions that return a `Vec` by first allocating use function name `to_vec`. This explicitly excludes:

  - Functions that return an array (`CompressedPublicKey::to_bytes`)
  - Functions that consume self and return a `Vec` without allocating (`ScriptBuf::into_bytes`)

  See #3025 for discussion and consensus.

  Close: #3025

ACKs for top commit:
  apoelstra:
    ACK a51768af3f3d4c8e138e1ded250800810bedc903; successfully ran local tests

Tree-SHA512: ee932c13ad2e09c2b76a7833b23c859df175aa307f56e673921f3ae8b5d865518c6f999749e3b627594457b3ca33301b777177ada3520cf006acc0f14e5dacf8
2024-11-01 00:55:15 +00:00
merge-script 8bc2f39fca
Merge rust-bitcoin/rust-bitcoin#3547: Remove more wildcard re-exports
0bf1910980 Remove wildcard from script self re-exports (Tobin C. Harding)
397a4b9382 Remove wildcard in push_bytes module (Tobin C. Harding)

Pull request description:

  We thought #3436 was done (well I thought it was), turns out I was wrong.

ACKs for top commit:
  jamillambert:
    ACK 0bf1910980
  apoelstra:
    ACK 0bf1910980a13005496244ec4d4adf0553afbc73; successfully ran local tests

Tree-SHA512: 131a4aa4a907099790d14cfc2d19305943a2270cf6852c7dd92e35ea69188c9a40797fb22fd2ed8b2fefc2d6380b884401b5e32f521711f0f7b2da610d0e332f
2024-10-31 23:51:50 +00:00
merge-script 8af8bc7886
Merge rust-bitcoin/rust-bitcoin#3543: Bump hex-conservative to 0.3.0
7f289a9fdf Bump hex-conservative to 0.3.0 (Leo Nash)

Pull request description:

ACKs for top commit:
  tcharding:
    ACK 7f289a9fdf
  apoelstra:
    ACK 7f289a9fdf86604cc1ecfb31c6df0ea5bb175465; successfully ran local tests

Tree-SHA512: bf8543ef7dc9b7ec0d11659c0a53213be50b9bbae0e6ba6970a19d32b3d89025315fcae332c23d68582ef69ea5f8e6673192ff74316a1e3dc47521312bbc469e
2024-10-31 21:05:02 +00:00
Tobin C. Harding 2b7cb04265
primitives: Add missing re-exports
Add re-exports of types from `taproot` and `merkle_tree`.
2024-11-01 07:31:07 +11:00
Tobin C. Harding 3af3239ad0
script: Re-order functions
We want our code to be easy to read and our APIs discoverable, for those
of us who read source files the layout matters.

Put the constructors and getters at the top of the impl block.

Code move only, no logic changes.
2024-11-01 07:09:59 +11:00
Tobin C. Harding db40297f87
script: deprecate to_bytes
Deprecate the `Script::to_bytes` function in favour of `to_vec` as we
are doing elsewhere.

Note that `ScriptBuf` has `into_bytes` because it does not copy.
Potentially this should be deprecated in favour of `into_vec`?

Note that in regards to the `to_` prefix this naming as valid according
to convention because the `Script` type is borrowed and `to_vec` copies
the underlying bytes.
2024-11-01 07:09:53 +11:00
Tobin C. Harding c5cd0db493
Revert the change to to_bytes
During this release cycle we deprecated `to_vec` in favour of
`to_bytes`, we have since reversed our position on the name.

Remove the deprecation of `to_bytes` from the three types that had it
and use `to_vec`.
2024-11-01 07:09:11 +11:00
Tobin C. Harding 0bf1910980
Remove wildcard from script self re-exports
In the `script` module remove the wildcards and re-export stuff from
`self` explicitly in both `primitives` and `bitcoin`.

Internal change only, everything is re-exported.
2024-10-31 15:52:54 +11:00
Leo Nash 7f289a9fdf Bump hex-conservative to 0.3.0 2024-10-31 03:36:22 +00:00
Tobin C. Harding bafe11d7e4
Correctly feature gate impl_to_hex_from_lower_hex
Currently we feature gate code within the `impl_to_hex_from_lower_hex`
 macro on "alloc" but `bitcoin` does not have the "alloc" feature so
 this code is never built in. This can be seen by the lack of a
 `to_hex` function on `LeafVersion`.

Remove the feature gate from the macro and put it on the individual
call sites as needed.
2024-10-31 13:43:47 +11:00
Tobin C. Harding 57769f5f28
Fix ugly rustfmt
Fix some ugly formatting introduced by the fmt bot recently.

Whitespace only, no logic changes.
2024-10-31 13:38:27 +11:00
Tobin C. Harding f8f846bb9e
Move Transaction type to primitives
Needs no explanation - lets go!
2024-10-30 12:28:53 +11:00
Tobin C. Harding e84346644e
Run the formatter
Run `just fmt` - no other changes.
2024-10-30 11:30:24 +11:00
merge-script 1f578fc929
Merge rust-bitcoin/rust-bitcoin#3518: Automated nightly rustfmt (2024-10-27)
39f46a16bc 2024-10-27 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 39f46a16bc
  apoelstra:
    ACK 39f46a16bc0da356f495166ccd5829627af3749b; successfully ran local tests

Tree-SHA512: 6c27714b18ad6957104246145a2d4243f8e43e378d63f3d946ba05ecaf859432f2fe363fe3e7a29a33c41297216fd1176c165ac55deb109f636813c637ff6c43
2024-10-28 21:34:59 +00:00
merge-script 6c54a1d2f2
Merge rust-bitcoin/rust-bitcoin#3497: Explicitly re-export stuff from crates down the stack
66da2266e2 Explicitly re-export stuff from crates down the stack (Tobin C. Harding)

Pull request description:

  Up until recently we were using wildcard re-exports for types moved to `units` and `primitives`. We have decided against doing so in favour of explicit re-exports.

  Audit `units` and `primitives` using `git grep 'pub enum'` (and `struct`) and explicitly re-export all types.

  Remove all wildcards except for the re-exports from `opcodes`, there are too many opcodes, explicitly re-exporting them does not aid clarity.

ACKs for top commit:
  apoelstra:
    ACK 66da2266e26dfe53947c4606e9d18620931e93cf; successfully ran local tests

Tree-SHA512: 74717f8b127e975e3d131aab884bdfe78e699d88b7ee1db7731ad117437d37684285264001cf6b2182eb1e565171167695e00c4b6aef28a3e26b69d9cebfbb74
2024-10-28 19:20:23 +00:00
Tobin C. Harding 3e2c43b19e
Elide more lifetimes
clippy found some more lifetimes to elide.
2024-10-28 15:22:13 +11:00
Fmt Bot 39f46a16bc 2024-10-27 automated rustfmt nightly 2024-10-27 01:21:24 +00:00
Tobin C. Harding 66da2266e2
Explicitly re-export stuff from crates down the stack
Up until recently we were using wildcard re-exports for types moved to
`units` and `primitives`. We have decided against doing so in favour of
explicit re-exports.

Audit `units` and `primitives` using `git grep 'pub enum'` (and
`struct`) and explicitly re-export all types.

Remove all wildcards except for the re-exports from `opcodes`, there are
too many opcodes, explicitly re-exporting them does not aid clarity.
2024-10-27 06:45:58 +11:00
Tobin C. Harding 003dc9cf4d
Move TxOut to primitives
The `TxOut` has all public fields; move the `TxOut` to `primitives`.
2024-10-24 09:04:12 +11:00
Tobin C. Harding 4d37d7efc6
Move TxIn to primitives
The `TxIn` has all public fields; move the `TxIn` to `primitives`.
2024-10-24 09:04:12 +11:00
Tobin C. Harding 1b521dce99
Move taproot hash types to primitives
Move the three `taproot` hash types and their associated tags over to
the `primitives` crate.
2024-10-22 13:50:44 +11:00
merge-script 7e5911923f
Merge rust-bitcoin/rust-bitcoin#3284: Add a few unit tests for Sequence
4a8e2c3704 Add tests for sequence (Shing Him Ng)

Pull request description:

  Add a few unit tests for Sequence

ACKs for top commit:
  apoelstra:
    ACK 4a8e2c3704 successfully ran local tests; sure
  tcharding:
    ACK 4a8e2c3704

Tree-SHA512: fb793a6a94a9d3f1522357f98a73a87618ba70776875b3ce051631970ca6c15998401dece47e426f7040770b8d24ee1b72f206d3164b7ca76492e12e86116677
2024-10-21 23:58:55 +00:00
Fmt Bot 2a08b29232 2024-10-20 automated rustfmt nightly 2024-10-20 01:21:52 +00:00
merge-script 51d503730d
Merge rust-bitcoin/rust-bitcoin#3406: Move `Witness` to `primitives`
c1eccfde25 Move Witness to primitives (Tobin C. Harding)
6ce76cd7c8 Add unstable constructor to Witness (Tobin C. Harding)

Pull request description:

  Patch 1 introduces a new policy to the codebase, we use `foo__unstable` for public unstable functions and there are zero semver guarantees if you call these functions.

  Patch 2 does the move.

  Close #3406

ACKs for top commit:
  apoelstra:
    ACK c1eccfde25fd4c2b19e7ec6759352b46ac246113; successfully ran local tests

Tree-SHA512: 2388066be2b6bb2cf3d6757c8f6334beeda6115ef1ce7c537955d32aa5e466add5162d0d2adee27f416fe622fc93c4e94bd848326463ee55e08d1c0f4e03719c
2024-10-18 16:35:15 +00:00
Tobin C. Harding c1eccfde25
Move Witness to primitives
Move the `Witness` over to `primitives` leaving behind any method that
takes or returns a `Script` or a signature.

Includes addition of a feature gate to unit test.
2024-10-18 14:02:03 +11:00
merge-script 7af9e33f2b
Merge rust-bitcoin/rust-bitcoin#3468: Move `block::Header` to `primitives`
ff64fa3c46 Move block::Header to primitives (Tobin C. Harding)
65925117a0 Manually implement block::Header::block_hash (Tobin C. Harding)
b02ab25342 Add regression test for block_hash function (Tobin C. Harding)
5614694b69 block: Remove wildcard re-export (Tobin C. Harding)

Pull request description:

  - Patch 1: Trivial preparation.
  - Patch 2 and 3: Reduce the API surface in a disappointing way due to the orphan rule.
  - Patch 4: Do the move.

ACKs for top commit:
  apoelstra:
    ACK ff64fa3c46 successfully ran local tests; nice!

Tree-SHA512: 8d93de4a12c9f71f9dfbdc023fd8defb78f7d3da995490af8f83a927c2ca6338dd236bc08691311dc7345183fb6d0be61eedce3e4424d4060be2de934facd60a
2024-10-17 13:12:06 +00:00
Jamil Lambert, PhD 88b53a471e
Unify deprecated note field format
All the deprecated note fields have been changed to be lower case and in
the format "use `a` instead".
2024-10-15 15:16:01 +01:00
Shing Him Ng 4a8e2c3704 Add tests for sequence 2024-10-14 22:41:23 -05:00
Tobin C. Harding ff64fa3c46
Move block::Header to primitives
Introduce an extension trait and move the `block::Header` type to
`primitives`.

Nothing surprising here.
2024-10-15 11:04:00 +11:00
Tobin C. Harding e68da281ff
Warn on future deprecations
We use `TBD` in our `deprecated` string and it was discovered that there
is an exception on this string so as not to warn because it is used
internally by the Rust language. However there is a special lint to
enable warnings, lets use it.

Add `#![warn(deprecated_in_future)]` to the coding conventions section
of all crates except `fuzz`.
2024-10-15 07:56:06 +11:00
Shing Him Ng 0e0192c025 Add tests for block version 2024-10-13 22:07:31 -05:00
merge-script 1b23d1c66c
Merge rust-bitcoin/rust-bitcoin#3431: Move script types to `primitives`
d649c06238 Move script types to primitives (Tobin C. Harding)
ec4635904b Inline bytes_to_asm_fmt into Script::Display impl (Tobin C. Harding)

Pull request description:

  First patch removes `bytes_to_asm_fmt` as requested by Kix here: https://github.com/rust-bitcoin/rust-bitcoin/pull/3194#discussion_r1756557768

  Second patch does the move. The move is minimal but there is quite a bit of code moved in `script/mod.rs` - I believe it is as minimal as required as well.

ACKs for top commit:
  apoelstra:
    ACK d649c06238 successfully ran local tests

Tree-SHA512: 329a23948ac5617402a724b734d81cde8ab1f57ddd4860f858880618e260ea8b5cc89315de1fd93ae32787d5e8508fd604a41f003b1f5772a773b5b1648d382c
2024-10-14 00:31:38 +00:00
Tobin C. Harding d649c06238
Move script types to primitives
Move the `Script` and `ScriptBuf` types to `primitives`, nothing else.
2024-10-14 09:02:39 +11:00
merge-script cc5b46bfc7
Merge rust-bitcoin/rust-bitcoin#3462: Automated nightly rustfmt (2024-10-13)
f1733309e0 2024-10-13 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:
  apoelstra:
    ACK f1733309e0 successfully ran local tests

Tree-SHA512: 465336b92d9b8a61afbc8e8d0560f3b41a732e3245d764447cc2a5429f693e29172bebeca756a91b5a1f3a16d42728960a526111bbd92316f72b46b420373641
2024-10-13 16:40:17 +00:00
merge-script 4717f4d1af
Merge rust-bitcoin/rust-bitcoin#3459: feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF
3565f70df9 feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF (ChrisCho-H)

Pull request description:

  follow up https://github.com/rust-bitcoin/rust-bitcoin/pull/3455.
  Replace all `ENABLE_RBF_NO_LOCKTIME`(deprecated) with `ENABLE_LOCKTIME_AND_RBF`

ACKs for top commit:
  apoelstra:
    ACK 3565f70df9 successfully ran local tests
  tcharding:
    ACK 3565f70df9

Tree-SHA512: 4c6c6ad9ac89efe042cf239ce68594e715dbc827c1ae430819e2f16d2191f82d81f1e55b348f8176fc21454cf9d25fc9da1a414982cd3483d5f9f39834441f6c
2024-10-13 14:09:42 +00:00
Fmt Bot f1733309e0 2024-10-13 automated rustfmt nightly 2024-10-13 01:20:28 +00:00
merge-script 65e290a0ce
Merge rust-bitcoin/rust-bitcoin#3450: Add version three variant to transaction version
9e6b8faf84 feat: add version three variant to transaction version (Rob N)

Pull request description:

  Topologically restricted transactions are now considered standard as of Bitcoin 28.0.

ACKs for top commit:
  apoelstra:
    ACK 9e6b8faf84 successfully ran local tests
  tcharding:
    ACK 9e6b8faf84

Tree-SHA512: 289b986304e206802f04cee6607087167f6d91d8a81d4fc49ed01c430f4f6ad00b44646fbefdd000148fc5bfe2d257f92b386bfaf4405c482e4e438d830ab586
2024-10-12 17:55:21 +00:00
merge-script ae2358610d
Merge rust-bitcoin/rust-bitcoin#3457: Fix unused import
a250c8eee4 Fix unused imports (Shing Him Ng)

Pull request description:

  Found some unused imports while working on something unrelated

ACKs for top commit:
  apoelstra:
    ACK a250c8eee4 successfully ran local tests
  tcharding:
    ACK a250c8eee4

Tree-SHA512: ffa4fcddb91c849df7885a6d734405ab704e0353293fa3462a981e179ea49091990df4482eee2324e7b5ef250a0890b2e8983d53ec288ca6e8ada77e30c102dc
2024-10-12 14:56:48 +00:00
Andrew Poelstra 76f022d380 Merge rust-bitcoin/rust-bitcoin#3438: Implement Arbitrary for Block
0c824c9c68 Implement Arbitrary for Block (Shing Him Ng)

Pull request description:

  Implementing `Arbitrary` for `Block` and its child types

ACKs for top commit:
  apoelstra:
    ACK 0c824c9c68 successfully ran local tests
  tcharding:
    ACK 0c824c9c68

Tree-SHA512: 407acd4155ca7496bf7c59af19f103b22b4c74dd013c2e2c42aae690ba7264ecd42ed034355cf8895f2532f8cef77dfdbeac250301a6973afd5f3920be7e4310
2024-10-12 14:15:28 +00:00
ChrisCho-H 3565f70df9 feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF 2024-10-12 12:42:43 +09:00
Rob N 9e6b8faf84
feat: add version three variant to transaction version 2024-10-11 06:38:58 -10:00
merge-script 0f887707ea
Merge rust-bitcoin/rust-bitcoin#3455: Use new Sequence::ENABLE_RBF_AND_LOCKTIME
5e0a07e74f Use new Sequence::ENABLE_RBF_AND_LOCKTIME (Tobin C. Harding)

Pull request description:

  We just renamed this and forgot to use the new name. This should have been caught by CI.

ACKs for top commit:
  apoelstra:
    ACK 5e0a07e74f successfully ran local tests

Tree-SHA512: 0830184f3afa7b42d53460444637d16bace98438fac14a53e3c6f2fdb5b801847f3864d104be2e5311131b2db432e7ef8dd20ad833420ea05303fc93bd4dc68c
2024-10-11 14:59:57 +00:00
merge-script 03715872cd
Merge rust-bitcoin/rust-bitcoin#3432: fmt: Use style_edition = 2021
323e706113 Add rustfmt config option style_edition (Tobin C. Harding)
2e4179ed0f Run the formatter (Tobin C. Harding)
2c40b4f4ec Configure formmater to skip read_compact_size (Tobin C. Harding)

Pull request description:

  `rustfmt` is emitting:

   Warning: the `version` option is deprecated. Use `style_edition` instead.

  As suggested add a config option and set it to 2021.

  - Patch 1: Manually configure rustfmt to skip some code
  - Patch 2: Run the formmater with current configuration
  - Patch 3: Add the new config option (remove old one), introduces no new formatting requirements

ACKs for top commit:
  apoelstra:
    ACK 323e706113 successfully ran local tests

Tree-SHA512: 7f80cc89f86d2d50936e51704344955fa00532424c29c0ee3fae1a6836e24030f909b770d28da13e1c5efde3d49ad7d52c6d909d120fb09c33abf1755f62cd38
2024-10-11 12:48:50 +00:00
Shing Him Ng a250c8eee4 Fix unused imports 2024-10-10 23:42:51 -05:00
Shing Him Ng 0c824c9c68 Implement Arbitrary for Block 2024-10-10 23:30:39 -05:00
Tobin C. Harding 5e0a07e74f
Use new Sequence::ENABLE_RBF_AND_LOCKTIME
We just renamed this and forgot to use the new name. This should have
been caught by CI.
2024-10-11 11:46:34 +11:00
merge-script fe62d94ff7
Merge rust-bitcoin/rust-bitcoin#3296: Remove the `SliceIndex` implementation from hash types
3b7ba4f977 Remove the SliceIndex implementation from hash types (Tobin C. Harding)

Pull request description:

  If folk really want to index into a hash they can us `as_byte_array` then index that.

  Includes a bump to the version number of `hashes` to `v0.15.0` - this is because otherwise `secp` won't build since we are breaking an API that is used in the current release of secp.

  Fix: #3115

ACKs for top commit:
  apoelstra:
    ACK 3b7ba4f977 successfully ran local tests

Tree-SHA512: 0ba93268cd8133fe683183c5e39ab8b3bf25c15bfa5767d2934d67a5f6a0d2f65f6c9304952315fe8a33abfce488d810a8d28400a28facfb658879ed06acca63
2024-10-10 22:39:21 +00:00
merge-script d5ebb19543
Merge rust-bitcoin/rust-bitcoin#3437: Move `block::Version` to primitives
70264bfcec Move block::Version to primitives (Tobin C. Harding)
819d8d72e8 Stop using private Version constructor (Tobin C. Harding)

Pull request description:

  This is a straight up move of the whole type because there are only three methods, a getter, a setter, and `is_signalling_soft_fork`.

  If we use an extension trait for `is_signalling_soft_fork` then we have to make the two private associated consts public which is in my opinion worse.

  Patch 1 is preparation, use getter/setter, patch 2 does the move.

ACKs for top commit:
  apoelstra:
    ACK 70264bfcec successfully ran local tests

Tree-SHA512: b61e853b4b96cb1cc56c7bfb67cc6c3ba7c631cb9e540393eb780dcf63bd2d934058794f2ac0145b4b5404a6a68887c3a1d225b2d87b57415474c05d3ef2811f
2024-10-10 21:28:44 +00:00
Tobin C. Harding 2e4179ed0f
Run the formatter
Run `just fmt`, no other manual changes.
2024-10-10 10:39:53 +11:00
merge-script 0a83e5336d
Merge rust-bitcoin/rust-bitcoin#3439: sequence: clarify sequence constant name and add FINAL
4499b5c95b feat: rename ENABLE_RBF_NO_LOCKTIME to ENABLE_LOCKTIME_AND_RBF (ChrisCho-H)
861d97de36 feat: add FINAL constant to disable all (ChrisCho-H)

Pull request description:

  c24630e7b13312ea34f0f54ed832783ced8dde3f
  - `LOCKTIME` is used for both absolute and relative one without clear classification, which is confusing and could lead to an unexpected bug. Although it's API breaking change, current constant is so ambiguous unless understand the details of `LOCKTIME` semantic.

  9cc5dfeef178f03ea4d0786cfbaa3b8709fed644
  - Add constant `ENABLE_ALL` and `DISABLE_ALL`, which is useful for those who want to enable(disable) rbf, absolute/relative locktime.

ACKs for top commit:
  tcharding:
    ACK 4499b5c95b
  apoelstra:
    ACK 4499b5c95b successfully ran local tests

Tree-SHA512: dbea5ae911556d53025078e7193f0972d5e8ba354f69692091b2b05cc441e270f25eafa55b144a6970de42d8f596a2b0103cdee463c3126d5d9986cee88ce8fc
2024-10-08 02:46:11 +00:00
ChrisCho-H 4499b5c95b feat: rename ENABLE_RBF_NO_LOCKTIME to ENABLE_LOCKTIME_AND_RBF 2024-10-05 18:39:26 +09:00
ChrisCho-H 861d97de36 feat: add FINAL constant to disable all 2024-10-03 22:51:49 +09:00
Tobin C. Harding 3b7ba4f977
Remove the SliceIndex implementation from hash types
If folk really want to index into a hash they can us `as_byte_array`
then index that.

Includes a bump to the version number of `hashes` to `v0.15.0` - this
is because otherwise `secp` won't build since we are breaking an API
that is used in the current release of secp.

Fix: #3115
2024-10-02 10:18:45 +10:00
Tobin C. Harding fed94f8899
Bump version of bitcoin-io to 0.2.0
In preparation for releasing `io v0.2.0` bump the version number,
add a changelog entry, update the lock files, and depend on the new
version in all crates that depend on `io`.
2024-10-02 09:47:10 +10:00
Tobin C. Harding 70264bfcec
Move block::Version to primitives
This is a straight up move of the whole type because there are only
three methods, a getter, a setter, and `is_signalling_soft_fork`.

If we use an extension trait for `is_signalling_soft_fork` then we
have to make the two private associated consts public which is in my
opinion worse.
2024-10-02 09:35:23 +10:00
merge-script e8a3c1f01b
Merge rust-bitcoin/rust-bitcoin#3117: Release tracking PR: `bitcoin-units 0.2.0`
07a529a132 Bump version of bitcoin-units to 0.2.0 (Tobin C. Harding)
148711a4c6 units: Use double ## in changelog entries (Tobin C. Harding)
80e600ba0c units: Copy 0.1.2 release notes (Tobin C. Harding)

Pull request description:

  In preparation for releasing `units v0.2.0` bump the version number, add a changelog entry, update the lock files, and depend on the new version in all crates that depend on `units`.

  Close: #3095

ACKs for top commit:
  apoelstra:
    ACK 07a529a132 successfully ran local tests

Tree-SHA512: 98a75d485ded6225551a5fc4b4a14d8efecc76911a720f959044cdd62781024a8787f258f171ed297705f5ab470f9a88a81ad5d255c9e03c1e22857615ad2e6d
2024-10-01 22:51:05 +00:00
merge-script 12e4671810
Merge rust-bitcoin/rust-bitcoin#3388: Move `OutPoint` to `primitives`
da0795e590 primitives: Use doc links for OutPoint (Tobin C. Harding)
b079cbafee Move OutPoint to primitives (Tobin C. Harding)
f5c46cd411 Introduce OutPoint extension traits (Tobin C. Harding)
7e5bd5048d Remove docs on deprecated is_null function (Tobin C. Harding)
97b20a2316 Add additional impl block to OutPoint (Tobin C. Harding)

Pull request description:

  Just the minimal move of `OutPoint` to `primitives`.

  The last patch closes #3347

ACKs for top commit:
  apoelstra:
    ACK da0795e590 successfully ran local tests

Tree-SHA512: dced5a6d6bc6af0ce8b4ae4e52c04b45c85eb77a24bb25762ba8ab7deeab1e6b392cc4b258bb14218e8a2af999715dfed45ba94599cb16963a843995a7475917
2024-09-30 21:32:14 +00:00
merge-script 0b5e0bac31
Merge rust-bitcoin/rust-bitcoin#3401: Move the `block` hash types over to `primitives`
2d8c613340 Move the block hash types to primitives (Tobin C. Harding)
6b9429ac7b Remove BlockHash::all_zeros (Tobin C. Harding)
20d8dbd586 Add missing line of whitespace (Tobin C. Harding)

Pull request description:

  As an initial step in moving the `block` module, just move over the hash types `BlockHash` and `WitnessCommitment`.

  Patch 2 introduces an associated const `BlockHash::GENESIS_PREV_BLOCKHASH` and removes `all_zeros`.

ACKs for top commit:
  apoelstra:
    ACK 2d8c613340 successfully ran local tests

Tree-SHA512: 64aa0ae81e1c8ab1b5d4cd8cd28e6ef04ed01bf79175dc5b1fd607a6f0967e06b0aaf4c10ad368e2b327edcad3705187b6643d5ca8647716319424f19a838ba1
2024-09-30 19:40:15 +00:00
merge-script 08eaab2ecf
Merge rust-bitcoin/rust-bitcoin#3400: Move `merkle_tree` hash types to `primitives`
9ded58fc99 Move merkle_tree hash types to primitives (Tobin C. Harding)

Pull request description:

  In preparation for moving the `block::Header` struct over to `primitives` move the `merkle_tree` hash types.

ACKs for top commit:
  apoelstra:
    ACK 9ded58fc99 successfully ran local tests

Tree-SHA512: 98017cf0403871f01a6efeda22e8f319cc8104b9bc2f3a9bae2d6a31f6df8172307466c6486a9259204166933137fa03e565e08a0c156c278cfeb72cdae09b89
2024-09-30 18:29:56 +00:00
Fmt Bot a65d2a0ee4 2024-09-29 automated rustfmt nightly 2024-09-29 01:21:14 +00:00
yancy d39334e651 Refactor Arbitrary for Sequence 2024-09-27 11:26:33 -05:00
Tobin C. Harding da0795e590
primitives: Use doc links for OutPoint
Now that `OutPoint` is in `primitives` we can use a rustdoc link. While
we are at it link from the error type docs too.

Close: #3347
2024-09-27 12:43:13 +10:00
Tobin C. Harding b079cbafee
Move OutPoint to primitives
Move the `OutPoint` type and associated code over to `primitives`. Take
the opportunity to re-order the code so the file reads like a story,
things are implemented below where they are called.
2024-09-27 12:43:13 +10:00
Shing Him Ng 9d9872711f Refine Sequence and Version Arbitrary impls 2024-09-26 14:31:29 -05:00
Tobin C. Harding 07a529a132
Bump version of bitcoin-units to 0.2.0
In preparation for releasing `units v0.2.0` bump the version number,
add a changelog entry, update the lock files, and depend on the new
version in all crates that depend on `units`.
2024-09-25 10:58:31 +10:00
Tobin C. Harding 2d8c613340
Move the block hash types to primitives
Move the `BlockHash` and `WitnessCommitment` hash types over to
`primitives`.
2024-09-25 06:58:55 +10:00
Tobin C. Harding 9ded58fc99
Move merkle_tree hash types to primitives
In preparation for moving the `block::Header` struct over to
`primitives` move the `merkle_tree` hash types.
2024-09-25 06:56:24 +10:00
merge-script 6338f7c973
Merge rust-bitcoin/rust-bitcoin#3375: Release tracking PR: `bitcoin-internals 0.4.0`
18110a51f2 Bump version of internals to 0.4.0 (Tobin C. Harding)

Pull request description:

  In preparation for releasing `internals v0.4.0` bump the version number, add a changelog entry, update the lock files, and depend on the new version in all crates that depend on `internals`.

ACKs for top commit:
  apoelstra:
    ACK 18110a51f2 successfully ran local tests; lots of nice stuff here

Tree-SHA512: a4d3d5279b7d7fa993cbc3b7b34fc6dc4024dd54c0bfa1ecd0f0d5f09b984871f156c3695092a1f6c44b7571f8b2051699040f5f77636d44d4cae6c972ab597f
2024-09-23 18:32:23 +00:00
merge-script 387f94ce16
Merge rust-bitcoin/rust-bitcoin#3383: primitives: Move optional dependency to correct place
184dfbcdb6 primitives: Move optional dependency to correct place (Tobin C. Harding)

Pull request description:

  We keep optional deps in a separate group to non-optional deps, move the new `arbitrary` dependency.

  Internal change only.

ACKs for top commit:
  shinghim:
    ACK 184dfbcdb6
  apoelstra:
    ACK 184dfbcdb6 successfully ran local tests

Tree-SHA512: 8540ee9ce9663d60d1a8d08e94738c7a3e3341b640ec6cbc04c304cb12daa4c95ae6cd1e4ad9fde361065510b2e34c65f6f08db1ae305976fce4525aa98756a3
2024-09-23 17:37:31 +00:00
Fmt Bot 2009763ae5 2024-09-22 automated rustfmt nightly 2024-09-22 01:20:08 +00:00
merge-script 855c4bb754
Merge rust-bitcoin/rust-bitcoin#3364: Remove unused inports, and fix unused variables and methods in docs
f6abdcc001 Allow unused in `macros.rs` docs (Jamil Lambert, PhD)
fd89ddf401 Remove or fix unused variables and methods in docs (Jamil Lambert, PhD)
ff6b1d4f19 Remove unused variables and methods from docs (Jamil Lambert, PhD)
e58cda6f92 Remove `unused_imports` in docs (Jamil Lambert, PhD)

Pull request description:

  As mentioned in #3362 examples in documentation are not linted in the same way as other code, but should still contain correctly written code.

  #![doc(test(attr(warn(unused))))] has been added to all lib.rs files

  In the docs throughout all crates:

  - Unused imports have been removed.

  - Unused variables, structs and enums have been used e.g. with an `assert_eq!` or prefixed with `_`

  - Unused methods have been called in the example code.

ACKs for top commit:
  tcharding:
    ACK f6abdcc001
  apoelstra:
    ACK f6abdcc001 successfully ran local tests

Tree-SHA512: c3de1775ecde6971056e9fed2c9fa1621785787a6a6ccbf3a6dbd11e18d42d4956949f3f8adfc75d94fd25db998b04adb1c346cc2c2ba47f4dc37402e1388277
2024-09-20 02:10:51 +00:00
Tobin C. Harding 184dfbcdb6
primitives: Move optional dependency to correct place
We keep optional deps in a separate group to non-optional deps, move the
new `arbitrary` dependency.

Internal change only.
2024-09-19 08:36:20 +10:00
Jamil Lambert, PhD fd89ddf401
Remove or fix unused variables and methods in docs
Examples in documentation are not linted in the same way as other code,
but should still contain correctly written code.

Throughout all of the crates except internals (another commit) unused
variables have been prefixed with `_`, unused imports have been removed,
and a warn attribute added to all of the `lib.rs` files.
2024-09-18 16:37:47 +01:00
Tobin C. Harding 18110a51f2
Bump version of internals to 0.4.0
In preparation for releasing `internals v0.4.0` bump the version number,
add a changelog entry, update the lock files, and depend on the new
version in all crates that depend on `internals`.
2024-09-18 12:22:59 +10:00
Shing Him Ng 5b4e81b379 Implement Arbitrary for Transaction 2024-09-16 22:02:46 -05:00
merge-script 60e15b8007
Merge rust-bitcoin/rust-bitcoin#3194: priority: Prepare moving script types to `primitives`
8f2f4cbb3c Re-order optional dependencies (Tobin C. Harding)
95f2a8dab6 Do not access ScriptBuf inner from builder (Tobin C. Harding)
900af453ff Stop accessing inner ScriptBuf field when encoding (Tobin C. Harding)
8b82363d97 Use Script::as_bytes instead of inner when indexing (Tobin C. Harding)
b0675a4a4f Use Script::len instead of inner field (Tobin C. Harding)
374c6118dc Deprecate Script::fmt_asm and to_asm_str (Tobin C. Harding)

Pull request description:

  Move the `Script` and `ScriptBuf` types to `primitives`. There were still a few preparations required, things we had missed while creating the extension traits.

  Note also please, in the last patch, we enable `hex` from the `serder` feature. This is not the final state we want but like we did for `alloc` it is a step to reduce the size of the diff.

ACKs for top commit:
  Kixunil:
    ACK 8f2f4cbb3c
  apoelstra:
    ACK 8f2f4cbb3c successfully ran local tests

Tree-SHA512: 62a5f3c253ecb54d95c37fdc7eb955f3952909dc3bca20444b85c44665f54d5a0c48daf729bed0dd60ff3e9571b41deed039984c8b757b075ac6e136cacd17d7
2024-09-13 16:58:59 +00:00
Tobin C. Harding 0403e52ce3
Move the transaction hash types over to primitives
Move the `Txid` and `Wtxid` hash wrapper types over to `primitives`.
This introduces to `primitves` an unconditional dependency on
`hashes`.
2024-09-11 11:02:32 +10:00
Tobin C. Harding 8f2f4cbb3c
Re-order optional dependencies
The optional dependencies are ordered and separated by whitspace in a
manner that may not be obvious (or even have a reason).

Some of this is because since use of `?` deps changed name.

Put all the optional deps together in alphabetic order.
2024-09-11 10:50:18 +10:00
Fmt Bot 9a5ba9b6df 2024-09-08 automated rustfmt nightly 2024-09-08 01:17:12 +00:00
merge-script f6287fb445
Merge rust-bitcoin/rust-bitcoin#3287: Move `transaction::Version` to `primitives`
c48d9d6523 Move transaction::Version to primitives (Tobin C. Harding)
f490222068 Introduce the VersionExt trait (Tobin C. Harding)
fb89974b82 Run the formatter (Tobin C. Harding)
bb3a3ecbaa Introduce temporary module for Version (Tobin C. Harding)
1fde868f51 Separate Version impl blocks (Tobin C. Harding)

Pull request description:

  As per title, in tiny small chunks, move the `transaction::Version` over to `primitives`. Only the type, its associated consts, and its `Display` impl are moved. The two methods are left in an extension trait.

  Was originally attempted in #3253

ACKs for top commit:
  Kixunil:
    ACK c48d9d6523
  apoelstra:
    ACK c48d9d6523 successfully ran local tests

Tree-SHA512: 83415cf0762dca5c263deb743734fc7abede804a6daac31df3d0101b51c6261e6d54452eb744727ae680cacce9e4ef726a6fa253d86c4e7a5d8ec789b137566c
2024-09-04 01:21:43 +00:00
Tobin C. Harding c48d9d6523
Move transaction::Version to primitives
We would like to move the `Transaction` type to `primitives`, as a step
towards this move the `transaction::Version` and its trait imps (just
`Display`) over there.
2024-09-03 11:01:29 +10:00
Shing Him Ng 30bb93c676 Implement impl_to_hex_from_lower_hex macro for types that implement fmt::LowerHex 2024-08-31 22:41:40 -05:00
Tobin C. Harding e1e0230827
primitives: Enable alloc from serde
Currently the `serde` feature requires an allocator, this is a hang over
from code being written for the `bitcoin` crate.

This was not found because we are not testing `primitives` correctly in
CI (there is the `fuzz` bug and also `primitives` is not even in the
CRATES list).
2024-08-22 16:51:24 +00:00
Tobin C. Harding ce36a37d68
primitives: Test ordered feature
We forgot to add the `ordered` feature to `test_vars.sh`.
2024-08-22 16:51:24 +00:00
Fmt Bot ce3851d241 2024-08-18 automated rustfmt nightly 2024-08-18 01:12:19 +00:00
Tobin C. Harding 2ec901fd63
Move the CompactTarget type to primitives
Potentially the whole `pow` module will move to `primitives` but this
is not possible easily right now. However, we would like to be able to
move the `BlockHash` and `block::Header` types over to `primitives`
and doing so requires the `CompactTarget` to be there.

Move the `CompactTarget` type to `primitives` and re-export it from the
`primitives` crate root.

Note also, we re-export the type publicly from `bitcoin::pow`.
2024-08-13 05:29:22 +10:00
Tobin C. Harding 3d85ee3a02
primitives: Fix alloc feature
We have an `alloc` feature but we are unconditionally using
`extern crate alloc`, this is broken - clearly we need to add a `no-std`
build for `primitives` in CI.

Feature gate the `alloc` crate.

While we are at it just pull types in from `alloc` in the `prelude` - I
have no idea why we do not do this in `bitcoin`?
2024-08-13 05:23:10 +10:00
merge-script 15b87606bf
Merge rust-bitcoin/rust-bitcoin#3100: Bump MSRV to 1.63
c72069e921 Bump MSRV to 1.63 (Martin Habovstiak)

Pull request description:

  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. (Accompanying PR to secp256k1: https://github.com/rust-bitcoin/rust-secp256k1/pull/709 )

  Suggested plan:

  * merge both PRs
  * at some point release `hashes` and `secp256k`
  * remove `rand-std` from `bitcoin`
  * release the rest of the crates

ACKs for top commit:
  apoelstra:
    ACK c72069e921
  tcharding:
    ACK c72069e921

Tree-SHA512: 0b301ef8145f01967318d3ed1c738d33e6cf9e44f835f3762122b460a536f926916dbd6ea39d6f80b4f95402cd845e924401e75427dbb0731ca5b12b4fa6915e
2024-07-28 21:11:28 +00:00
Shing Him Ng 14fdffeb5a Fix typo in primitives Cargo.toml 2024-07-27 16:29:09 -05:00
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
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
Shing Him Ng 86f82b487d Remove unused variable from LockTime example 2024-07-15 17:03:12 -05:00
Tobin C. Harding 64c31cfb97
Move locktimes and Sequence to primitives
The `absolute` and `relative` locktimes as well as the `Sequence` are
all primitive bitcoin types.

Move the `Sequence`, and `locktime` stuff over to `primitives`.

There is nothing surprising here, the consensus encoding stuff stays in
`bitcoin` and we re-export everything from `blockdata`.
2024-07-15 08:53:51 +10:00
Tobin C. Harding dc96475f58
Add/fix alloc features
Eventually we would like all our crates other than `bitcoin` to be able
to be used without an allocator. Currently, and during crate smashing,
this is not that useful because so much of the code comes from `bitcoin`
and relies on the availability of an allocator.

As an initial step, add the `alloc` feature to `addresses` , `base58`,
and `primitives`.

In order to to keep `--no-default-features` builds working make the
crates empty if the `alloc` feature is not enabled. This is a suboptimal
solution because the error messages users will get when they forget to
enable `alloc` will be confusing (eg something like primitives does not
contain Transaction). However our CI script (`run_task.sh`) expects
`--no-default-features` to build cleanly (as do I).
2024-07-11 10:14:50 +10:00
Tobin C. Harding 9a586987d1
Move opcodes to primitives
Move the `opcodes` module to the new `primitives` crate. This is pretty
straight forward, some things to note:

- Are we ok with the public wildcard re-export from `blockdata`? I think
so because the whole `blockdata` module should, IMO, be deleted after
everything in it is moved to `primitives`.

- `decode_pushnum` becomes public.

Includes addition of a `patch` section for `primitives` in the
`bitcoin/embedded` crate.
2024-07-09 15:26:33 +10:00
Tobin C. Harding 65e9ad2fea
Introduce empty primitives crate
Introduce an empty `bitcoin-primitives` crate.

We were give the name on crates.io and previously a version
`v0.1.16-alpha` was released so we use `v0.100.0`.
2024-07-03 05:22:39 +10:00