abc014a079 Move rustdoc above attribute (Tobin C. Harding)
e9230019eb Implement std::error::Error::source for MerkleBlockError (Tobin C. Harding)
613f1cf2d5 Implement std::error::Error::source for bip152 (Tobin C. Harding)
a37ab82503 Add non_exhaustive to _all_ errors (Tobin C. Harding)
Pull request description:
Do error cleanups, and add a script to help find missing `non_exhaustive` on error types
- Patch 1: Audit the codebase and put `non_exhaustive` on all error types.
- Patch 2: Implement `std::error::Error::source` for `bip152::Error`
- Patch 3: Implement `Display` and `std::error::Error::source` for `MerkleBlockError`
- Patch 4: Move rustdocs to above attributes on one error type
- ~Patch 5: Add a python script to `contrib` that checks the codebase for missing non exhaustive on the line above the results of regex `pub enum .*Error`~
I removed the Python script patch, I can't be bothered working on this for now but the clean ups and `non_exhaustive` additions are useful IMO.
### labels
- I added 'API break', I think the `non_exhaustive` addition requires major bump but not sure?
- release notes mention is just for the `non_exhaustive` patch.
ACKs for top commit:
Kixunil:
ACK abc014a079
apoelstra:
ACK abc014a079
Tree-SHA512: 16ea15014eae97de7ac9cca1e9b76304aa3702a98cde577c2d71343022f840d3b33a39d2ab6d3fba0f0f1ebaa1631a0595eea1d794ba9727fe6ccfcf08e2feae
We have a bunch of clippy warnings on master, at least one of them is
from a patch dated from March, before we ran clippy on CI.
Fix clippy warnings
- warning: accessing first element with `self.0.get(0)`
- warning: deref on an immutable reference
- warning: you are deriving `PartialEq` and can implement `Eq`
All one patch because clippy has to run cleanly for each patch on CI
now.
Please note the `Eq` change, adding this derive is an API change.
We are no using `non_exhaustive` on any error types unless we are
_really_ sure there will be no additional variants required.
There are only three error enums that do not have it in the codebase as
of this commit, add it to all three.
Add a `LockTime` type to hold the nLockTime `u32` value. Use it in
`Transaction` for `lock_time` instead of a `u32`. Make it public so this
new type can be used by rust-miniscript and other downstream projects.
Add a `PackedLockTime` type that wraps a raw `u32` and derives `Ord`,
this type is for wrapping a consensus lock time value for nesting in
types that would like to derive `Ord`.
This adds tests for serialization of BIP152 network messages and
tests specifically for the differential encoding of the transaction
indicies of 'getblocktx'. Previously, this code contained an
off-by-one error.