33ebbac4c8 Improve deprecation notice (Tobin C. Harding)
Pull request description:
The deprecation notice for `is_provably_unspendable` contains "is not very useful" which is a bit presumptuous to tell to users, it may very well be useful to them. Use the more helpful text that already exists in rustdoc on the function.
Function was deprecated in #2294
ACKs for top commit:
apoelstra:
ACK 33ebbac4c8 I am fine with the existing text
sanket1729:
utACK 33ebbac4c8
Tree-SHA512: 0611b9c414a5b01d453145d645dbfe6ef0be4000a7133bc79211c0494741638fcc19f97d6503546813f426cbc492816daf708045a76e7d67e5bd975ad8f56d5f
00572ae24b Automated update to Github CI to rustc nightly-2024-04-09 (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 00572ae24b
Tree-SHA512: 1a76e4777f760607507eee4769e0e30c5b681fb4b2c75ac0581753c2cf3d36e8dc2bb76da14977e2e7ee0f64fd2aad04474b7f56858adbdaa5a81d1b1f8ddf70
The deprecation notice for `is_provably_unspendable` contains "is not
very useful" which is a bit presumptuous to tell to users, it may very
well be useful to them. Use the more helpful text that already exists in
rustdoc on the function.
12be5c0d27 clippy: fix a couple of nits in `clippy --no-default-features` (Andrew Poelstra)
7d07fc3fb9 ci: update the new nightly_version file in cron (Andrew Poelstra)
Pull request description:
Fixes an issue with #2658 which accidentally disabled our nightly rustc update cronjob, and also fixes a small clippy lint.
After this, we should be able to get back onto the latest nightly :).
ACKs for top commit:
tcharding:
ACK 12be5c0d27
Tree-SHA512: 771fb2c278b0aaea04454a3c397d4ca1c201ff59891d4f7af69a295aa4c6475320383fa5f4dd2a20323e79d5fe68b2ff37c3f01717a12f98afb9db3c2939c95a
We only check clippy in CI with --all-features, which usually is the
best way to get maximum coverage. But if you try a couple other feature
combos, especially those related to nostd, you can hit more code.
051c358bcb Remove deprecated legacy numeric methods (Divyansh Gupta)
Pull request description:
As `rustc 1.79.0-nightly (9d79cd5f7 2024-04-05)` is released which solves the issue mentioned , but the release has deperacted legacy numeric methods.
Thus replaced `u16::max_value()` etc with `u32::MAX` & `core::u16` to directly `u16`.
fix#2639
ACKs for top commit:
tcharding:
ACK 051c358bcb
apoelstra:
ACK 051c358bcb thanks! I will remove an equivalent commit from my #2669
Tree-SHA512: c08c856f7f3b281417c29283351eac5e0f75cc1c8d23d9aae58d969219a327b2337fe57932053e53773ebb9dbec04254f90149266b6639a66c5c09f2ad1675ef
As `rustc 1.79.0-nightly (9d79cd5f7 2024-04-05)` is released which solves the issue mentioned , but the release has deperacted legacy numeric methods.
Thus replace `u16::max_value()` etc with `u32::MAX` & `core::u16` to directly `u16`.
fix#2639
0073a17e20 bitcoin: Bump version to 0.32.0-rc1 (Tobin C. Harding)
Pull request description:
This PR is just the final patch, primarily the changelog. Pretty happy with my effort, check it out: https://github.com/tcharding/rust-bitcoin/blob/04-04-release-bitcoin-rc1/bitcoin/CHANGELOG.md
ACKs for top commit:
sanket1729:
utACK 0073a17e20.
apoelstra:
ACK 0073a17e20
Tree-SHA512: 9d2815c8739286350373eac3cd03d703082fb41b67cc83dcd694f41f2b97cc7d07b8942b62876552f490fddb588e30c346246ff0114b3b3adafb3482f76db242
In preparation for dropping the first release candidate bump the version
and add a changelog.
Please not I went to much more effort that usual with the changelog,
open to review on the overall form - not promising I'll change it but
definitely would like to keep iterating and improving.
If this changelog is appreciated then FWIW I don't think we should
bother automating it, a machine does not have all the context required
to create it.
e06ebd69e7 units: Bump version number to 0.1.1 (Tobin C. Harding)
a2b019f823 Enable internals "alloc" feature (Tobin C. Harding)
Pull request description:
Fix a minor internal bug in error code in `units` and bump the version number so we can do a point release.
This can go in after the RC drops as part of the release candidate cycle if its easier - as long as its in and released before the finale `v0.32.0` release.
ACKs for top commit:
apoelstra:
ACK e06ebd69e7
sanket1729:
ACK e06ebd69e7
Tree-SHA512: b6523fae57ba3becf27c0a11fe0b1d75db9226d01bde527390e2cf1697520d5daabc5ef3909b2c464b14f38ba4f8ab87aa49d17a1d054767920963ef1c3ef3b9
14040e2ff5 psbt: Return the internal key for key path spend (Tobin C. Harding)
ffd5664c08 Do not panic if input_index is out of bounds (Tobin C. Harding)
f79f20d4e6 Remove stale rustdoc (Tobin C. Harding)
Pull request description:
When signing a Taproot input (in a PSBT) using a key path spend we currently return the pubkey associated with key that signs. However it is common to think of the internal key as being the one that signs even though this is not technically true. We also have the internal key in the PSBT so matching against it is less surprising.
When using the `Psbt` type to sign a Taproot input using a key path spend return the internal key.
- Patch 1: Fix stale docs
- Patch 2: Remove unnecessary panic
- Patch 3: Change the key returned when signing Taproot input as key path spend
Done as part of #2557, this is the release blocking part.
ACKs for top commit:
sanket1729:
ACK 14040e2ff5
apoelstra:
ACK 14040e2ff5
Tree-SHA512: 0b38b9009fd5dab682461dcb79f46c7540ec79cfd9c856fc5036ad8ecda061781c58b6fd157db9f034ab07dda6fa747417318f613092ee2017b8f2f44898dcd7
398fc6b73a Update pre-commit hook to use pinned nightly (Tobin C. Harding)
1a85eac01b Move nightly_version file to crate root (Tobin C. Harding)
Pull request description:
Move the nightly pinning config file out of `.github/` and use it in the pre-commit hook.
ACKs for top commit:
sanket1729:
ACK 398fc6b73a
apoelstra:
ACK 398fc6b73a
Tree-SHA512: 9b30c7064a43b068399927518732c3f4fe033693a7ad09af33f49b18a31c8965e6d4bb887ee558dd2a8d50b165545eb3de3fa7c415bff27efee5ac97385d27ff
The nightly pinning is used by a bunch of different tools outside of
github actions, move the config file to the crate root.
Update the path in the justfile.
Done in preparation for fixing the git pre-commit hook.
We just did a minor bug fix to error code in the `amounts` module. This
change did not effect the public API but improved the display of two
error types from that module.
In preparation for doing a point release bump the version number and add
a changelog entry.
We have 2 crates that require an allocator, `bitcoin` and `base58ck` -
these crates should enable the "alloc" feature when depending on
`internals`.
For `units` we use the `internals::error::InputString` but do not enable
the "alloc" feature - this is a bug, it means that the parsed string is
being lost from the error types that use `InputString`.
Enable "alloc" for `bitcoin`, `base58ck`, and `units`.
- `bitcoin` and `base56ck` is just for good measure so we don't get
bitten later on.
- `units` is a bug fix and requires a point release.
When signing a Taproot input (in a PSBT) using a key path spend we
currently return the pubkey associated with key that signs. However it
is common to think of the internal key as being the one that signs even
though this is not technically true. We also have the internal key in
the PSBT so matching against it is less surprising.
When using the `Psbt` type to sign a Taproot input using a key path
spend return the internal key.
There is no need to panic if input index is out of bounds because we
have a function to check the validity of the `input_index` argument and
use it in other places already.
f6467ac98d Minimize usage of Network in public API (Tobin C. Harding)
3ec5eff56e Add Magic::from_params (Tobin C. Harding)
Pull request description:
Minimize usage of the `Network` enum in the public API.
See #2225 for context, and https://github.com/rust-bitcoin/rust-bitcoin/pull/1291#discussion_r1492993788 for an interpretation of that long discussion.
Close: #2169
ACKs for top commit:
sanket1729:
reACK f6467ac98d.
apoelstra:
ACK f6467ac98d
Tree-SHA512: f12ecd9578371b3162382a9181f7f982e4d0661915af3cfdc21516192cc4abb745e1ff452649a0862445e91232f74287f98eb7e9fc68ed1581ff1a97b7216b6a
a05da2294e units: Add an initial changelog (Tobin C. Harding)
36ef4a62cf units: Improve re-exports (Tobin C. Harding)
Pull request description:
In preparation for release do two things:
- Patch 1: Attempt to improve the re-exports and HTML docs
- Patch 2: Add an initial changelog file
Note the version number is set already and does not conflict with the current `v0.0.0` version: https://crates.io/crates/bitcoin-units
ACKs for top commit:
sanket1729:
utACK a05da2294e
apoelstra:
ACK a05da2294e
Tree-SHA512: ab78f89d2e29e58e840d64889f0b7e0e57335e610b8759490478511854f1a7606e8203e4201872eaeb16a96fc527ecdca35e13b39027218d8f71290591e68101
In preparation for the initial release add a changelog. Note the version
number is already set to `v0.1.0` and this does not conflict with the
release currently on crates.io `v0.0.0`.
1bb32febbd Use manual docs attributes (Tobin C. Harding)
19f70959e1 Document private from_hex_internal function (Tobin C. Harding)
81a704302c Improve rustdocs on U256 type (Tobin C. Harding)
Pull request description:
Follow up to #2514, improve docs in the `pow` module. Done as separate patches because there are 3 distinct improvements. The first two are trivial the last can be verified by running:
`RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links`
ACKs for top commit:
apoelstra:
ACK 1bb32febbd
sanket1729:
ACK 1bb32febbd
Tree-SHA512: 13b9db4b184328fdea1f212b9d049c76b0b824bae822cd9f6cf9460a38f3ca3d2f7270d4c4ee2b9301a5a4049a30d82a706b8b5c8415573fa6724d5105093d97
A release or so ago we added `non_exhaustive` to the `Network` enum,
this turned out to make usage of the enum un-ergonomic for downstream
users. After much debate we decided that a way forward was to just
minimize the usage of the enum in the public API by instead use
`AsRef<Params>` so that downstream could define their own network enum
based on the networks they support.
Minimize usage of `Network` by using `AsRef<Params>` as a parameter type
instead. "minimize" because the `Network` still appears in some places.
Make an attempt to improve the ergonomics and docs clarity of the
`units` crate.
- Don't inline error type re-exports, this keeps them up in the
"Re-exports" section and saves cluttering the other inlined docs.
- Re-export and inline the docs for `FeeRate` and `Weight` same as we do
for `Amount`. This makes the "Structs" section of the docs nice except
for the exclusion of the locktime types (which cannot be helped).
Currently we are using `Self` (in backticks) in the docs to functions
defined by the `do_iml` macro, this is a bit lazy, we can do better than
that.
Use `doc` attribute and the `$ty` macro variable to construct the docs
to use the type name.
Use a code comment to document the calling restrictions of private
function `from_hex_internal`. (Code comment because comment is not well
formed as per convention in this codebase.)
Improve the rustdocs on the private `U256` type by doing:
- Remove link to self within constructors, just use backticks
- Use `U256` instead of `Self` or `self`
- Fix incorrect usage of `CompactTarget` [0]
[0] We knew this was wrong when we merged it but because the docs are
private we elected to do this follow up patch.
288ed33afa just: Use pinned nightly (Tobin C. Harding)
Pull request description:
Use the nightly version that we use in CI when running `just` commands that use the nightly toolchain.
ACKs for top commit:
apoelstra:
ACK 288ed33afa
sanket1729:
utACK 288ed33afa
Tree-SHA512: f19f8e41025a9c78d1d86ef13b2924321e1fad7e11c815960ea197d127a79423ca5f6bb447e878fc69c8bf9d34e278ca27f9d1bd5a75ca0a8a7539a7fa22c2c2
e1869340be Upgrade secp dependency (Tobin C. Harding)
Pull request description:
Upgrade `rust-secp256k1` to the latest version `v0.29.0`. This removes the duplicate deps as well.
Includes removal of usage of `ThirtyTwoByteHash` and enables usage of `Message::from(sighash)`.
ACKs for top commit:
sanket1729:
ACK e1869340be
apoelstra:
ACK e1869340be
Tree-SHA512: d2ae5f7fcac5f189d9a333025985d90a73af6cfcf7a55cf3a21e8b56c15e6327171ef3f38904fdd102ac1f39c567742bdf295133a52a506c39ca8c78500f2448
f019e24f1f Add hex parsing to pow types (Tobin C. Harding)
d33625f6e2 units: Introduce public hex_u128 function (Tobin C. Harding)
9705d51782 docs: Use backticks on stdlib type (Tobin C. Harding)
cf65bf035f Introduce local variable (Tobin C. Harding)
1269722770 Move helper function (Tobin C. Harding)
dca054c680 test: Add unit tests for hex_u32 (Tobin C. Harding)
Pull request description:
The `pow` types implement `fmt::LowerHex` but do not implement hex parsing.
Add inherent methods `from_hex` and `from_prefixed_hex` to the `pow` types - as we did for locktime types.
ACKs for top commit:
apoelstra:
ACK f019e24f1f
sanket1729:
ACK f019e24f1f
Tree-SHA512: d682e1259db1c2c0abe24a8ca137fc49abe0ed7ccce90de4d6058c7a4986d26c86a84289ec7377b9209648a57e0af6735c1eb3d39c9de6770fde1936f596dfd2
Currently `Magic` has per network consts but no way to dynamically get
the magic bytes for a network. Note also that we are currently trying to
reduce the usage of `Network` in the public API.
Add a public constructor to the `Magic` type that accepts a `Params`
parameter to determine the network to use.
The `pow` types implement `fmt::LowerHex` but do not implement hex
parsing.
Add inherent methods `from_hex` and `from_prefixed_hex` to the
`pow` types.
Move the `strip_hex_prefix` helper function to below where it is called.
Note that I was the original author of this helper so there is no excuse
for it being above - bad Tobin no biscuit.
fd6fedc3ad Improve API for max target threshold calculation (Tobin C. Harding)
6e47d57744 Rename difficulty transition threshold functions (Tobin C. Harding)
4121c9a09f Rename Params::pow_limit to max_attainable_target (Tobin C. Harding)
f0f6d3f162 Take Params instead of Network in difficulty function (Tobin C. Harding)
104dee9376 Debug assert that target != zero in difficulty calc (Tobin C. Harding)
c1ba496a07 Document current behaviour of difficulty_float (Tobin C. Harding)
3d01146374 Allow needless-borrows-for-generic-args (Tobin C. Harding)
2a6821b426 Use link to CompactTarget in rustdoc (Tobin C. Harding)
Pull request description:
When computing the maximum difficulty transition threshold we forgot to check that the returned `Target` is not bigger than the maximum. This value is network specific so keep the original logic but with `_unchecked` on the function name.
This was noted in the discussion on #2161
ACKs for top commit:
apoelstra:
ACK fd6fedc3ad
sanket1729:
ACK fd6fedc3ad
Tree-SHA512: 520ee2a07edb251c84b5ce8b48ed6e5a5c1945126dc7bcdb5570e97101ec4a3dc63fa7992725194869e22b21ee4f5955579d5e2499fcb48167637fd1fb3ae74d
The maximum target threshold has a network dependant upper bound.
Currently we are not checking this bound. One complication is that there
is currently heated open debate around the `Network` type.
We can bypass the `Network` issue by using `AsRef<Params>` instead.
Add a function that does the checks based on the `Params` type as well
as an unchecked version.
These two functions calculate the min/max threshold transition which is
a _target_ not a "difficulty" number. Using "difficulty" in the function
name is unnecessarily confusing.
Rename and deprecate the functions.
The maximum "attainable" target is a `rust-bitcoin` thing, Core use max
unattainable.
Deprecated the `Params::pow_limit` field and add a new field
`max_attainable_target`.
The `Params` type is `non_exhaustive` so this is not an API breaking
change.
What we really want is the maximum target, but since this is a const in
`Params` use an `AsRef<Params>` argument in the `difficulty` functions.
Requires implementation of `AsRef<Params> for Params`.
The `difficulty` calculation requires dividing a target value by `self`.
Add an assertion that `self` is not zero to help devs debug this.
Note that this should never really be hit, but its possible there is a
bug somewhere causing the target to be set to zero - so this may help
debugging.
Also, add panics section to rustdocs.