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
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`.
91268bba67 Examples use ?, not try!, not unwrap (Jamil Lambert, PhD)
Pull request description:
To conform to Rust API guidelines in Issue #3633 examples should use ?, not try!, not unwrap (C-QUESTION-MARK).
The examples were originally labelled `## Commonly used operations`, change the label to `# Examples`.
Replace `unwrap()` with `expect()` since these cases cannot error.
Two uses of `unwrap()` have been left since they are in a set of three writes with an engine that can not error and the first case uses `expect()` with the relevant error message.
ACKs for top commit:
tcharding:
ACK 91268bba67
sanket1729:
ACK 91268bba67
apoelstra:
ACK 91268bba672d7dea9e29cccfa83f3b34df27fe91; successfully ran local tests
Tree-SHA512: 4c7836b2e8d67ac5d6f85229ca9ad3c9c5f0f1dc7062bda398c48ef72fd6bb965effee313151f70c86bd7cebda78a651cc12b2d59bc331d689089cf17b8c3dc8
433f70939c Implement iter::Sum for BlockInterval (Tobin C. Harding)
0369e64b56 Implement Sum for an iterator of references to amounts (Tobin C. Harding)
31f883ac00 Implement iter::Sum for FeeRate (Tobin C. Harding)
Pull request description:
Enables summing an iterator of values. Note that this does not include either `LockTime`s. `absolute::LockTime` should not be added and for `relative::LockTime` we have https://github.com/rust-bitcoin/rust-bitcoin/issues/3676Close: #1638
ACKs for top commit:
apoelstra:
ACK 433f70939c3ecc10702ab6502e3f9bcd94dab739; successfully ran local tests; nice!
sanket1729:
utACK 433f70939c
Tree-SHA512: 1eda00f3bbbc61f795198ce8525a5a9b690478a8abc268da6d2e40de7d91decc28dd8211df0c6abeaf30148c7ec3907b85e3c5351972c354590569840e84d562
22769268f3 units: Close the hex parse errors (Tobin C. Harding)
Pull request description:
As part of the 1.0 effort close the errors in the `units::parse` module.
ACKs for top commit:
apoelstra:
ACK 22769268f34b45c0bd86c548eb13cfe1e290f0d7; successfully ran local tests; thanks!
sanket1729:
ACK 22769268f3
Tree-SHA512: 598ba236f8c08c3f750112e0d8b8e0aa0568be2700a328e4a2d8999ca59eada8a16a6a1d9e9121e7f42ce9bbe3da3f87221ba67c36056996a687e489f4c6007c
667b7f1010 Remove unused extern statement (yancy)
Pull request description:
`extern crate` keywords are no longer needed to import a crate as of Rust 2018
ACKs for top commit:
tcharding:
ACK 667b7f1010
apoelstra:
ACK 667b7f1010bc0745d3e39181e15ec795aeca68dc; successfully ran local tests
sanket1729:
ACK 667b7f1010
Tree-SHA512: d157aa881dfce12b65bb676425cb5f17fa5a193d0001f37c26f74cab1254ab08fdcc9b7462b9a74210f85028299af9e14c0071ba390642b59bb7e986ba85933d
987e31a188 Automated update to Github CI to rustc nightly-2024-11-27 (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 987e31a188
Tree-SHA512: d0ef5b7796178aed1e7b59ac2b85e7ecbb8640b8f30847c6cd3d14f3a0ec4291a668ecd2ba213b6a756ed4324aaaf82c54268f81eb53fc4a153ebd7edee6e00e
c49f40fd9a units: Test C-COMMON-TRAITS (Tobin C. Harding)
Pull request description:
Add structs to the `api` integration test file that verify the set of common traits.
ACKs for top commit:
apoelstra:
ACK c49f40fd9af1b9446a7c9a35aefdc02b30801275; successfully ran local tests; good idea!
Tree-SHA512: bc60ed8912e705d4c07714e9d19c0eee4fb2eb6be17a6ee67c2bb922ea27ef3a737eda3f7de690fa3a9fa364c34029989f20361d03f706fd3152ec4f20f33aab
7e17eaf21c units: Add stringy regression tests (Tobin C. Harding)
Pull request description:
Add regression tests for `Display` and `FromStr` impls. Exclude error types and helper types (`amount::Display`).
Done as part of #2498 and also as part of the 1.0'ing effort.
ACKs for top commit:
apoelstra:
ACK 7e17eaf21c479338d5161b493f02578ef4186e62; successfully ran local tests; nice
Tree-SHA512: 6484806777501fe38557987c9c39b377f972fd4406cf3cfd8ac36f8426041484caab45d4ccff87221dbc5c34507d1be6a7b23839367bd3010855c92fd898c835
To conform to Rust API guidelines examples should Examples use ?, not
try!, not unwrap (C-QUESTION-MARK).
Label the examples as `# Examples`.
Replace one `unwrap()` with `expect()` . The others don't technically
conform to the guidelines but are warranted.
77085a1fa1 units: Remove serde from amounts (Tobin C. Harding)
Pull request description:
The `Amount` and `SignedAmount` were not supposed to implement `serde` traits by design because doing so implicitly uses sats. We provide two modules `as_sat` and `as_btc` to allow users to explicitly serialize in their preferred format.
In commit: `d57ec019d5 Use Amount type for TxOut value field` derives were added for `serde` and we did not notice it during review.
ACKs for top commit:
apoelstra:
ACK 77085a1fa1f39e7358202e49189282e48a965747; successfully ran local tests
Tree-SHA512: ff4c1f34191e12d955e66737493af4b2dad761fa6f95eb334b86715906e70d2180e7f15d8b4af302d53fb0b1c8b5fb50b4924e9fcdee8824840ba555e73c1c17
60f43a893d Remove duplicate test case (Tobin C. Harding)
Pull request description:
In commit:
`a10d5e15b3 Extract the Script assembly creator from fmt::Debug`
A test case was refactored and where there used to be two test case, one for `Debug` and one for `Display`, two identical test cases were left.
Remove duplicate test case.
ACKs for top commit:
apoelstra:
ACK 60f43a893d67c221f61e289cab6394418411cf55; successfully ran local tests
Tree-SHA512: 8d21f07b33c9f88ac820422b9f5471bf53e36050a31854a7152ab14c6e25654455f4eb366ea2b497a80f741af36bf068b1df8a69321a0299c9bae60f001b354e
d9b48cc2ce Add p2wpkh address creation example (yancy)
Pull request description:
Add example for creating p2wpkh address. It would be helpful to add examples the other address types (p2tr etc) either in separate files or in one. Note this should be created in the Address crate however that crate is currently empty.
ACKs for top commit:
tcharding:
ACK d9b48cc2ce
apoelstra:
ACK d9b48cc2ce68b065640caa22da6fbcb1f3ad85f8; successfully ran local tests
Tree-SHA512: b383c1aca2d3669f66f0dcaf858526793ffc9e62671cf4985c44a11f7717c8e02d359b4d7d8b5822ebdde27595612e10bc831c84a2c4b654f69d4137ad16ba2f
f961f3c0ec Add test (yancy)
3352032892 Fix internal weight calculation (yancy)
Pull request description:
A fix for 261c8d8ae6. Maybe it's better to roll back that commit instead. Clearly there needs to be a test or two added here as well since this change causes not test failures.
ACKs for top commit:
apoelstra:
ACK f961f3c0eca4e9b175761756f48699012b63d70a; successfully ran local tests
sanket1729:
utACK f961f3c0ec
tcharding:
ACK f961f3c0ec
Tree-SHA512: e6bb6d492b6a85f328bdfae6d0e5df9ea48c9c06bd0c310816826c893163bd0a6071af893fa7012fbd4eea0394bc8997277151486807fb8bd06ac78ce8cfc5fd
4d0d78a3af Fix typo in from_next_work_required documentation (Shing Him Ng)
5e47c4123d Update CompactTarget::from_next_work_required to take timespan as i64 (Shing Him Ng)
Pull request description:
[In Core](f7144b24be/src/pow.cpp (L56)), the timespan is defined as a signed int64. This PR will update `from_next_work_required` to take in an `i64` instead of a `u64`
Fixes#3652
ACKs for top commit:
tcharding:
ACK 4d0d78a3af
apoelstra:
ACK 4d0d78a3af2ca300c6b40348724e806bd51ef27a; successfully ran local tests
Tree-SHA512: eea33ec18b081a97ae2a22c681982ad8693200ff8de3a3fc8f46b84b5e72f41589b79140ddd79ba3fce628f1539baf8387422bcc2c6b409fcadc4c2043aa2901