Commit Graph

6702 Commits

Author SHA1 Message Date
Tobin C. Harding a18d28761b
api: Run just check-api 2025-01-06 17:13:49 +11:00
Tobin C. Harding 1175faca32
io: Introduce api test file
Introduce an `io/tests/api.rs` file to test the API surface of the `io`
crate. In doing so fix C-DEBUG and prove C-DEBUG-NONEMPTY.

C-DEBUG: https://rust-lang.github.io/api-guidelines/debuggability.html#c-debug
2025-01-06 17:13:49 +11:00
Tobin C. Harding 01f3eefc12
io: Move bridge type constructors
Put the constructors at the top of the impl block.

Code move only.
2025-01-06 15:32:46 +11:00
Tobin C. Harding a8fbd5e302
units: Remove api docs
These docs a way too prone to going stale; we only wrote these a week
ago and they are stale already.

Lets just remove them.
2025-01-06 15:32:10 +11:00
Tobin C. Harding aaa20fc098
units: Move code comment to correct imports
This comment is meant to be on top of the `bitcoin_units` imports.
2025-01-06 15:32:10 +11:00
merge-script b0ec566742
Merge rust-bitcoin/rust-bitcoin#3855: io: Use get_ref / get_mut API
12a83e1bf3 api: Run just check-api (Tobin C. Harding)
88dfd4e8f2 io: Use get_ref / get_mut API (Tobin C. Harding)
b7fdb359e7 io: Move constructors (Tobin C. Harding)

Pull request description:

  Currently in the `bridge` module to get a reference and mutable reference we provide the `as_inner` and `inner_mut` functions. These names are not in line with the `std::io` module which favours `get_ref` and `get_mut`.

  Add inherent functions `get_ref` and `get_mut` for accessing the wrapped value in `bridge::ToStd` and deprecate `as_inner` and `inner_mut`.

  To convince yourself this API is correct grep the stdlib `io` module for `fn get_ref` as opposed to `fn as_ref`.

  Patch 1 is a trivial code move cleanup.

  Close: #3832

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

Tree-SHA512: a5ebd806a4914aca050746ffca4930dc0a5bbeffd0d2fdb000af3bebd4d932cb08ec68acd18cd0a8a9cecf3cb7a211e066ebfd2fd62aaf40c5b4b5348e39e6d4
2025-01-06 03:34:33 +00:00
Tobin C. Harding 0e5d6db7df
units: Don't ignore serde examples
There is no reason to ignore the rustdoc example in
`units::amount::serde`. The `as_btc` function requires the `alloc`
features so use `as_sat` in the example instead.

While we are at it clean up the whole block of rustdocs.
2025-01-06 13:45:01 +11:00
Tobin C. Harding a7c44cebf9
Use _unchecked to construct amounts
We have a `_unchecked` constructor now for both `Amount` and
`SignedAmount`. In preparation for enforcing the `MAX_MONEY` invariant
use the `_unchecked` constructor throughout the codebase to construct
amounts from hard coded integer values.
2025-01-06 13:14:21 +11:00
Tobin C. Harding 09df951760
Use sat variable in tests
As we do in other places use a local variable for the `Amount`
constructor.

Refactor only, no logic change.
2025-01-06 13:14:19 +11:00
Tobin C. Harding 4a5b2c60c6
Use ssat variable in tests
As we do in other places use a local variable for the `SignedAmount`
constructor.

Refactor only, no logic change.
2025-01-06 13:13:31 +11:00
merge-script 33d70529bd
Merge rust-bitcoin/rust-bitcoin#3854: Add parenthesis to explicitly show precedence
2c9fda4135 Add parenthesis to explicitly show precedence (Tobin C. Harding)

Pull request description:

  Recent clippy nightly update introduces warnings about precedence. While ours are, IMO, clear the lint docs have some cases that are not so I don't think we should ignore this lint. Specifically I could easily miss this one

    1 << 2 + 3 equals 32, while (1 << 2) + 3 equals 7

  ref: https://rust-lang.github.io/rust-clippy/master/#/precede

  Add parenthesis to explicitly show precedence. Refactor only no logic changes.

ACKs for top commit:
  apoelstra:
    ACK 2c9fda413572e251fe3fd07f679b6c786da137b3; successfully ran local tests; yeah, these all seem reasonable

Tree-SHA512: 67b8cb56c0b271d41db58f9297e4be43410c04bf7bc2308789624084e5e9fee325a2eb3be7e56bd6b3904cf19c7a8b1b426e7adef7f4af18ea8c9d24b77a9db9
2025-01-05 21:37:46 +00:00
merge-script 681de7aa17
Merge rust-bitcoin/rust-bitcoin#3840: Address mutants in units
286bf900b1 Address mutants in units (Shing Him Ng)

Pull request description:

  Preemptively addressing these mutants before introducing the `cargo-mutants` workflow. There are several types of changes:
  - Changes that address mutants that were actually missing
  - Changes that address test values that cause `cargo-mutants` to think mutants were missed. For example, `cargo-mutants` will replace the return values for unsigned integer types with 0 and 1. While this case might be tested, the test might be testing this with a call that results in 0 or 1. When `cargo-mutants` substitutes the function call with `Ok(1)`, the test will still pass, and it will consider this a mutant. `cargo-mutants` also replaces operations (+, -, /, %), bitwise operations (&, |, ^, etc), so an operation such as `3 - 2` results in a mutant because changing it to `3 / 2` yields the same result
  - TODOs to ignore functions/impls in the future

  I uased the following `mutants.toml` config file when running `cargo mutants` and skipped the `Debug`, `Arbitrary`, `Display`, and `Error` impls and the `kani` test:
  ```
  additional_cargo_args = ["--all-features"]
  examine_globs = ["units/src/**/*.rs"]
  exclude_globs = ["units/src/amount/verification.rs"]
  exclude_re = ["impl Debug", "impl Arbitrary", "impl Display", ".*Error", "<impl Visitor for VisitOptAmt<X>>"]
  ```

  I wasn't sure the code for Displaying things needed to be tested with `cargo mutants`, but I'm less sure about the errors so i can kill those mutants too if needed

ACKs for top commit:
  tcharding:
    ACK 286bf900b1
  apoelstra:
    ACK 286bf900b1c100d2f5d0a0d45f31a5bf5a0a26ce; successfully ran local tests

Tree-SHA512: 3db9598a5ad92f2013d43876221ce9363cc019cbf720a206768b517a812c8355b7f00594212eb0526c0feb2dc578f88e1df12548f72a2b2360c4d4227de749f7
2025-01-05 19:18:50 +00:00
merge-script f3e56f1c95
Merge rust-bitcoin/rust-bitcoin#3857: Automated nightly rustfmt (2025-01-05)
762f6630fe 2025-01-05 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 762f6630fe22e54e5a8b2839054e2e09a5a2db64; successfully ran local tests

Tree-SHA512: 5be013a53697ab2c3f5bb6da8c1c45124d4fee696a655544bb7fad3d28606638a639932d05a990d7e1ae7d91bcc85eb9bc136145a241b39b9089b2e7dc10f5a5
2025-01-05 18:41:02 +00:00
merge-script 8458ca5167
Merge rust-bitcoin/rust-bitcoin#3850: Fix typo in MerkleBlock::from_block_with_predicate comment
d5de89259b Fix typo in MerkleBlock::from_block_with_predicate comment (Jesus Christ)

Pull request description:

  - Corrected a grammatical error by adding "are" to the comment in MerkleBlock::from_block_with_predicate.

ACKs for top commit:
  clarkmoody:
    ACK d5de89259b
  apoelstra:
    ACK d5de89259b64ed6d4756973073f06172d1d14090; successfully ran local tests
  storopoli:
    ACK d5de89259b

Tree-SHA512: 55595e8858e90ee5ab5ef7d592cf2c47dc593f303f3f60040f1612d92abcf4a4d0f9c9ad3bf7eece54f3078a3ab8ff92b36357be58db0919888e239a8a5c1a6b
2025-01-05 16:08:50 +00:00
Shing Him Ng f94c7185fd Remove usage of impl_from_infallible in 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 the bitcoin, units, and internals crates
and just write the code.
2025-01-04 23:46:12 -06:00
Tobin C. Harding cf455d3a06
Fix typo in prifixes
Close: #3856
2025-01-05 12:36:56 +11:00
Fmt Bot 762f6630fe 2025-01-05 automated rustfmt nightly 2025-01-05 01:22:00 +00:00
Tobin C. Harding 12a83e1bf3
api: Run just check-api 2025-01-04 15:53:12 +11:00
Tobin C. Harding 88dfd4e8f2
io: Use get_ref / get_mut API
Currently in the `bridge` module to get a reference and mutable
reference we provide the `as_inner` and `inner_mut` functions. These
names are not in line with the `std::io` module which favours `get_ref`
and `get_mut`.

Add inherent functions `get_ref` and `get_mut` for accessing the wrapped
value in `bridge::ToStd` and deprecate `as_inner` and `inner_mut`.

To convince yourself this API is correct grep the stdlib `io` module for
`fn get_ref` as opposed to `fn as_ref`.

Close: #3832
2025-01-04 15:43:35 +11:00
Tobin C. Harding b7fdb359e7
io: Move constructors
Put all the constructors together.

Internal change only.
2025-01-04 15:38:03 +11:00
Tobin C. Harding 2c9fda4135
Add parenthesis to explicitly show precedence
Recent clippy nightly update introduces warnings about precedence. While
ours are, IMO, clear the lint docs have some cases that are not so I
don't think we should ignore this lint. Specifically I could easily miss
this one

  1 << 2 + 3 equals 32, while (1 << 2) + 3 equals 7

ref: https://rust-lang.github.io/rust-clippy/master/#/precede

Add parenthesis to explicitly show precedence. Refactor only no logic
changes.
2025-01-04 15:25:00 +11:00
merge-script b97be3d497
Merge rust-bitcoin/rust-bitcoin#3851: Automated weekly update to cargo-semver-checks (to 0.38.0)
ab8017d6b3 Automated update to Github CI to cargo-semver-checks version-0.38.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 ab8017d6b3

Tree-SHA512: 568d90367d6251f2f4ad6c5d43b304290db1d903fb43ed98cd4fb1daeb297080f9bf587f32c9d3aa6b5df2ec27b0296935ac2386524eeee78e36e2cc1e976899
2025-01-04 15:11:26 +11:00
Shing Him Ng 286bf900b1 Address mutants in units
Preemptively addressing these mutants before introducing the
cargo-mutants workflow

There are several types of changes:
- Changes that address mutants that were actually missing
- Changes that address test values that cause `cargo-mutants` to think
  mutants were missed. For example, `cargo-mutants` will replace the
return values for unsigned integer types with 0 and 1. While a function
might be tested, the test might be testing the function with a call that
results in 0 or 1. When `cargo-mutants` substitutes the function call
with `Ok(1)`, the test will still pass, and it will consider this a
mutant.  `cargo-mutants` also replaces operations (+, -, /, %), bitwise
operations (&, |, ^, etc), so an operation such as `3 - 2` results in a
mutant because changing it to `3 / 2` yields the same result
- TODOs to ignore functions/impls in the future
2025-01-03 21:17:20 -06:00
merge-script 72cc88d907
Merge rust-bitcoin/rust-bitcoin#3847: ParsePublicKeyError using hex::InvalidCharError
945fcd0920 fix ParsePublicKeyError using hex::InvalidCharError (Innocent Onyemaenu)

Pull request description:

  Replaced the InvalidChar variant u8 with hex::InvalidCharError

  Resolves #3835

  changed InvalidChar variant of the ParsePublicKeyError from `u8` to `hex::InvalidCharError`

  ```
  pub enum ParsePublicKeyError {
      ...
      /// Hex decoding error.
      InvalidChar(hex::InvalidCharError),
      ...
  }

  Also,

  modified the test cases to accommodate the new variant

  Why:
  - hex::InvalidCharError includes both the invalid character and its position.
  - This improves debugging and makes error messages more actionable.

ACKs for top commit:
  apoelstra:
    ACK 945fcd09209120ef8869a2e4165e866328cc9bd5; successfully ran local tests; I like it
  clarkmoody:
    utACK 945fcd0920

Tree-SHA512: c13446c099cb02b4f253f9cc559a860aff3288a2cc5eac96d3cf910bf63e78957741bbdff69b936b16b36e46b366841a5c94876d16cbc0c41aea2a70866a6e45
2025-01-04 01:05:04 +00:00
Update cargo-semver-checks Bot ab8017d6b3 Automated update to Github CI to cargo-semver-checks version-0.38.0 2025-01-04 01:04:22 +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
Jesus Christ d5de89259b
Fix typo in MerkleBlock::from_block_with_predicate comment
- Corrected a grammatical error by adding "are" to the comment in MerkleBlock::from_block_with_predicate.
2025-01-03 21:00:13 +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
merge-script e8a52ccf8f
Merge rust-bitcoin/rust-bitcoin#3784: units: Document public macros
b1399d193f units: Improve rustdocs on macros (Tobin C. Harding)
706c7c9f5f Hide impl_tryfrom_str (Tobin C. Harding)
2675cd1040 units: Re-order impl_parse_str (Tobin C. Harding)
4cc7aae6b9 Hide impl_tryfrom_str_from_int_infallible (Tobin C. Harding)
fc9e40ab1a units: Re-order impl_parse_str_from_int_infallible (Tobin C. Harding)

Pull request description:

  Document the public macros in `units::parse`. Done as part of #3632

  First 2 patches are trivial preparatory refactor.

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

Tree-SHA512: e2b0196adb37b3616963e3e3ded1c2be95f98fe33a4e6edb269b7eca1ddb66b82be139f4edb3269a5cf69a73b3c803845fe83a5f6e300b08abf9fcb0da602084
2025-01-03 17:12:09 +00:00
merge-script 6501b0d781
Merge rust-bitcoin/rust-bitcoin#3666: Implement serde modules for `FeeRate`
f5eb8f4747 api: Run just check-api (Tobin C. Harding)
472b1d3ff3 units: Add serde regression test (Tobin C. Harding)
dedae8acf2 Implement custom serde modules for FeeRate (Tobin C. Harding)
d94e5f03e6 Move fee_rate.rs to module (Tobin C. Harding)
c3c1f6f82d Add missing license comment to test file (Tobin C. Harding)

Pull request description:

  Implement and enforce explicit unit when serializing. This is as we do for `Amount` (see #3672 for similar).

  To test it, and as part of the 1.0 effort; add regression tests for `serde` stuff in `units`.

  With this applied one must use attributes to serialize `FeeRate`.

  ```rust
      #[derive(Serialize, Deserialize)]
      pub struct Foo {
          #[serde(with = "bitcoin_units::fee_rate::serde::as_sat_per_kwu")]
          pub fee_rate: FeeRate,
      }
  ```

ACKs for top commit:
  apoelstra:
    ACK f5eb8f4747a7cd303cad2b7f8f442bb31862c52a; successfully ran local tests; great idea!

Tree-SHA512: 0968ead568b1e3142efd4c0e856192ddde0f441de84215cbb0950b60a56922f1abaf6d4ccfe243b722a6883c0a927d26bcfba979acf3ca84c4f21baba73af764
2025-01-03 16:31:34 +00:00
Innocent Onyemaenu 945fcd0920 fix ParsePublicKeyError using hex::InvalidCharError
What:
- Replaced the InvalidChar variant u8 with hex::InvalidCharError

Why:
- hex::InvalidCharError includes both the invalid character and its position.
- This improves debugging and makes error messages more actionable.
2025-01-03 15:33:26 +01: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
merge-script 21d435cf84
Merge rust-bitcoin/rust-bitcoin#3836: Update to rust-ordered 0.4.0
1a8f5b19fb Update to rust-ordered 0.4.0 (Tobin C. Harding)

Pull request description:

  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`.

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

Tree-SHA512: 823962a9e6b956126c7ff7a63b780431e358a9f0713f30e3801de3febea1e1e569b8ba3f6e3c0dc3c38759ac233c3d0ddea2223588cd796db6849fae8b599e04
2025-01-01 16:52:11 +00:00
merge-script 16b522043d
Merge rust-bitcoin/rust-bitcoin#3789: Add hash data to Inventory's Error variant
72e97c637f Add a hash value to Inventory's Error variant (Nick Johnson)

Pull request description:

  I am working on adding BIP324 V2 p2p network message support to the p2p module and ran into a little snag. I can post a draft branch of that work if helpful, but the general strategy is to add a `V2NetworkMessage` which operates in parallel with the existing `RawNetworkMessage` type (which is a bit of misnomer and may be better described in the future as `V1NetworkMessage`, see #3157). This allows both p2p message types to hook into the existing `Encodable`/`Decodeable` chain.

  But the `Error` variant of the `Inventory` type message does not have symmetrical encoding and decoding paths. Encoding writes out a zero'd 32 bytes while decoding ignores it completely. And while it is not clear to me if there is [requirement written down](https://en.bitcoin.it/wiki/Protocol_documentation#Inventory_Vectors) anywhere, [bitcoin core does appear to always expect a hash](c1252b14d7/src/protocol.h (L499)) even with the `Error` variant where it is meaningless.

  I believe rust-bitcoin's handling of this was never a problem before because the top level `RawNetworkPackage` pulls all the required bytes off a reader before decoding them. But this is not as easy to do with the v2 p2p network messages since the length is decoded at the transport level, not the message itself. I believe it is preferable for the Decoders to *not* assume that all bytes have been pulled off already given their input stream interface. Maybe somewhat surprisingly, this is the only issue I have run into so far adding the v2 encoding and decoding paths. As it is now, the code panics with an `Unconsumed` because it hasn't pulled the dummy zero bytes off the reader.

  This patch adds the 32 byte array to the Error variant in order to make its Encoding and Decoding paths symmetrical. This also allows a reader to discard the 32 bytes when decoding a message while cleanly keeping things hooked up with the `Decodeable` chain. The hash is still not exposed to the caller.

  This is *a way* to solve my issue, but not sure if it will cause more confusion than its worth. I tried a few other strategies, but preferred this one due to how well it hooks into `Decodeable`.

ACKs for top commit:
  apoelstra:
    ACK 72e97c637fa0916be75aef28ea8169ffbbe2c4f5; successfully ran local tests
  tcharding:
    ACK 72e97c637f

Tree-SHA512: 20cb9fec0768e0fdf7c7f520a00e1a37f5ef0583e2ebc7d47583249c6829c47826d83694a56338efa5844a9fe264a77f6d04c0c46c85f8732c7585515723d7ce
2024-12-31 14:08:25 +00:00
Tobin C. Harding b1399d193f
units: Improve rustdocs on macros
Extensively document the two _real_ public macros (not the helpers) in
`units::parse`.
2024-12-31 13:03:17 +11:00
Tobin C. Harding 706c7c9f5f
Hide impl_tryfrom_str
This macro is a helper for `impl_parse_str` used to reduce code
duplication. It does not, and should not, need to be part of the public
API - hide it.
2024-12-31 13:03:16 +11:00
Tobin C. Harding 2675cd1040
units: Re-order impl_parse_str
We have a public macro `impl_parse_str` and a helper macro used by it,
both pubicly exported.

As we did for `impl_parse_str_from_int_infallible`; to assist readers
understanding what is going on put the helper below the other.

Done as a separate patch to make the diff easier to read.

Internal change only, no logic change.
2024-12-31 13:01:51 +11:00
Tobin C. Harding 4cc7aae6b9
Hide impl_tryfrom_str_from_int_infallible
This macro is a helper for `impl_parse_str_from_int_infallible` used to
reduce code duplication. It does not, and should not, need to be part of
the public API - hide it.
2024-12-31 13:01:21 +11:00
Tobin C. Harding fc9e40ab1a
units: Re-order impl_parse_str_from_int_infallible
We have a public macro `impl_parse_str_from_int_infallible` and a helper
macro used by it, both pubicly exported.

To assist readers understanding what is going on put the helper below
the other.

Code move only, no logic change.
2024-12-31 12:59:35 +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
merge-script 4cd7a5e708
Merge rust-bitcoin/rust-bitcoin#3821: api: Include generics in regex
7f2cf1dce8 api: Include generics in regex (Tobin C. Harding)

Pull request description:

  The regex is still wrong, it misses structs with generics.

  Currently `contrib/api.sh io types` returns:

  ErrorKind
  Error
  Sink

  But with this patch applied it returns:

  FromStd<T>
  ToStd<T>
  ErrorKind
  Cursor<T>
  Error
  Sink
  Take<'a, R: bitcoin_io::Read + ?core::marker::Sized>

  Thanks ChatGPT, good robot.

ACKs for top commit:
  storopoli:
    ACK 7f2cf1dce8
  apoelstra:
    ACK 7f2cf1dce8236c60931f729748c487d401878067; successfully ran local tests; nice!

Tree-SHA512: 92fde9788edf8bf3e9b0639aec0aa0c4d7509c46cb048505e8018af57d671e893dccb7e0e018246438cceeb9c64232b8a0639bfe1ee7a35983b9e2bf1f2d4a4a
2024-12-30 21:55:31 +00:00
merge-script 7497c282eb
Merge rust-bitcoin/rust-bitcoin#3828: Update to latest `rust-ordered`
20b798175c Update to latest rust-ordered (Tobin C. Harding)

Pull request description:

  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`.

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

Tree-SHA512: b21608ad1992df3a0c5c93a454c08c8e3fab4d9e10c2f05ee2d929e585134ad26045f707f77083e6b6c3952dd04e611db7a35389ffe8fd487acad5344e9d36f3
2024-12-30 20:12:34 +00:00
merge-script 0ac5b43040
Merge rust-bitcoin/rust-bitcoin#3823: Improve Cursor ref API
ae129d84ac api: Run just check-api (Tobin C. Harding)
3f433f1cde Improve Cursor ref API (Tobin C. Harding)

Pull request description:

  Our `Cursor` is a replacement of sorts for the `std::io::Cursor`. Users of the `Cursor` are likely to expect the same API so to get a reference and/or mutable reference users will likely reach for `get_ref` and `get_mut`. We should provide these.

  Deprecate `inner` since it is the same as `get_ref` but less idiomatically named (should have been `as_inner`).

  Add `get_ref` and `get_mut` methods to the `Cursor` type.

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

Tree-SHA512: 664d08cc977c9d6e3319767c49bbabc8f21d681d570f50c514797a7737469cf861af60158ccc1c71d28baed542dabbbca586968144d60691ee0183a549a7b765
2024-12-30 18:13:29 +00:00
merge-script 13c066e195
Merge rust-bitcoin/rust-bitcoin#3811: Introduce an unchecked constructor for the `Amount` type
2042d91be5 api: Run just check-api (Tobin C. Harding)
04bae4bb91 Use _unchecked in unit tests (Tobin C. Harding)
8e6784dd41 Introduce Amount::from_sat_unchecked (Tobin C. Harding)
f32af7dac6 Use ua_sat throughout test function (Tobin C. Harding)
75f0afd0a3 Add local variable to use as constructor (Tobin C. Harding)
940a244132 Replace Amount::from_sat(0) with ZERO (Tobin C. Harding)

Pull request description:

  This is a small-ish changeset in order to mirror what was started in #3769 and reduce the diff in #3794

  - Patch 1: Trivial refactor to use `Amount::ZERO`.
  - Patch 2: Add the constructor and refactor a single unit test to use it.
  - Patch 3: Use the two `_unchecked` constructors throughout `units/src/amount/tests.rs`.
  - Patch 4: Add the API text file changes.

ACKs for top commit:
  jamillambert:
    ACK 2042d91be5
  apoelstra:
    ACK 2042d91be59a1d47afb986cef0152f9b5250f476; successfully ran local tests

Tree-SHA512: 8f9c3816509bb3fc0707cd4a47426130d001358e82273457b24170522644e10fe36b596e16500ce1778738f5546dfad592f1f3c4de552ec0afcb146442176cf5
2024-12-30 15:00:36 +00: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
merge-script 148b8b19dd
Merge rust-bitcoin/rust-bitcoin#3819: hashes: Hide both macros
87293dfdd3 api: Run just check-api (Tobin C. Harding)
ed387e5f1d hashes: Hide both macros (Tobin C. Harding)

Pull request description:

  We have two macro definitions feature gated on `serde`. At some stage we added the `doc(hidden)` attribute to one of them but forgot to add it to the other. This technically makes our features non-additive. This macro is "internal" so its unlikely that this is being used in the wild.

  Add `doc(hidden)` to the `serde_impl` macro that is missing it.

  Found by `cargo semver-checks` after recent upgrade to 0.38

ACKs for top commit:
  storopoli:
    ACK 87293dfdd3
  apoelstra:
    ACK 87293dfdd38be71938ae9d6a9981eb4569de3521; successfully ran local tests

Tree-SHA512: 3773eb42684bce56928f2d3f87993d010dd36634fda8dfa6b18b27a36b6c4bb521d711340a4868270dbd2d0c6a11715f9a1998ff3deb6900bd4227a44722a11e
2024-12-29 21:25:54 +00:00