68f3c3e5d7 api: Run just check-api (Tobin C. Harding)
b956940a6d Add ops unit tests for amount types (Tobin C. Harding)
d88306fb68 units: Implement ops for amount types (Tobin C. Harding)
4a3aa4a08b Add ops unit tests for Weight (Tobin C. Harding)
43ef9a618c units: Implement ops for Weight (Tobin C. Harding)
c5fbc7e117 units: Add assign macros (Tobin C. Harding)
20a79da344 units: Use one level of path for ops traits (Tobin C. Harding)
6ce5385914 units: Add macros for Add and Sub (Tobin C. Harding)
b31ca72b33 units: Use rhs instead of other (Tobin C. Harding)
cd0fa2d1dc Make FeeRate ops impls more terse (Tobin C. Harding)
Pull request description:
Sort out `Add`, `AddAssign`, `Sub`, and `SubAssign` for the following types:
- `Amount`
- `SignedAmount`
- `FeeRate`
- `Weight`
And clean up as we go.
Note that `BlockInterval` isn't touched in this PR - it looks correct already.
The unit tests in the two patches "Add ops tests ..." can be moved if you want to verify that they don't build without the patch they follow.
ACKs for top commit:
apoelstra:
ACK 68f3c3e5d728a60a4b52ca64523770bcdd32f957; successfully ran local tests
Tree-SHA512: a82d3bf288f61b169b8cff498e81bd2cd123c8dcbf534413233ff03f06102a42508e09b2f7e5b268b21f82d4bf2b3612cd88dea1231b4d3e6455c7e99f82e729
f01f071751 api: document the need of cargo nightly (Jose Storopoli)
ff67eadc7f contributing: clarify API changes (Jose Storopoli)
04852958b9 contrib: check if the user has cargo-public-api (Jose Storopoli)
Pull request description:
Closes#3764.
yancyribbens can you test it locally? It works in my end both with and without `cargo-public-api`. Of course without gives the error message that I was supposed to see.
EDIT: You can run it with `just check-api`.
ACKs for top commit:
apoelstra:
ACK f01f071751332bb6aa8b9affa4677f913035de7f; successfully ran local tests
tcharding:
ACK f01f071751
Tree-SHA512: 7acf8332731191de47afc02e24c151bc53c1f38685217eccbea1b64c216674f31729ba703e132765cba67183dff95757aa949d653c5cbe538240371c2db52c14
815330dad2 Clean up weight unit tests (Tobin C. Harding)
3f4365ee0c api: Run just check-api (Tobin C. Harding)
75594c7299 Add Weight::to_kwu_ceil (Tobin C. Harding)
Pull request description:
It is not immediately obvious why we have floor and ceil versions of `to_vbytes` but not for `to_kwu`.
Add a conversion function to get weight by kilo weight units rounding up.
And then clean up the `weight` unit tests.
ACKs for top commit:
apoelstra:
ACK 815330dad2d2026ecf11c998dd560217c8d05d52; successfully ran local tests
Tree-SHA512: 8ba6c255fb9a3bc4a3dd485d6875663976870805a639b0aa309727fd211460029d05154351522d2b753afd478df1187abd92b212512b140c1ddb24b34b7e2bc0
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.
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.
010141ecc9 api: Run just check-api (Tobin C. Harding)
cf800a1b07 Remove bech32 dependency from blockdata (Tobin C. Harding)
Pull request description:
We have a single usage of the `bech32` crate inside the `blockdata` module, to convert a `WitnessVersion` to a `Fe32`. We then have a single call site where we use the conversion in the `address` module.
This code was written without thinking to hard about the introduced dependency on `bech32`, in hindsite it shouldn't have been added.
In preparation for splitting a bunch of code in `blockdata` out into the `primitives` crate remove the `bech32` stuff from the `witness_version` module.
ACKs for top commit:
Kixunil:
ACK 010141ecc9
apoelstra:
ACK 010141ecc9
Tree-SHA512: 2d368ebf64ab7197b421e0dec48623f3fb03243081a988ff9ed2070135c8741efe24520c2aab496d54c52595808f10ee39816eaab8e3e4a7e64955cd25285670
a7731b2f33 api: Run just check-api (Marko Bencun)
47cba7a655 bip32: add from_32_slice method to DerivationPath (Marko Bencun)
Pull request description:
ChildNumber already has a `From<u32>` impl, but converting `&[u32]` to a `DerivationPath` was still difficult.
ACKs for top commit:
Kixunil:
ACK a7731b2f33
tcharding:
ACK a7731b2f33
Tree-SHA512: 2db94ee035e686102b8201f637422bb96bd79858aeffdb007594d722902d31a20f27e61b88fae8c854c80f785d9e7837b0158a046639ff8cc2d20d8883391842
dc10a49876 api: Run just check-api (Tobin C. Harding)
5e8f204581 Pass sigs and associated types by value (Tobin C. Harding)
Pull request description:
We should pass `Copy` types by value not by reference.
Currently this is not done in secp, but lets do it here in bitcoin.
Pass by value:
- `SerializedSignature`
- bitcoin sigs
- secp sigs
- secp `Message`
This is a continuation of the work to split up #2404 into manageable PRs.
ACKs for top commit:
apoelstra:
ACK dc10a49876
Kixunil:
ACK dc10a49876
Tree-SHA512: 8736eba067c74edb951c92357f5b3d0fc99c4fa6dc3beea579c10b3150873b74e8ec46c2c01f18818b37fca6e77c6b6edddeb6340edde6a9d8c28a4e69164c8c
6a7f780018 api: Run just check-api (Tobin C. Harding)
0c9223ac05 Manually format write_err statement (Tobin C. Harding)
43d7c750cc taproot: Add error types (Tobin C. Harding)
afe41c8a39 taproot: Split errors up (Tobin C. Harding)
Pull request description:
Currently there are a couple of errors in the `taproot` module that are too general, resulting in functions that return a general error type when a specific one would do.
Split two errors out and use them for for enum variants and function returns as possible.
Done as part of #2883
ACKs for top commit:
Kixunil:
ACK 6a7f780018
apoelstra:
ACK 6a7f780018
Tree-SHA512: bf5ed50dd8f913280d007f03124c7918c4b6cd642e67726bc3ffff23d9897f764a4391e167115668c3a1e951197485eba280fdbb8a0ce1bb7efb051388d13997
10440b36a2 api: Run just check-api (Shing Him Ng)
452a7cc091 Re-export public functions, enums, and structs from units::parse in the bitcoin crate root (Shing Him Ng)
Pull request description:
Re-export UnprefixedHexError in the bitcoin crate root
Fixes#2874
ACKs for top commit:
tcharding:
ACK 10440b36a2
Tree-SHA512: 78a0676aa6d6fe63d810eeeebd3bf053d679d966d0aebf752760bfb440b2d4e831b0ff6b54b0306b390126b3f96a70c0846b4a1ec20aca96994d4a7b75e438e3
872ba938cc api: Run just check-api (Tobin C. Harding)
264d080054 hashes: Add hash type alias' (Tobin C. Harding)
d2632d3d8a hashes: Re-export Hkdf (Tobin C. Harding)
Pull request description:
In an effort to make the `hashes` crate more ergonomic to use add a bunch of type alias' to the crate root.
We intentionally do not rename the `foo::Hash` types so that uses have a choice of either using the module path to differentiate or to use the alias.
Update the crate level docs to use the alias' because they are more terse with no loss of clarity.
ACKs for top commit:
Kixunil:
ACK 872ba938cc
Tree-SHA512: 3635a72e0b9a1d05e49e83ba24bed80c87b8f5fa0b3260e8dd5a5fc130b6cc22e041e2b1798cd04d78c759f3c6e839c754c63afd9b7c3d5de5319a8abc8f5b12
362c3b8772 api: Run just check-api (Jamil Lambert, PhD)
9ea8c58ad6 Fix case sensitivity of denomination (Jamil Lambert, PhD)
67569ca632 Remove denominations < 1 satoshi (Jamil Lambert, PhD)
Pull request description:
The denomination `MilliSatoshi` has been removed from `Amount`.
`NanoBitcoin` and `PicoBitcoin` have also been removed since they are also less than 1 satoshi and the same reason for removing milliSatoshi in Issue #2820 should apply to them.
The second patch fixes the way the denominations with various combinations of upper and lower case are handled when converted from a string.
Close: #2820
ACKs for top commit:
Kixunil:
ACK 362c3b8772
tcharding:
ACK 362c3b8772
Tree-SHA512: d2dc23366023dae66705352822fbd25b90567971cbe0139ab6937b4dc419a1fd4681af1380232f39cd7844422e069d7861274eb2fd9bfe6730798271f1b50349
2bde5d002e api: Run just check-api (Jose Storopoli)
d1f84329e4 psbt: implement const for PsbtSighashType::ALL (Jose Storopoli)
Pull request description:
Closes#2751.
I only did the `ALL` which is by far the most common case.
ACKs for top commit:
tcharding:
ACK 2bde5d002e
apoelstra:
ACK 2bde5d002e
Tree-SHA512: 693575de758657a3e172d86ba5114ec0bf3b12b82df598e38c6a7916c99c20cfb5c4e74442108b51ae4e7bb1f1e940fd4a7269145e3f9838f727675c7711c890
There are a few green lines for the Tap*Hash types, which are tagged
hashes, and whose engine/from_engine impls are replaced. The rest is
red, for the other hashtypes where these methods are just dropped.
A later PR will also drop the methods for the Tap*Hash types but that
seemed different enough from the rest to warrant its own PR.
4652ce20ed API changes for "delete `all_zeros`" (Andrew Poelstra)
8869f35a69 hashes: drop the `all_zeros` method on arbitrary hashes (Andrew Poelstra)
9f8797f486 API changes for constification of hash constructors (Andrew Poelstra)
154e91af8c hashes: constify a bunch of constructors (Andrew Poelstra)
c155cbf8b2 hashes: use workaround to get constfns on tagged hashes with MSRV (Andrew Poelstra)
Pull request description:
I think these changes are both uncontroversial but they have fairly large diffs so I am PRing them together before making more invasive changes.
ACKs for top commit:
tcharding:
ACK 4652ce20ed
Tree-SHA512: 4560fa397deab50448598894b9364f9d8f8b48169901a84db6a44168cdba795ab69b48ad2cac61caebcee5e227a03271335b405cf5514265290a4d1f2fdf52a2
72655607b6 api: Run just check-api (Tobin C. Harding)
e8250cd96a Remove InvalidInternalKey variant from TaprootBuilderError (Tobin C. Harding)
Pull request description:
This variant is unused, remove it.
Done as part of #2883.
ACKs for top commit:
Kixunil:
ACK 72655607b6
apoelstra:
ACK 72655607b6
Tree-SHA512: 5cd27cacebcf078afdf1ceba4e3d51e78f20ee4883000b766efb7a246fd7a166240038a2e7d27249a22049c3258673a393ff2fd62cb4b27a2cade04b28ef2ac9
433fd6bf7e api: Run just check-api (Tobin C. Harding)
8fd583b069 Pass hash types by value (Tobin C. Harding)
Pull request description:
We should pass `Copy` types by value not by reference. Pass the hash types by value.
Second step in the pass-copy-types-by-value work, pulled out of #2404.
ACKs for top commit:
apoelstra:
ACK 433fd6bf7e
Kixunil:
ACK 433fd6bf7e
Tree-SHA512: 999d12f60550cacc4ae19b4cbf505b25c1eed803820f22b1a706e9f95da1b7e7b422f393f4115d579927c0c476cd504036a39b3cdc06a1d6befbcff5513f7433
As you can see from the - lines in the API diff, there is no reduction
in API surface (we just remove the T:Tag bound from the sha256t::Tag
type, which is not strictly necessary but maybe we would prefer to keep).
These changes are nontrivial. They
* Drop the `From` impls from (w)txids to (w)TxMerkleRoots
* Introduce a new trait and bound calculate_root on it...
* ...in such a way that its return value cannot be inferred without
further hints (though in practice this doesn't matter because usually
the return value is immediately assigned to something with a known
type such as a BlockHeader field)
9f01871c11 api: Run just check-api (Tobin C. Harding)
7929b51640 Pass keys by value (Tobin C. Harding)
Pull request description:
We should pass `Copy` types by value not by reference. Pass the key types by value.
This is patch 1 from #2404
ACKs for top commit:
apoelstra:
ACK 9f01871c11 this will annoy some people but I think we should do it
Tree-SHA512: 18afab537edf4ade4dc1c1e5992e50060b8935531f1e3cbe1d3b94b2fcb87aafa39947f342e0e762835bda3b4091dd35b3b74ea79f4dbb3b21660ffd21d1f82e
18b2788a5a api: Run just check-api (Tobin C. Harding)
6b7d02e5ae Add inherent functions to hashes (Tobin C. Harding)
Pull request description:
Currently we have a trait `Hash` that is required for `Hmac`, `Hkdf`, and other use cases. However, it is unegonomic for users who just want to do a simple hash to have to import the trait.
Add inherent functions to all hash types including those created with the new wrapper type macros.
This patch introduces some duplicate code but we are trying to make progress in the hashes API re-write. We can come back and de-dublicate later.
Includes making `to_byte_array`,`from_byte_array`, `as_byte_array`, and `all_zeros` const where easily possible.
ACKs for top commit:
apoelstra:
ACK 18b2788a5a
Tree-SHA512: 6b7a8d8a8501e981416d767040e5bd9fa8d1134be2ca133b5c53aa55f65c8456dccb63b642e30d0d571ca838c6f9eaeff6527d92a9b4212819a49ce619c4e093