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.
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
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
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
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
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
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
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
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
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.
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.
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.
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
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
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
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
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.
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
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
7e0501c03c Add a script to query the API (Tobin C. Harding)
e126a24307 Add API script (Tobin C. Harding)
219ecd5498 Add api text files (Tobin C. Harding)
Pull request description:
Last time we did this there was push back by Kixunil because he did not like updating the API files. This time we only add API files for those crates we are focused on stabalizing.
As we try to do the checklists for making sure the crates conform to the Rust API guidelines one has to repeatedly audit the code. Being able to quickly get lists of things out of the code is super useful.
And the after we release 1.0 these API text files become valuable for review.
--
Add a script to generate API files using `cargo check-api` for the crates that we are trying to stabalise.
- hashes
- io
- primitives
- units
Add a script to query the API files. E.g., `contrib/api.sh units types`
Current commands are
`types`: Show all public structs and enums
`types_no_err`: Show all public structs and enums excluding errors
`traits`: Show all public traits
ACKs for top commit:
apoelstra:
ACK 7e0501c03cbc02ccd9292a709b51deb96c74901d; successfully ran local tests; let's do it
Tree-SHA512: d9fcff3dd9976b15669625b8e613b10c6e1d16bd9e01980214ead497fd6487539e4b8fa5d44cc25137c658b931f90e22bf51741950ef78e1bdf7ceba96294b76
6950c0a7b5 Change `Amount::MAX` to equal `MAX_MONEY` (Jamil Lambert, PhD)
Pull request description:
As discussed in #3688 and #3691 using `u64::MAX` causes errors when converting to `f64` so `MAX_MONEY` is should be used as the maximum `Amount`.
- `Amount::MAX` changed to equal `MAX_MONEY`
- Add a check to add, multiply and from_str functions
- Change tests to account for new lower maximum
Different approach to the existing PR #3692. I have only done Amount and not SignedAmount until there is feedback on which approach to use.
ACKs for top commit:
tcharding:
ACK 6950c0a7b5
apoelstra:
ACK 6950c0a7b507f9d70c1ebdab540634482f73b247; successfully ran local tests
Tree-SHA512: 03ebf39c47b19ba88d95235538039f28bfa29f4499618fab25c9b627684c348ed41caef682e8f0e01ca62cf9ced8a1183fe3ed861bffeb9609b09440ddfb1c92
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`.
Add a simple script that allows one to query the current API. Done by
parsing the API text files and grepping for things.
This is useful as a dev tool as we try to stabalize the leaf crates.
Add a script to generate API files using `cargo public-api` for the
crates that we are trying to stabalise (the so called 'leaf crates').
- hashes
- io
- primitives
- units
We already ran the script and committed the files last patch. The fact
that this patch does not include any changes to the `api/` directory and
that CI passes is enough to convince us that last patch was valid.
Add a CI job that runs the script and checks there are no changes to
the committed text files thereby proving no API changes are made in a
PR without explicitly modifying the API text files.
Add documentation to `CONTRIBUTING.md` on what is expected of devs.
We are about to introduce a script that generates text files for the
public API surface of various crates.
Run the soon-to-be-introduced script and commit the changes. Covers:
- `hashes`
- `io`
- `primitives`
- `units`
The script and CI setup will be done in the next patch, this is just to
make review easier.
edab380ac0 bitcoin: Bump version to v0.33.0-alpha.0 (Tobin C. Harding)
Pull request description:
Needs release notes but there are 20 pages of them, that feels like too many to go through manually.
ACKs for top commit:
apoelstra:
ACK edab380ac096babf3d12f27d373d0900d10bc065; successfully ran local tests
Tree-SHA512: 318fc9a6a8a2142b2f5e11881dfa60748c51c693325503b35e0197ac18b2c2ebb37bad71846fea2dfe64f93c67aba018447ed4a3eb9beb481c094fc03ff271a2
To prevent rounding errors converting to and from f64 change
`Amount::MAX` to `MAX_MONEY` which is below the limit in f64 that has
issues.
Add checks to `from_str_in`, `checked_add` and `checked_mul` that the
result is below MAX, where previously a u64 overflow was relied on.
Change tests to account for new lower MAX that is within the range of
SignedAmount and does not overflow so easily
Remove overflow tests
`Amount::MAX` is now below `u64::MAX` and within the range of values for
`SignedAmount`. These tests therefore do not overflow.
In effective_value there is no error with `Amount::MAX` and the correct
value is returned.
In psbt the removed test is effectively the same as the previous test.
Modify `Amount` tests to work with new `MAX`
Tests need to be changed that checked values above the new `MAX` or
`Amount::MAX` was out of range for `SignedAmount` which it isn't anymore
Needs release notes but there are 20 pages of them, that feels like too
many to go through manually.
Includes a missing changelog entry in `units` for an already released
change that is included in this `bitcoin` release.
Sometimes JSON parsers may munge floats. Instead of using `f64` we can
serialize BTC amounts as strings.
Includes addition of `alloc` feature gate to `DisplayFullError` to
remove lint warnings when building with `--no-default-features`.
Close: #894
75297a68f6 Automated update to Github CI to rustc nightly-2024-12-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 75297a68f6
Tree-SHA512: 8a36d0f3e660195a1ba6811994b0df70962c4dd31eafe0ad125966883c63f09f18b1d073516e136677b72d17f54487670ed1745fd68e17b38b554f72d315e4a3
8b41ecb427 Fix typo in re-export (Shing Him Ng)
Pull request description:
Fix typo in re-export
ACKs for top commit:
apoelstra:
ACK 8b41ecb4270585652259277e7f132c8fbdcae953; successfully ran local tests
tcharding:
ACK 8b41ecb427
Tree-SHA512: 72de9268a509647d4ad4de931478582198071e5e26e5cb44beeca341e80b1fe380d45721ba8d8e871ae828c1e3740cb23dbc6fc635078fb39f909c625364e710
fd2a5c1ec7 Close amounts error types (Tobin C. Harding)
23c77275b1 Reduce code comment lines (Tobin C. Harding)
d595f421c6 Remove whitespace between enum variants (Tobin C. Harding)
Pull request description:
Close the two pubic enum error types in `units::amounts`. All the other structs are closed already because they either have private fields or marked `non_exhaustive`.
ACKs for top commit:
apoelstra:
ACK fd2a5c1ec79f337fb3695c030c9fb6b4671468f2; successfully ran local tests; thanks!
Tree-SHA512: f8d68ef821449e0829c926cf527df4b226b29c8d1d41b320a016fbf70b4b39cc54c8c218955caa0c3776158eeeae0ebacc1cc89dab67bafc399b94063324ab0e
01ec48cfb8 Re-name cron nightly update jobs (Tobin C. Harding)
f428833bdd Only update nightly once a week (Tobin C. Harding)
Pull request description:
Merging the nightly update PRs is boring and annoying. We can just do it once a week without too much risk of falling behind.
This does mean that I (Tobin) can't be lazy and skip merging the bot's PRs (which I find myself doing when its twice a week).
ACKs for top commit:
apoelstra:
ACK 01ec48cfb83389759c1c83ec85d008533ddef74d; successfully ran local tests
Tree-SHA512: 72bd138399cc742cba89912fd576bf8b8ef23db123c197278f9910f6ce9470607b37e26ceb690e7140faa3493ad7e370c157285ffb2adfc1321b0dc0e0f9f9c9
b5a0731a23 refactor: remove unnecessary if block (Chris Hyunhum Cho)
Pull request description:
This `if...else` block can be replaced with one `if` block, by changing `==` to `!=`.
ACKs for top commit:
jamillambert:
ACK b5a0731a23
apoelstra:
ACK b5a0731a23f945f7e4cc7d8f3c0f1d3f83875272; successfully ran local tests
tcharding:
ACK b5a0731a23
Tree-SHA512: eee0d63532953d27fe081c36180ae9adb63c0ab7f1fb8324d9fc5e4a408f421d8df894efcccfc4bd3142625d6be6ea1258c9478faa025ce147ebe1b4e9377738
Merging the nightly update PRs is boring and annoying. We can just do it
once a week without too much risk of falling behind.
This does mean that I (Tobin) can't be lazy and skip merging the bot's
PRs (which I find myself doing when its twice a week).
a1260b06ed Automated update to Github CI to rustc stable-1.83.0 (Update Stable Rustc 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 a1260b06ed
Tree-SHA512: 1f8cdfe3336109608afd786430c8f37544ba866405c63c6032f214fcb8f15815eef785748188efbe9436e010496701b7f4a831602843cf94c73afcbf16b98b83