Commit Graph

4716 Commits

Author SHA1 Message Date
Update Stable Rustc Bot e9ecc0989c Automated update to Github CI to rustc stable-1.81.0 2024-09-06 00:51:52 +00:00
merge-script 59f9518687
Merge rust-bitcoin/rust-bitcoin#3309: Automated daily update to rustc (to nightly-2024-09-04)
b60156321c Automated update to Github CI to rustc nightly-2024-09-04 (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 b60156321c

Tree-SHA512: 0d7227d52f58d09ef44882d5b1727c09c2949b5f0f6b7149bf14cf009cf55f995d9453c415280db33cb2b52e92396b59c97d0704671a70de7e6ba045ecf2bf35
2024-09-05 16:07:21 +10:00
Update Nightly Rustc Bot b60156321c Automated update to Github CI to rustc nightly-2024-09-04 2024-09-05 01:40:03 +00:00
merge-script e2ff08635e
Merge rust-bitcoin/rust-bitcoin#3294: units: Fix typo in measured
8f5bde9f17 units: Fix typo in measured (Tobin C. Harding)

Pull request description:

  Its "time is measured" not "time is measure".

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

Tree-SHA512: 5dfb7c1def9fb9cb8b51083e2c6d22ae1fab30002802a71d93818ddbe457bcb20998d0fc7235d6953f212a801e66f7f87b01f130d58b76098716ccdd05736c9e
2024-09-04 18:50:25 +00:00
Tobin C. Harding 8f5bde9f17
units: Fix typo in measured
Its "time is measured" not "time is measure".
2024-09-04 14:45:05 +10: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
merge-script 0123f2894c
Merge rust-bitcoin/rust-bitcoin#3267: Automated daily update to rustc (to nightly-2024-09-01)
eccd3c4a3d Automated update to Github CI to rustc nightly-2024-09-01 (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 eccd3c4a3d

Tree-SHA512: 448936db5b2d64204535af3707189e86945c58de239bf4ef861923fe2c0b24866945efd6ec4bcfd41b27bfa23fbbcfb91bb1d86111e795caf7edefa840341c45
2024-09-03 12:11:45 +10: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
Tobin C. Harding f490222068
Introduce the VersionExt trait
In preparation for moving the `transaction::Version` type to
`primitives`; add a `VersionExt` trait using our macro.
2024-09-03 10:57:58 +10:00
Tobin C. Harding fb89974b82
Run the formatter
Run `just fmt`. No manual changes.
2024-09-03 10:56:59 +10:00
Tobin C. Harding bb3a3ecbaa
Introduce temporary module for Version
In preparation for using the formatter to indent add a temporary module.
Done as part of adding an extension trait.
2024-09-03 10:56:06 +10:00
Tobin C. Harding 1fde868f51
Separate Version impl blocks
In preparation for adding an extension trait; separate the
`transaction::Version` impl blocks into stuff that will stay here and
stuff that will go to `primitives`.

Refactor only, no logic changes.
2024-09-03 10:54:48 +10:00
merge-script 3b057ad2f5
Merge rust-bitcoin/rust-bitcoin#3150: Create a macro that implements `to_hex` for types that have `core::fmt::LowerHex` implemented
30bb93c676 Implement impl_to_hex_from_lower_hex macro for types that implement fmt::LowerHex (Shing Him Ng)

Pull request description:

  Created a macro that implements `to_hex` for types that currently have `core::fmt::LowerHex` and called it on types that have `core::fmt::LowerHex` implemented. I put the macro in the `internals` crate since there are types across the whole project that can potentially use this.

  Resolves #2869

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

Tree-SHA512: d3ebc7b5c0c23f1a8f8eef4379c1b475e8c23845e18ce514cb1e98eb63fc4f215e6bc4425f97c7303053df13374ef931ae9d9373badd7ca1975a55b0d00d0e40
2024-09-02 21:18:44 +00:00
Andrew Poelstra b535102c1c Merge rust-bitcoin/rust-bitcoin#3201: CI: Generate `CRATES` using shell
90e073ef3e Set CRATES mechanically (Tobin C. Harding)

Pull request description:

  Instead of manually setting the crates list it is less error prone to do so mechanically. This required some changes to the `run_task` script which have now merged, so we update to use the new commit hash at the same time.

  - Use shell to set the `CRATES` env var used by `run_task.sh`.
  - Use latest revision of  rust-bitcoin-maintainer-tools
2024-09-02 19:07:49 +00:00
merge-script 6301272643
Merge rust-bitcoin/rust-bitcoin#3280: Remove bool from const_assert
c71b23d81d Remove bool from cont_assert (Tobin C. Harding)

Pull request description:

  It was correctly pointed out during review of #3215 (when we made `const_assert` panic) that using a `bool` added no additional information.

  Remove the `bool` and just use unit.

ACKs for top commit:
  apoelstra:
    ACK c71b23d81d successfully ran local tests; lol sure
  Kixunil:
    ACK c71b23d81d

Tree-SHA512: be9f4f10ee7d626a082b7ae9f257b79d500824ed3c1f7327391b2ad4d67e60d7da47a14fa7ef8f99d1ea8157967b4658518cbcf1c1bfcf1d8888455f3eb96437
2024-09-02 15:40:23 +00:00
merge-script 3bbe821ce5
Merge rust-bitcoin/rust-bitcoin#3268: Fix clippy rustdocs warnings
b6371b5801 Fix clippy rustdocs warnings (Tobin C. Harding)

Pull request description:

  A new nightly version (`nightly-2024-08-28`) introduces a few warnings because of our rustdocs. These are valid warnings and should be fixed, thanks `clippy` team.

  (The `bip152` change is a bit sloppy, open to suggestions.)

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

Tree-SHA512: 503fb9d48772b74a5acdb26c0f77a85c52323c03360f983204fccee0f28bedeff142237b067caa1ce6ea04ea9842cc493e0d06dc141ca00a98151fa002b62392
2024-09-02 14:20:44 +00:00
Update Nightly Rustc Bot eccd3c4a3d Automated update to Github CI to rustc nightly-2024-09-01 2024-09-02 01:41:22 +00:00
merge-script 9233eb2fa3
Merge rust-bitcoin/rust-bitcoin#3275: Enforce that `Hash::Bytes` is an array
be13397570 Make hmac & hkdf more robust against buggy `Hash` (Martin Habovstiak)
94c0614bda Enforce that `Hash::Bytes` is an array (Martin Habovstiak)

Pull request description:

  This makes sure `Hash::Bytes` is an array. We've discussed this somewhere but I don't remember where.

  I'm not sure if the second commit is actually valuable but hopefully shouldn't make things worse.

ACKs for top commit:
  apoelstra:
    ACK be13397570 successfully ran local tests; yep, this looks like an improvement. Agreed that the second commit has questionable value but doe not make things worse
  tcharding:
    ACK be13397570

Tree-SHA512: 0fed982084f0f98927c2b4a275cec81cb4bbc0efbf01551a0a4a8b6b39a4504830243ee8d55a5c0418d81b5d4babc7b22332dbacc0609ced8fada84d2961ae71
2024-09-02 00:42:39 +00:00
merge-script 6a06c023e0
Merge rust-bitcoin/rust-bitcoin#3276: fix: deprecate wrong and unused max script num
345d3daa72 fix: deprecate wrong and unused max script num (ChrisCho-H)

Pull request description:

  ~~Script number can be up to 2^39 - 1 to encode locktime.~~
  ~~If it's only for the integer operation besides locktime, it must be 2^31 - 1, not 2^31.~~

  I agree with apoelstra  opinion to deprecate this value.

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

Tree-SHA512: df4205415634d8db1412f16a75d1dbc110ed69930cefa085bdaa268a7fcaf47776dd1d8ed6965e6bbb476825b5f80e5c00bb375730ad102bae8868abe5894068
2024-09-02 00:01:32 +00:00
Tobin C. Harding 90e073ef3e
Set CRATES mechanically
Instead of manually setting the crates list it is less error prone to do
so mechanically. This required some changes to the `run_task` script
which have now merged, so we update to use the new commit hash at the
same time.

- Use shell to set the `CRATES` env var used by `run_task.sh`.
- Use latest revision of  rust-bitcoin-maintainer-tools
2024-09-02 09:21:19 +10:00
Tobin C. Harding c71b23d81d
Remove bool from cont_assert
It was correctly pointed out during review of #3215 (when we made
`const_assert` panic) that using a `bool` added no additional
information.

Remove the `bool` and just use unit.
2024-09-02 08:21:53 +10:00
merge-script af0c85c6e0
Merge rust-bitcoin/rust-bitcoin#3277: Automated weekly update to cargo-semver-checks (to 0.34.0)
7ecb8dfa98 Automated update to Github CI to cargo-semver-checks version-0.34.0 (Update cargo-semver-checks Bot)

Pull request description:

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

ACKs for top commit:
  tcharding:
    ACK 7ecb8dfa98

Tree-SHA512: b21c513ae0bfceee62f8415402f69347c10b25289246b1d9c742b7385871d1fbf526e7a56b41c83c1fc9b4152e8f1c257a7b2f41ab7d0cb71cedf6c358ea4dc2
2024-09-02 08:11:56 +10:00
ChrisCho-H 345d3daa72 fix: deprecate wrong and unused max script num 2024-09-01 22:14:39 +09:00
merge-script 0a3f5330a8
Merge rust-bitcoin/rust-bitcoin#3279: Automated nightly rustfmt (2024-09-01)
fa71b0e044 2024-09-01 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 fa71b0e044 successfully ran local tests; a bit big this week

Tree-SHA512: 875e8d54a06a22ccbef690a21f9d48a0acc1e6ea073a2d16632dd7ce63400cc7f2522339b7cb808653dade407517cd03d4fece4c8dec24abacf5303418aeaa75
2024-09-01 13:03:01 +00: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
merge-script d1e7116321
Merge rust-bitcoin/rust-bitcoin#3278: Show compressed public key in Debug for CompressedPublicKey
9db6234ea9 Show compressed public key in Debug for CompressedPublicKey (Jiri Jakes)

Pull request description:

  Currently `CompressedPublicKey` debug produces output of form:

  ```
  CompressedPublicKey(PublicKey(2f8b18dc0adcb73d75f7934d9523ea7347083e41c48115398cb37e295a0a6ffe86e0bf8b1ef65888c880c8d8813a30e69e466380cbe2daec18f3ed1e7a553ff2))
  ```

  Although it shows real internal structure together with inner uncompressed public key, it is not too helpful for the purpose of debugging _compressed_ public key.

  After this patch, `Debug` output will be equal to `Display` (it, in fact, delegates rendering to `Display`), prepended by the name of the struct:

  ```
  CompressedPublicKey(02fe6f0a5a297eb38c391581c4413e084773ea23954d93f7753db7dc0adc188b2f)
  ```

ACKs for top commit:
  Kixunil:
    ACK 9db6234ea9 unless other maintainers agree to drop the struct name.
  apoelstra:
    ACK 9db6234ea9 successfully ran local tests; we should keep the struct name since it is canonical for Debug output

Tree-SHA512: e2626678a4144357d3ff4ddd888459ae1283ea50bc7c8ef86deb9902d7d543de79109ac42883e5538f7e2f6a29426224bb43eb44a34f366821e47a9aca563753
2024-09-01 01:30:30 +00:00
Fmt Bot fa71b0e044 2024-09-01 automated rustfmt nightly 2024-09-01 01:22:04 +00:00
merge-script 753961fdb8
Merge rust-bitcoin/rust-bitcoin#3215: Improve const_assert
3c7c8c44b6 Improve const_assert (Tobin C. Harding)

Pull request description:

  Now that we can panic in const context we can improve the `const_assert` macro by adding a message string.

  Original idea by Kix:

    https://github.com/rust-bitcoin/rust-bitcoin/pull/2972#discussion_r1726328228

ACKs for top commit:
  Kixunil:
    ACK 3c7c8c44b6 in the sense that it does what it's supposed to with the only tiny issue being that the `bool` looks weird but not broken in any other way I can think of.
  apoelstra:
    ACK 3c7c8c44b6 successfully ran local tests

Tree-SHA512: 5ff721c0056f87d42c934818da6f780cd945f235291eb4b044752d67405a74f992d7f85853fec129e794ec3fcda1f319cc40daabc6a349d21bbdc977640d2572
2024-08-31 20:00:28 +00:00
merge-script 2a54c1c1f2
Merge rust-bitcoin/rust-bitcoin#3271: Move import inside feature gate
a184066660 Move import inside feature gate (Tobin C. Harding)

Pull request description:

  The `String` type is only used if the `serde` feature is enabled, move the import statement inside the already feature gated block.

ACKs for top commit:
  apoelstra:
    ACK a184066660 successfully ran local tests; sure
  Kixunil:
    ACK a184066660

Tree-SHA512: 688adb1e4489b0242856ac36ed9cf3503b147b84954cf1e6fd34b5e708ed6c1dd92da91e739243face1c1b4e4c8b19ce88e215117bef2a7af2e732859a6e108a
2024-08-31 18:22:51 +00:00
Jiri Jakes 9db6234ea9
Show compressed public key in Debug for CompressedPublicKey 2024-08-31 22:41:12 +08:00
Update cargo-semver-checks Bot 7ecb8dfa98 Automated update to Github CI to cargo-semver-checks version-0.34.0 2024-08-31 01:00:40 +00:00
merge-script c2e3e86106
Merge rust-bitcoin/rust-bitcoin#3274: Add Arbitrary to SignedAmount type
3f244db19d Add Arbitrary to SignedAmount type (yancy)

Pull request description:

  While proptesting, I've found Arbitrary for SingedAmount to be useful.  Would appreciate adding this as well.

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

Tree-SHA512: f293215505db85998135c75e147f4cb0031a08c7db619b706e6c7d632c6f23783af56992531396aecc6e3da55b107a7f2c7ec4d68a3e5737ebcf4225f306ed29
2024-08-30 20:08:17 +00:00
merge-script 904fefba5a
Merge rust-bitcoin/rust-bitcoin#3272: Fix bug in `ArrayVec::extend_from_slice`
4024ba5910 Add unit test for ArrayVec::extend_from_slice (Tobin C. Harding)
798c9cff1c Fix bug in ArrayVec::extend_from_slice (Tobin C. Harding)

Pull request description:

  Currently the source slice must be the exact length to fill the array to max capacity, this is an unnecessary restriction since an `ArrayVec` is a variable sized data structure.

  Set the destination slice to be the same length as the source slice (still maintain capacity checks).

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

Tree-SHA512: b7a510ba6f6e5cf5a535d691f79da98e29558eb9a50b60d41e080769560e9b9f0b8a831806dc9f159c888001951e17b5bbd970363d6a2e57fa9748902548b3ab
2024-08-30 16:45:10 +00:00
Martin Habovstiak be13397570 Make hmac & hkdf more robust against buggy `Hash`
Use the newly added requirement that `Hash::Bytes` is an array to
protect the implementation of hmac and hkdf against implementations that
would accidentally return slices of different sizes from the `AsRef`
impl.
2024-08-30 06:20:30 +02:00
Martin Habovstiak 94c0614bda Enforce that `Hash::Bytes` is an array
In the future we would like to guarantee the correctness of `LEN` which
is currently not entirely possible, so this at least adds a sealed trait
enforcing the `Bytes` type to be an array. Consumers concerned about the
validity of the length can access the `LEN` constant on `Bytes` instead
to get the correct length of the array.
2024-08-30 06:16:44 +02:00
yancy 3f244db19d Add Arbitrary to SignedAmount type 2024-08-29 20:19:48 -05:00
Tobin C. Harding 4024ba5910
Add unit test for ArrayVec::extend_from_slice
Test that we can extend an `ArrayVec` with a slice that is less than
remaining capacity.
2024-08-30 09:14:43 +10:00
merge-script 0d9e8f8c99
Merge rust-bitcoin/rust-bitcoin#3204: Do many cleanups (and bug fix)
dae42bef9d do not enable bitcoin-io by default (Antoni Spaanderman)
a14cdaf859 don't enable std by default when testing (Antoni Spaanderman)
e83830dcfc use slice instead of array to not have to hardcode the length (Antoni Spaanderman)
55749d6f61 use `hash.to_byte_array` to check equality with `test.output` (Antoni Spaanderman)
969864e3b0 use fixed size array if possible, otherwise `&'static [u8]` (Antoni Spaanderman)
28ccf70fa6 remove unnecesarry borrow operator (`&`) (Antoni Spaanderman)
fa3a3afd02 remove unnecessary slicing (Antoni Spaanderman)
22e42ab86c fix test code being unnecessarily feature gated (Antoni Spaanderman)

Pull request description:

  - remove 2 unnecessary cfg attributes from tests left over from  #3167 (it made them not dependent on `alloc` anymore)
  - simplify assertion logic by removing unnecessary conversions before comparing
  - make tests `no_std` compatible by adding imports to alloc or std
  - feature gate tests behind the `alloc` feature if they use anything from the alloc crate (like the `format!` macro)
  - `schemars` feature enables `alloc` because (for example) its trait wants implementations to return `String`
  - fix `bitcoin-io` always enabling when `std` is enabled (only useful if people depend on `hashes` only, `bitcoin` depends on `bitcoin-io` already)

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

Tree-SHA512: 622fd4963ef21530a98af89bcfc71abe8723aac12d363ab88d9bd30dcf2f75392711bec10e2901fab5f1a30e11897d1aae36e22892738aa1e5670166f91fddd4
2024-08-29 21:20:10 +00:00
Tobin C. Harding 3c7c8c44b6
Improve const_assert
Now that we can panic in const context we can improve the `const_assert`
macro by adding a message string.

Original idea by Kix:

  https://github.com/rust-bitcoin/rust-bitcoin/pull/2972#discussion_r1726328228
2024-08-30 06:33:31 +10:00
Tobin C. Harding b6371b5801
Fix clippy rustdocs warnings
A new nightly version (`nightly-2024-08-28`) introduces a few warnings
because of our rustdocs. These are valid warnings and should be fixed,
thanks `clippy` team.

(The `bip152` change is a bit sloppy, open to suggestions.)
2024-08-30 05:47:31 +10:00
Tobin C. Harding a184066660
Move import inside feature gate
The `String` type is only used if the `serde` feature is enabled, move
the import statement inside the already feature gated block.
2024-08-30 05:25:51 +10:00
Tobin C. Harding 798c9cff1c
Fix bug in ArrayVec::extend_from_slice
Currently the source slice must be the exact length to fill the array to
max capacity, this is an unnecessary restriction since an `ArrayVec` is
a variable sized data structure.

Set the destination slice to be the same length as the source
slice (still maintain capacity checks).
2024-08-30 03:03:12 +10:00
merge-script cfb53c7866
Merge rust-bitcoin/rust-bitcoin#3257: Add Arbitrary to Weight
f8edbd1f45 Add Arbitrary to Weight (yancy)

Pull request description:

  Adds Arbitrary to the Weight type.  I had meant to add this with the initial Arbitrary PR but I overlooked it.

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

Tree-SHA512: b886f78285b5cd06b2531a1e53272cad623a8e43e76e8108abe90668b45d00674b6a867c5ff980ee7f0a34919e1d6bb534624bd0bc67a53c8c9a41ea2ed504e8
2024-08-28 23:02:13 +00:00
merge-script 98252f36df
Merge rust-bitcoin/rust-bitcoin#3255: fix: re-implement `Psbt` (de)serialization from/to readers/writers
cf129ad314 fix: re-implement (de)serialization from/to readers/writers (elsirion)

Pull request description:

  Fixes #3250.

  The serialization is less than ideal and still allocates a lot. I can understand not wanting to (ab)use the consensus encoding traits, but they have a pretty good interface, copying it and creating some `EncodePsbt` and `DecodePsbt` traits with similar interfaces would have been nice imo.

ACKs for top commit:
  Kixunil:
    ACK cf129ad314
  apoelstra:
    ACK cf129ad314 successfully ran local tests; LGTM -- I believe this is non-breaking, as does cargo-semver-checks, so we can backport this to 0.32

Tree-SHA512: d7f218164d772db3a9fb4436953c3b5fd3677b92078d0843233197629df7d852d80615a3ff38c5b70771381ba1aeb30defdc98ee63653e570bb75dc553400cad
2024-08-28 22:26:07 +00:00
merge-script fdeac2bced
Merge rust-bitcoin/rust-bitcoin#3262: Change `T::from_str(s)` to `s.parse::<T>()` in examples, docs and tests
9fce57b738 Change T::from_str(s) to s.parse::<T>() in tests (Jamil Lambert, PhD)
4ad86148c7 Change Address::from_str(s) to s.parse (Jamil Lambert, PhD)
64e668f99e Change from_str(s) to parse::<T>() in Examples (Jamil Lambert, PhD)
c835bb9eab Change T::from_str(s) to s.parse::<T>() in docs (Jamil Lambert, PhD)

Pull request description:

  This PR follows on from #3256 changing `T::from_str(s)` to `s.parse::<T>()` in the rest of the repository, i.e. in examples, docs and tests that were not done in the previous PR.

  Address was done in a separate patch because the formatting was different and required a different macro to make the change.  Also in the rustdocs it gives 3 variants for parsing strings to addresses (`bitcoin/src/address/mod.rs` ll266-301) and I chose variant 3, but I can change to 1 if preferred.
  ``` rust

  // variant 1
  let address: Address<NetworkUnchecked> = "32iVBEu4dxkUQk9dJbZUiBiQdmypcEyJRf".parse().unwrap();
  let address: Address<NetworkChecked> = address.require_network(Network::Bitcoin).unwrap();

  // variant 2
   let address: Address = Address::from_str("32iVBEu4dxkUQk9dJbZUiBiQdmypcEyJRf").unwrap()
                  .require_network(Network::Bitcoin).unwrap();

  // variant 3
  let address: Address<NetworkChecked> = "32iVBEu4dxkUQk9dJbZUiBiQdmypcEyJRf".parse::<Address<_>>()
                 .unwrap().require_network(Network::Bitcoin).unwrap();
  ```

  Issue #3234 still needs `contributing.md` to be updated before closing.

ACKs for top commit:
  Kixunil:
    ACK 9fce57b738
  apoelstra:
    ACK 9fce57b738 successfully ran local tests; whew!

Tree-SHA512: 1e8abfa4a62c681c902827b8a7503ed5a10721c0adc68a97701ab00923dea7d62049ba530609b8bc6590209ad2e11698a761453c00f80965835677f6d3a7aee3
2024-08-28 20:47:50 +00:00
Jamil Lambert, PhD 9fce57b738
Change T::from_str(s) to s.parse::<T>() in tests
`s.parse` is more idiomatic and produces more helpful error messages.

This has been changed repo wide in tests.
2024-08-28 16:13:03 +01:00
Jamil Lambert, PhD 4ad86148c7
Change Address::from_str(s) to s.parse
`s.parse` is more idiomatic and produces more helpful error messages.

This has been changed for parsing a string as an `Address`.
2024-08-28 13:50:43 +01:00
Jamil Lambert, PhD 64e668f99e
Change from_str(s) to parse::<T>() in Examples
`s.parse` is more idiomatic and produces more helpful error messages.

This has been changed in examples.
2024-08-28 13:50:43 +01:00
Jamil Lambert, PhD c835bb9eab
Change T::from_str(s) to s.parse::<T>() in docs
`s.parse` is more idiomatic and produces more helpful error messages.

This has been changed repo wide in docs.
2024-08-28 13:50:42 +01:00
merge-script e048b7b003
Merge rust-bitcoin/rust-bitcoin#3256: Change `T::from_str(s)` to `s.parse::<T>()`
a76d76eca1 Change `T::from_str(s)` to `s.parse::<T>()` (Jamil Lambert, PhD)

Pull request description:

  As mentioned in issue #3234 `s.parse::<T>()` is more idiomatic and produces more helpful error messages.

  This has been changed in the main codebase, not including examples, rustdocs, and in the `test` modules.

  `use std::str::FromStr;` has been removed where this change makes it unnecessary.

  To close the issue it may also need to be changed in the examples and the `test` modules and `contributing.md` updated.

ACKs for top commit:
  Kixunil:
    ACK a76d76eca1
  storopoli:
    ACK a76d76eca1
  tcharding:
    ACK a76d76eca1

Tree-SHA512: 18be389579b5c2d0ba567dfb02b9c8d71c108a749ec5168c60a50e7af9d7f498e364c8f4c0ce1698d960e7d146486899cd10214ebc9c96708ed158a04dfff425
2024-08-28 12:47:16 +00:00