Commit Graph

5522 Commits

Author SHA1 Message Date
Tobin C. Harding 4ef06b4f2b
Remove ToU64 from rustdocs
The `ToU64` trait is not meant to be used publicly, remove the mention
of it from rustdocs.
2024-12-13 09:00:53 +11:00
Tobin C. Harding 3ac9b2ded2
Remove unnecessary type
`hex_psbt` returns `Psbt`, no need for the explicit type.

Internal change only.
2024-12-13 09:00:41 +11:00
Tobin C. Harding 870bd49123
readme: Fix the MSRV link
The link is broken, has the wrong date in it.
2024-12-13 09:00:32 +11:00
Tobin C. Harding 99e2a9f530
Remove unnecessary rustdocs
The `deprecated` attribute already fully explains the status of a
deprecated function and the replacement - no need to repeat this.
2024-12-13 09:00:20 +11:00
Tobin C. Harding 55092aab47
Use Self in amount consts
Currently the consts in the `amount` modules repeat the type. For
`Amount` this isn't a big deal but for `SignedAmount` its quite noisy.

Use `Self` as the type in const declarations inside `Amount` and
`SignedAmount`.

Internal change, no logic changes.
2024-12-13 08:59:31 +11:00
merge-script ea6bf12a64
Merge rust-bitcoin/rust-bitcoin#3725: Rename private module to sealed
7725ca77c5 Rename private module to sealed (Tobin C. Harding)

Pull request description:

  There are two `private` modules in `amount` but they do slightly different things. One provides a private `Token` and one is for trait sealing. We have various other trait sealing modules in the codebase and they are all called `sealed` not `private`. Also the seal trait is called `Sealed`.

  Rename the `private` module and the trait to be uniform with the rest of the codebase.

ACKs for top commit:
  apoelstra:
    ACK 7725ca77c589a5215c50f1634f1b095d3e268540; successfully ran local tests; sure

Tree-SHA512: 5953686d7d22daaad8d2d59eff2338db3bb2a7765a37c08ed02ae1a4622509d628dbcb971781a6e85d750afa58609f5b058dfce6d5b4066f4f0d8ded45375b5b
2024-12-12 21:19:38 +00:00
merge-script 6865ced228
Merge rust-bitcoin/rust-bitcoin#3755: api: Run just check-api
8576d194af api: Run just check-api (Tobin C. Harding)

Pull request description:

  Bother, punished by the merge queue again.

ACKs for top commit:
  apoelstra:
    ACK 8576d194af25dc8ea0be0d576cfc318da6019482; successfully ran local tests; though obligatory reference to #3166 since this is the sort of API break that will be a paper cut

Tree-SHA512: bb1048fb74b1c4003df1af1e275e33befa92dcca662e955f0cef7afe502f211c91d53213b76731abffec0fefa0565e5b57eac0e5fad5b87f48f9160ab9f8c569
2024-12-12 19:52:08 +00:00
merge-script bfd35d49e3
Merge rust-bitcoin/rust-bitcoin#3726: units: Improve `Default`
a4a0f2921c units: Add regression tests for Default impls (Tobin C. Harding)
f5c2248a31 units: Derive Default for BlockInterval (Tobin C. Harding)

Pull request description:

  Done while looking into [C-TOR](https://rust-lang.github.io/api-guidelines/predictability.html#c-ctor)

  - Derive `Default` for `BlockInterval`
  - Add regression test for all types that implement `Default`

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

Tree-SHA512: ce39c2bcb37fc0fa70bd2553dd7843d9ac8f9528631706056ba89fda9623defadf32974091832b7a087121290b3f883bc8a8dcca070f1d90670eeee6b541de01
2024-12-12 18:26:46 +00:00
merge-script 661524f53f
Merge rust-bitcoin/rust-bitcoin#3727: units: Add _export::_core
a2cab6f925 units: Add _export::_core (Tobin C. Harding)

Pull request description:

  As we do in `bitcoin` add a module for usage in macros to prevent naming clashes if a module called `core` exists.

  Overly paranoid yes but this is bitcoin after all.

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

Tree-SHA512: f20d5b7aae55370891a2943cf3be6e04cb24a93f570093252eefee548f3e13931d03cfaef14613df2a75c477476c98f33173bd4a6da3a15beb7dc4e01648f574
2024-12-12 17:08:49 +00:00
merge-script e768faf2a3
Merge rust-bitcoin/rust-bitcoin#3733: Add additional catagories
38c329c1b7 Add additional catagories (Tobin C. Harding)

Pull request description:

  Add `no-std` category to the soon-to-be-released leaf crates. Also add `cryptography` to the `bitcoin_hashes` crate.

  Close: #3731

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

Tree-SHA512: e4481c61028b42876ac4ff62d7f1f97116c49a72f99aa0f75fe158c524d021518bf3334ea181fdc9979765bbe3ef2167a7999396898471e88299814e292a9949
2024-12-12 15:52:14 +00:00
merge-script 157d5bfc80
Merge rust-bitcoin/rust-bitcoin#3719: Change `SignedAmount` `MAX` and `MIN` to equal +/- `MAX_MONEY`
4b926e1908 Change`MAX and `MIN` to equal `MAX_MONEY` (Jamil Lambert, PhD)

Pull request description:

  To prevent rounding errors converting to and from f64 change `SignedAmount` `MAX` and `MIN` to +/- `MAX_MONEY` which are within the limit in f64 that has issues.

  Add checks to `from_str_in`, `checked_add`,  `checked_sub` and `checked_mul` that the result is within MIN and MAX.

  Modify tests to work with new `MIN` and `MAX`.

  Discussed in #3688 and #3691

ACKs for top commit:
  tcharding:
    ACK 4b926e1908
  apoelstra:
    ACK 4b926e1908f72af98d24cc64d7e1eef44d624e4e; successfully ran local tests

Tree-SHA512: 9053e761b3b74a7a9d826ae7271ced41cf7919752ac8ed8977a20b5b1a746ac8a6bfff68159f4a0dea733ea00f49cf41c0422de53c7aff39efd8482f8cba6069
2024-12-12 14:34:34 +00:00
Tobin C. Harding 8576d194af
api: Run just check-api 2024-12-12 16:30:47 +11:00
Tobin C. Harding 6e01383f16
api: Run just check-api 2024-12-12 16:28:49 +11: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 0135cddc32
Refactor non_input_size
Looks like the formatter has put code comments in the wrong place.

Refactor the `non_input_size` line so that the formatter does not mess
with it.
2024-12-12 15:34:22 +11:00
Tobin C. Harding f42f13cd8d
Simplify closures in call to fold
Remove unnecessary code comments and make the closure variable names more
terse with no loss of clarity.

Refactor only, no logic changes.
2024-12-12 15:34:12 +11:00
Tobin C. Harding 60f2089dcd
Clean up possibly confusing
Put the list of possibly confusing forms in the same order as the enum
and fix the rustdocs to show the actual error variants returned.
2024-12-12 15:31:25 +11:00
Tobin C. Harding 3c8c956511
Remove Weight::from_wu_usize function
This constructor is an anomaly in this repo. Also it is ugly to have the
type parameter hard coded in the function name.

The problem the constructor is trying to solve is that we don't like
casts that don't obviously loose data. We have a solution for that
already in `internals::ToU64`. This trait cannot be used in const
contexts though so we do introduce a single cast in this patch.
2024-12-12 15:21:29 +11:00
Tobin C. Harding 4cccbfdf76
units: Seal the Integer trait
This trait is an internal thing, users should never implement it.
2024-12-12 15:16:15 +11:00
Tobin C. Harding 7725ca77c5
Rename private module to sealed
There are two `private` modules in `amount` but they do slightly
different things. One provides a private `Token` and one is for trait
sealing. We have various other trait sealing modules in the codebase and
they are all called `sealed` not `private`. Also the seal trait is
called `Sealed`.

Rename the `private` module and the trait to be uniform with the rest of
the codebase.
2024-12-12 15:16:00 +11:00
Tobin C. Harding a4a0f2921c
units: Add regression tests for Default impls
Add a regression test to the `api` tests to check the value returned by
`Default` for all types that implement it.
2024-12-12 15:15:29 +11:00
Tobin C. Harding f5c2248a31
units: Derive Default for BlockInterval
A block interval is a relative thing so it makes sense to default to
zero. This is the same as how we derive `Debug` for `relative::Height`
but not `absolute::Height`.
2024-12-12 15:15:28 +11:00
Tobin C. Harding a2cab6f925
units: Add _export::_core
As we do in `bitcoin` add a module for usage in macros to prevent naming
clashes if a module called `core` exists.

Overly paranoid yes but this is bitcoin after all.
2024-12-12 15:15:13 +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
Tobin C. Harding d1dd63d6d4
Remove wildcard in script re-exports
We don't like wildcard re-exports anymore; explicitly re-export the
types from `primitives::script`.
2024-12-12 15:14:00 +11:00
merge-script aeca93b561
Merge rust-bitcoin/rust-bitcoin#3721: Add new api text file changes
601a47fb40 Add new api text file changes (Tobin C. Harding)

Pull request description:

  In a recent PR (#3682) we introduced api text files. Then in another PR (#3711) we removed `alloc` feature gating. Possibly due to the timing of running through CI and merging these two PRs managed to get merged without an update to the API text files.

  As would be expected; removing the `alloc` feature gate adds a bunch of new lines to the `no-features` api text file.

ACKs for top commit:
  jamillambert:
    ACK 601a47fb40
  apoelstra:
    ACK 601a47fb405872c58a9a41d805c204c4d4851e14; successfully ran local tests

Tree-SHA512: 65e22192bcc386172ec1b74651c35deef954f9f461e6dc0758140b67c62c9afa0290031ddb04d67455a558dbfb10126c042c01002057b400cd5aff7d4e38e4da
2024-12-12 04:09:19 +00:00
merge-script 8e52f758b5
Merge rust-bitcoin/rust-bitcoin#3715: units: Add `must_use`
2fd8614f5d units: Add additional must_use (Tobin C. Harding)
79a229b391 units: Add pedantic lint return_self_not_must_use (Tobin C. Harding)

Pull request description:

  Enable return_self_must_use and also run the linter locally with must_use_candidate.

  Add must_use attribute as required excluding obvious functions (conversion, getters, etc).

  Done as part of https://github.com/rust-bitcoin/rust-bitcoin/issues/3185

ACKs for top commit:
  apoelstra:
    ACK 2fd8614f5d091377f179440b04ec71f4853fd187; successfully ran local tests; nice! will one-ACK merge

Tree-SHA512: 90868846d6877830ca2b6931e8b94208434acc5a7b21808a32e2e1568c0ad33185644b931cae500e6619b8b4f19c39bce6922502d9233173722ef0e6455edba6
2024-12-11 18:22:02 +00:00
merge-script e2de5162d9
Merge rust-bitcoin/rust-bitcoin#3717: base58ck: Bump version to 0.2.0
5b3e4ab95b base58ck: Bump version to 0.2.0 (Tobin C. Harding)

Pull request description:

  In preparation for release add a changelog entry, bump the version, and update the lock files.

ACKs for top commit:
  storopoli:
    ACK 5b3e4ab95b
  apoelstra:
    ACK 5b3e4ab95b015b5bba5b73db2052cbb63a901466; successfully ran local tests

Tree-SHA512: 8347b0540ccdfc29f4a03f0a3554142b4fbd39b519512dcc886c28cae75666201aa8a7e4a07999e70c0348e59f02c4c0d67541a20102153b36150f5e4748a89e
2024-12-11 16:58:08 +00: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 b2a60b9d3f
Merge rust-bitcoin/rust-bitcoin#3714: hashes: Add `must_use`
f4b9c06c8b hashes: Add additional must_use (Tobin C. Harding)
b9b8ddafde hashes: Add lint return_self_must_use (Tobin C. Harding)

Pull request description:

  Enable `return_self_must_use` and also run the linter locally with `must_use_candidate`.

  Add `must_use` attribute as required excluding obvious functions (conversion, getters, etc).

  Done as part of #3185

ACKs for top commit:
  apoelstra:
    ACK f4b9c06c8bdffccfe997135f7b6ec168978e9bcc; successfully ran local tests; nice! will one-ACK merge
  sanket1729:
    utACK f4b9c06c8b

Tree-SHA512: 26668e5871a9d3d1ba71974a656227904dca5d553b2466b5bca2253c0aa020fa71c548b17d03aff9ebeca62d4a194cf6d227d5d248391b9b26646ccda400c29d
2024-12-11 14:22:42 +00:00
merge-script f1b993a00d
Merge rust-bitcoin/rust-bitcoin#3713: io: Add lint `return_self_not_must_use`
199516b599 io: Add lint return_self_must_use (Tobin C. Harding)

Pull request description:

  Enable lint `clippy::return_self_not_must_use`. Does not generate any new warnings.

  Also run the linter with `clippy::must_use_candidate` enabled. Also does not generate any new warnings.

  Done as part of #3185

ACKs for top commit:
  apoelstra:
    ACK 199516b599fa11cfabf64b3e641db9fc162e2496; successfully ran local tests; nice! will one-ACK merge

Tree-SHA512: a44772f58d60d02fc14c364cfd8bc098ab0be45a80463f5337957b04170116d680d15cea5ce96b7c55d8bc08e04e546f4dd3ee29a2acf2e1fadd4e78321e689c
2024-12-11 13:42:11 +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
Jamil Lambert, PhD 4b926e1908
Change`MAX and `MIN` to equal `MAX_MONEY`
To prevent rounding errors converting to and from f64 change
`SignedAmount` `MAX` and `MIN` to +/- `MAX_MONEY` which are within the
limit in f64 that has issues.

Add checks to `from_str_in`, `checked_add`,  `checked_sub` and
`checked_mul` that the result is within MIN and MAX.

Modify tests to work with new `MIN` and `MAX`
2024-12-11 08:15:48 +00:00
merge-script 087427cf85
Merge rust-bitcoin/rust-bitcoin#3679: Support serde serializing Amount as string
c27f443520 Add basic unit tests for Amount serde (Tobin C. Harding)
22530f6a2b Support serde serializing Amount as string (Tobin C. Harding)

Pull request description:

  Sometimes JSON parsers may munge floats. Instead of using `f64` we can serialize BTC amounts as strings.

  Close: #894

ACKs for top commit:
  apoelstra:
    ACK c27f4435208cc3ca7b98580fd7e2784e089b545e; successfully ran local tests
  sanket1729:
    utACK c27f443520.

Tree-SHA512: 084669a0622557b75fceae732fb485e7139ecada48c0b65642d122e1a02f6f7e41564c3579fd10adbf3aa14c82c9f10abc3f9201858e50b729852140b31a4216
2024-12-11 04:18:53 +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 2fd8614f5d
units: Add additional must_use
Use the `must_use_candidate` clippy lint to find all functions that are
candidates for having `must_use`.

Add `must_use` attribute but exclude obvious functions like `from_`,
`to_`, and `new`.

This patch is subjective.
2024-12-11 09:19:19 +11:00
Tobin C. Harding 601a47fb40
Add new api text file changes
In a recent PR (#3682) we introduced api text files. Then in another
PR (#3711) we removed `alloc` feature gating. Possibly due to the
timing of running through CI and merging these two PRs managed to get
merged without an update to the API text files.

As would be expected; removing the `alloc` feature gate adds a bunch of
new lines to the `no-features` api text file.
2024-12-11 08:56:59 +11:00
Tobin C. Harding 79a229b391
units: Add pedantic lint return_self_not_must_use
As part of the effort to polish the `units` create ready for the 1.0
release; enable the pedantic lint `return_self_not_must_use`.
2024-12-11 08:50:27 +11:00
merge-script e7efdd7c42
Merge rust-bitcoin/rust-bitcoin#3711: primitives: Reduce alloc requirements
6ae35be0db primitives: Reduce alloc requirements (Tobin C. Harding)

Pull request description:

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

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

Tree-SHA512: a49076a72b81a68f7e0e03c452eb5490dcc69136b15834577ba10ec71767080cf74fd443e2668f008814ed677d4ee6b45972f6f52b78b8eb793e05780d10a2ec
2024-12-10 21:17:27 +00:00
merge-script ec37c28fad
Merge rust-bitcoin/rust-bitcoin#3697: Range check against SignedAmount::MAX instead of i64::MAX
ac74ed2144 Range check against SignedAmount::MAX instead of i64::MAX (yancy)

Pull request description:

  Future proof this check by using SignedAmount::MAX in the case where the MAX SignedAmount changes to something other then i64::MAX.

ACKs for top commit:
  tcharding:
    ACK ac74ed2144
  apoelstra:
    ACK ac74ed2144e785fef7c395388a4fb7fb394e833e; successfully ran local tests; nice. Simple and obviously an improvement

Tree-SHA512: 4003a2f3b34e03330c57125622cab5e55a235b1a610dda622035c071bc5530811e275c2e25f40e1309cecf1c3bef35070ae690fa57fdf3e2c1b5c3f75ca5d29e
2024-12-10 16:44:10 +00:00
Tobin C. Harding 5b3e4ab95b
base58ck: Bump version to 0.2.0
In preparation for release add a changelog entry, bump the version, and
update the lock files.
2024-12-10 13:47:29 +11:00
merge-script f8136abdb1
Merge rust-bitcoin/rust-bitcoin#3701: Automated daily update to rustc (to nightly-2024-12-06)
d3d20d3fb2 Automated update to Github CI to rustc nightly-2024-12-06 (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 d3d20d3fb2

Tree-SHA512: bb22746dab2f8e75674fa4fa3653bfd067cc1d680198ed62730737ca08a8fe8e49c3e5475a1e9f7b1cd73bfc8499bbcc1111f783b055aa041108d7cc863e8b91
2024-12-10 13:26:23 +11:00
merge-script 52ff933e29
Merge rust-bitcoin/rust-bitcoin#3700: Automated weekly update to cargo-semver-checks (to 0.37.0)
78f61f55de Automated update to Github CI to cargo-semver-checks version-0.37.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 78f61f55de

Tree-SHA512: 1765aa338b5e86320702f0c27430853e072152358a179db106354c71c371c91499e712b0595407fff47cbb4ca1d8ccfc8e28b050ac1b3bcd9875037a95ad6a7c
2024-12-10 13:23:30 +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 199516b599
io: Add lint return_self_must_use
Add the lint. No additional clippy warnings are introduced.
2024-12-10 11:00:16 +11:00
Tobin C. Harding f4b9c06c8b
hashes: Add additional must_use
Run the linter with `must_use_candidate` enabled and check all the
warnings.
2024-12-10 10:58:11 +11:00
Tobin C. Harding b9b8ddafde
hashes: Add lint return_self_must_use
Add the lint. No additional clippy warnings are introduced.
2024-12-10 10:56:33 +11:00
merge-script 8eda92ee7b
Merge rust-bitcoin/rust-bitcoin#3699: Explicitly define Ord for NodeInfo
428e9787d1 Explicitly define Ord for NodeInfo (Shing Him Ng)

Pull request description:

  Fixes #3654 by explicitly defining Ord so that we avoid potentially catastrophically changing addresses out from under users

ACKs for top commit:
  sanket1729:
    utACK 428e9787d1
  apoelstra:
    ACK 428e9787d181a462d06a18b7a45701790cbc0929; successfully ran local tests

Tree-SHA512: e900e07b2c53f643e3239bf7d26567b56275899b408a94e45f1cddd81217141c304c87159ce413a7a4660f1c09a0db2bbc1146948a2d9e7600abf14cd73ac691
2024-12-09 22:13:58 +00:00
merge-script ecab6857bf
Merge rust-bitcoin/rust-bitcoin#3706: units: test for C-SEND-SYNC
ffdd63fa8e units: test for C-SEND-SYNC (Tobin C. Harding)

Pull request description:

  Done as part of the Rust API guidelines checklist.

  Add a unit test for `Send` and one for `Sync`.

ACKs for top commit:
  apoelstra:
    ACK ffdd63fa8ec3575bc3087241ebdcbccc71818ab7; successfully ran local tests; ooh, I like how extensible this API test framework is!

Tree-SHA512: 9227ad487f77596964c728deee97c62a04490510a8ab69fd3fc29a3e400b37114e27c777cf868fe58de870a9ff0aca3d234ccf2bb93d69a709e8c9b85d44fc61
2024-12-09 19:44:31 +00:00