Commit Graph

2325 Commits

Author SHA1 Message Date
Tobin C. Harding 6095a4de9b Use blockdata exports
We now export `blockdata` submodules at the crate root level. Use the
new exports for all rustdoc tests/examples.
2022-08-17 09:33:24 +10:00
Tobin C. Harding 4a119e5624 Re-export blockdata modules
In an effort to make the library more ergonomic to use re-export modules
from `blockdata` at the crate root level. This helps to decouple the
internal code layout with the public API.
2022-08-17 08:46:36 +10:00
sanket1729 deb867e33d
Merge rust-bitcoin/rust-bitcoin#1077: Move sighash types to the sighash module
cc2c67fc2d Move sighash types to the sighash module (Tobin C. Harding)
7c040f4437 Refactor imports (Tobin C. Harding)
29f21d6ff5 Add additional sighash related pubic exports (Tobin C. Harding)

Pull request description:

  This is non-urgent work, something I've wanted to do for months now, please only review at your leisure :)

  Currently we have a bunch of sighash types defined in the `transaction` module and we have a newer `sighash` module that defines a bunch of related types. This is an artifact of the development process as we added the new types. If we put things that are related together it makes it easier for devs to find their way around the library and grok the code.

  Move all the sighash types from the `blockdata::transaction` module to the `sighash` module.

  The first two patches are preparatory cleanup.

  ### Labels

  I added "API break" because I move the types without adding a re-export from the original place. I believe this is correct because we are, hopefully, aiming to de-couple the public API from the internal module structure so there is going to be a load more of this.

ACKs for top commit:
  apoelstra:
    ACK cc2c67fc2d
  sanket1729:
    ACK cc2c67fc2d

Tree-SHA512: 62a586b63c388baf91655a9afc8595394565d6ea6eb9aa3bd4746f899c140f332999e886cd85b098ec01304d2b96a310848d42d5ae38af476d3a26496576e36c
2022-08-15 23:05:20 -07:00
Andrew Poelstra 9f37fdd7d8
Merge rust-bitcoin/rust-bitcoin#1139: Do error cleanups
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
2022-08-15 22:12:13 +00:00
Tobin C. Harding abc014a079 Move rustdoc above attribute
It is customary in this repository to put the rustdoc above the
attributes.
2022-08-15 07:49:08 +10:00
Tobin C. Harding e9230019eb Implement std::error::Error::source for MerkleBlockError
The `MerkleBlockError` type does not implement `Display` or
`std::error::Error` - bad rust-bitcoin developers, no biscuit.
2022-08-15 07:49:06 +10:00
Andrew Poelstra 67e88e732c
Merge rust-bitcoin/rust-bitcoin#1170: Move `address` out of `util`
22fd107e16 Run rustfmt (Tobin C. Harding)
e1ae9d86bb Move the address module out of util (Tobin C. Harding)
6cc8b22f82 Run cargo fmt (Tobin C. Harding)

Pull request description:

  The identifier 'util' does not convey any real information. We have a whole bunch of modules inside the `util` module.

  As part of work to reduce the amount of arbitrary things in the `util` module move the `address` module to the crate root level.

  - Patch 1: fixes rustfmt issues currently on master, this patch is in heaps of my open PRs at the moment
  - Patch 2: Does the module move
  - Patch 3: Runs the formatter, done separately so reviewers can run `rustfmt +nightly fmt` and check the diff

ACKs for top commit:
  sanket1729:
    ACK 22fd107e16. Reviewed range diff from 9e7998897639ddcf115296b72fbb74ed5d4592c8 which I previously ACKed.
  Kixunil:
    ACK 22fd107e16
  apoelstra:
    ACK 22fd107e16

Tree-SHA512: b1e3384b79b61e2a27bb4afa0a1a37f9da359bd4ab0a2338a45aa29e1a64394a97b552beafa55a8540ed7dcbd99fe6e1aea573dd37648e705b96176a96e0e27f
2022-08-12 17:00:18 +00:00
Tobin C. Harding cc2c67fc2d Move sighash types to the sighash module
Currently we have a bunch of sighash types defined in the `transaction`
module and we have a newer `sighash` module that defines a bunch of
related types. This is kruft from the development process as we added
the new types. If we put things that are related together it makes it
easier for devs to find their way around the library and grok the code.

Move all the sighash types from the `blockdata::transaction` module to
the `sighash` module.

Refactor only, no logic changes.
2022-08-12 07:57:37 +10:00
Tobin C. Harding 7c040f4437 Refactor imports
Clean up some imports, only do the ones that we are about to touch.

- Remove/add whitespace to group by crate
- move modules/types to their module instead of using lib wide
  re-export (this helps minimise future merge conflicts)

Re-order imports, refactor only. No logic changes.
2022-08-12 07:39:51 +10:00
Tobin C. Harding 29f21d6ff5 Add additional sighash related pubic exports
We already export some of the sighash related types, there are others
that are uniquely named that can also be exported. Doing so makes use of
the library more ergonomic because devs do not have to know where types
are defined.
2022-08-12 07:38:11 +10:00
Tobin C. Harding 22fd107e16 Run rustfmt
We just moved the `address` module out of `util` which is currently
ignored by `rustfmt`.

Run `rustfmt`, no other changes other than those made by the tool.
2022-08-12 07:35:15 +10:00
Tobin C. Harding e1ae9d86bb Move the address module out of util
The identifier 'util' does not convey any information. We have a whole
bunch of modules inside the `util` module.

As part of work to reduce the amount of arbitrary things in the `util`
module move the `address` module to the crate root level.
2022-08-12 07:35:15 +10:00
Tobin C. Harding 6cc8b22f82 Run cargo fmt
We have formatting issues on master because we do not yet run the
formatter in CI (PR is open).

We are about to move the `address` module to `/src` which will require
running the formatter.

Run `cargo fmt` to fix formatting issues, no other changes.
2022-08-12 07:35:15 +10:00
sanket1729 0eff9eb94a
Merge rust-bitcoin/rust-bitcoin#1182: Fix clippy warnings
7001e93ad5 Fix clippy warnings (Tobin C. Harding)

Pull request description:

  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.

ACKs for top commit:
  apoelstra:
    ACK 7001e93ad5
  sanket1729:
    ACK 7001e93ad5

Tree-SHA512: b59bf92a8222d236538fe38951a92d0daaf86fc19e4ec4752c0eaf3e5b59025953560d089c72141d90f72ea137ec70425b4fa438ebfae65160fbd8799b95af7d
2022-08-11 14:31:42 -07:00
Tobin C. Harding 7001e93ad5 Fix clippy warnings
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.
2022-08-12 05:50:58 +10:00
Andrew Poelstra 3c758c74cf
Merge rust-bitcoin/rust-bitcoin#1177: Remove accidentally-exported internal macros
94eeabfd6c Remove accidentally-exported internal macros (Martin Habovstiak)

Pull request description:

  Closes #1176

ACKs for top commit:
  sanket1729:
    reACK 94eeabfd6c
  apoelstra:
    ACK 94eeabfd6c

Tree-SHA512: 6c37c606499f1a9aa56ba6da02865de1638cbfe8fd1c45ef73ed936d9002e0079b1e5dcb13163f35a1c4effd6023692608afa32badef394b5604767d9bb9d80a
2022-08-11 13:31:50 +00:00
Andrew Poelstra cc5b6ef53a
Merge rust-bitcoin/rust-bitcoin#1163: Remove old deprecated code
dfb8ef97dc Remove deprecated MerkleBlock methods (Tobin C. Harding)
b171f88bc3 Remove deprecated SighashComponents struct (Tobin C. Harding)
c2bbf7c343 Use SighashCache instead of SigHashCache (Tobin C. Harding)
1c04a99ec3 Use sighash::SighashCache for bip143 unit tests (Tobin C. Harding)
f65e034742 Refactor test module imports (Tobin C. Harding)

Pull request description:

  I'm not sure what the exact policy we decided on for deprecating is but we have code deprecated since v0.24.0 and v.026.2, both of these seem reasonable safe to remove.

  Removal of `SighashCompontents` uncovered the fact that we never moved the BIP 143 test vector code over to the new `SighashCache`.

  - Patch 1: Trivial preparatory cleanup
  - Patch 2: Re-write bip143 test vectors using `sighash::SighashCache`
  - Patch 3: Trivial, use `SighashCache` instead of `SigHashCache`
  - Patch 4: Remove `SighashComponents` struct deprecated in 0.24.0
  - Patch 5: Remove `MerkleBlock` methods deprecated in 0.26.2

ACKs for top commit:
  apoelstra:
    ACK dfb8ef97dc
  sanket1729:
    ACK dfb8ef97dc

Tree-SHA512: 493525859a131307fbe3ea17f8edb70045dc56526d5579a4fc0d6e7c3fded58c890304721502d1cfceed0a61f4b3d1827a60760e42af0114f3b3ba29b136238c
2022-08-11 13:24:20 +00:00
Andrew Poelstra 0afe5f849d
Merge rust-bitcoin/rust-bitcoin#1166: Deprecate `Transaction`'s `signature_hash`/`encode_signing_data_to` methods
c062e4ff80 Deprecate legacy sighash methods (Tobin C. Harding)
1fdf5f9b82 Move legacy sighash unit test data to test_data (Tobin C. Harding)
6fa0329930 Re-order import statements (Tobin C. Harding)

Pull request description:

  When we introduced the `SighashCache` we put encoding and sighash code
  for segwit (v0 and taproo) in the `sighash` module. We also added
  methods for legacy inputs that wrapped calls to encode/sighash methods
  in the `transaction` module. This is confusing for a couple of reasons

  - When devs read `Transaction` there are two methods that apparently
  enable encodeing tx data and calculating the sighash but there is no
  indication that these methods are only for legacy inputs.

  - Once devs work out that segwit inputs have to be handled by methods on
  the `SighashCache` it is not obvious why the methods on `Transaction`
  exist at all.

  Move the legacy encode/sighash code over to the `sighash` module and
  deprecate the old methods. (Includes moving unit tests.)

  Patch 1 and 2 are preparation.

  (I did this work because I got lost in `Transaction::signature_hash` when messing with `TxOut::Amount` and trying to understand the signing algorithm vs bip143.

  sanket1729 is there some other reason that I'm missing why we left the legacy code in `transaction`?

ACKs for top commit:
  sanket1729:
    ACK c062e4ff80
  apoelstra:
    ACK c062e4ff80

Tree-SHA512: b94de928e64e652ec75e34af94d5d161f5c52a862b5b10904e980b8ae669b3b434f8639d5ddadad84a7bbdf36ac21bdd287398448e844b5bb531c3664e91fb02
2022-08-11 13:17:30 +00:00
Andrew Poelstra d29f81ad25
Merge rust-bitcoin/rust-bitcoin#1180: Clean up bip158 module
167ee8e72c Improve docs on bip158 module (Tobin C. Harding)
5cfe9169f5 Refactor tests module imports (Tobin C. Harding)
2447d96b44 Use Gcs instead of GCS (Tobin C. Harding)
e9846ad579 Improve docs on filter_header (Tobin C. Harding)
e0fddce9e9 Refactor new_script_filter (Tobin C. Harding)
f6105a16a7 Improve module docs (Tobin C. Harding)
25d1472924 Move new to top of impl block (Tobin C. Harding)
08e55bc4f1 Remove unneeded newlines (Tobin C. Harding)
28853fd3cc Use generics instead of dynamic dispatch (Tobin C. Harding)
d79c6b8358 Remove unnecessary use of Cursor (Tobin C. Harding)

Pull request description:

  In attempt to resolve #1147 clean up the `bip158` module.

  I was unable to resolve the `"confusing method names read and write that look like those from std:i:o::{trait}"`

  I find the `bip158` data types and abstractions kind a funky but was unable to come up with any improvements.

  Open question: Are all the public data types really meant to be public? Perhaps we should have an issue to write an example module that uses the bip158 module?

ACKs for top commit:
  sanket1729:
    ACK 167ee8e72c
  apoelstra:
    ACK 167ee8e72c

Tree-SHA512: 7caa661432f02d90cf32c13b54a635647b871bb1564d1df67957b6422465880fcfca8f74d51d4b0255dc34306a56cd866366febabc9a27ecdc00a2d1e6a21d5a
2022-08-11 13:05:17 +00:00
Martin Habovstiak 94eeabfd6c Remove accidentally-exported internal macros
Closes #1176
2022-08-11 11:10:56 +02:00
Tobin C. Harding c062e4ff80 Deprecate legacy sighash methods
When we introduced the `SighashCache` we put encoding and sighash code
for segwit (v0 and taproo) in the `sighash` module. We also added
methods for legacy inputs that wrapped calls to encode/sighash methods
in the `transaction` module. This is confusing for a couple of reasons

- When devs read `Transaction` there are two methods that apparently
enable encodeing tx data and calculating the sighash but there is no
indication that these methods are only for legacy inputs.

- Ocne devs work out that segwit inputs have to be handled by methods on
the `SighashCache` it is not obvious why the methods on `Transaction`
exist at all.

Move the legacy encode/sighash code over to the `sighash` module and
deprecate the old methods. (Includes moving unit tests.)
2022-08-11 08:54:48 +10:00
Tobin C. Harding 1fdf5f9b82 Move legacy sighash unit test data to test_data
The legacy sighash test data is massive, move it to a file instead of
inline in the unit tests.
2022-08-11 08:54:48 +10:00
Tobin C. Harding 6fa0329930 Re-order import statements
In preparation for adding imports; do a trivial refactor to clean up the
import statements.

Refactor only, no logic changes.
2022-08-11 08:54:48 +10:00
Tobin C. Harding 167ee8e72c Improve docs on bip158 module
Make an effort to improve the rustdocs throughout the `bip158` module.
2022-08-11 08:42:43 +10:00
Tobin C. Harding 5cfe9169f5 Refactor tests module imports
Refactor the import statements for the bip158 tests module. Includes
removing `extern crate` which is unnecessary now we have edition 2018.
2022-08-11 08:42:43 +10:00
Tobin C. Harding 2447d96b44 Use Gcs instead of GCS
Rust convention stipulates that acronyms are in snake case not all caps.
We should use `Gcs` for Golomb Coded Sets
2022-08-11 08:42:43 +10:00
Tobin C. Harding e9846ad579 Improve docs on filter_header 2022-08-11 08:42:43 +10:00
Tobin C. Harding e0fddce9e9 Refactor new_script_filter
Refactor the `new_script_filter` by doing:

- Put it directly below the `new` constructor
- Improve docs
- Remove unneeded scope
- Correctly indent `where` keyword
2022-08-11 08:42:43 +10:00
Tobin C. Harding f6105a16a7 Improve module docs
Improve the module rustdocs for `bip158` by doing:

- Add bip references
- Use correct markdown headings
- Use caps in title
2022-08-11 08:42:43 +10:00
Tobin C. Harding 25d1472924 Move new to top of impl block
To ease reading, put the `new` method at the top of the impl block.
Improve rustdocs while we do it.
2022-08-11 08:42:43 +10:00
Tobin C. Harding 08e55bc4f1 Remove unneeded newlines
Conventionally we only put a single newline between types, impl blocks,
and functions.
2022-08-11 08:42:43 +10:00
Tobin C. Harding 28853fd3cc Use generics instead of dynamic dispatch
Currently in the `bip158` module we do a bunch of dynamic dispatch using
the reader/writer objects. We can improve runtime performance, at the
cost of compile time, by using generics instead of dynamic dispatch.
2022-08-11 08:42:43 +10:00
Tobin C. Harding d79c6b8358 Remove unnecessary use of Cursor
The function `match_all` takes an iterator, it does not need to use the
`Seek` trait, we can just pass in the content as a slice, no need to
wrap it in a `Cursor`.
2022-08-11 08:42:43 +10:00
Andrew Poelstra 9a606fc68a
Merge rust-bitcoin/rust-bitcoin#1178: Pin `serde` to 1.0.142
7a28a56ac4 Pin `serde` to 1.0.142 (Martin Habovstiak)

Pull request description:

  1.0.143 bumps MSRV higher than what we support.

  Closes #1175

  Unfortunately I have to go now, will try to get back ASAP.

ACKs for top commit:
  apoelstra:
    ACK 7a28a56ac4
  tcharding:
    ACK 7a28a56ac4

Tree-SHA512: 09546984d3d68c24068cb357e4a57db223cea6b48e32471fab551998d8afe46eeaac2e6a49ec3d8bf2cc9767b564f12ccd6022ef8167d8e5eefdc6c898f3077a
2022-08-10 21:43:13 +00:00
Martin Habovstiak 7a28a56ac4 Pin `serde` to 1.0.142
1.0.143 bumps MSRV higher than what we support.
2022-08-09 15:59:27 +02:00
Andrew Poelstra 8a30169d36
Merge rust-bitcoin/rust-bitcoin#1109: Release tracking PR - v0.29.0
110b5d8963 Bump version to v0.29.0 (Tobin C. Harding)

Pull request description:

  Add changelog notes and bump the version number to v0.29.0.

  ## Notes

  I attempted to go through all the PRs since last release, please sing out if you had a PR merged that is not mentioned and you would like it mentioned.

  The changelog notes can be changed or improved, please do not take me writing them to imply I know exactly what goes on round here - I just made an effort to save others having to do it.

  ## TODO
  - [x]  merge all 'required' PRs
    - https://github.com/rust-bitcoin/rust-bitcoin/pull/1131
    - #1137
    - https://github.com/rust-bitcoin/rust-bitcoin/pull/1129
    - https://github.com/rust-bitcoin/rust-bitcoin/pull/1151
    - https://github.com/rust-bitcoin/rust-bitcoin/pull/1165 (add release notes still)
  - [x] Ensure all green from the CI run on: https://github.com/rust-bitcoin/rust-miniscript/pull/450
  - [ ] Carry out (and improve) the https://github.com/rust-bitcoin/rust-bitcoin/discussions/1106

ACKs for top commit:
  tcharding:
    ACK 110b5d8963
  Kixunil:
    ACK 110b5d8963
  apoelstra:
    ACK 110b5d8963
  sanket1729:
    reACK 110b5d8963

Tree-SHA512: d00c70534476794c01cd694ea9a23affef947c4f913b14344405272bc99cc00763f1ac755cc677e7afbd3dbef573d786251c9093d5dbafd76ee0cf86ca3b0ebd
2022-08-08 18:32:46 +00:00
Andrew Poelstra 995c83c38c
Merge rust-bitcoin/rust-bitcoin#1171: Remove `MAX_SEQUENCE` constant
b6c5fc3622 Remove MAX_SEQUENCE const (Tobin C. Harding)

Pull request description:

  This is follow up work to the recent addition of the `Sequence` type. We
  do not need to keep a public integer const for `MAX_SEQUENCE` because we
  offer the `Sequenc::MAX` associated type.

  Use the all-bits-set u64 directly in the associated type `Sequence::MAX`.

  cc nlanson

ACKs for top commit:
  Kixunil:
    ACK b6c5fc3622
  apoelstra:
    ACK b6c5fc3622

Tree-SHA512: c0acacc25d7cb2f8774e8c6dee8acb3faca0bf6cbd657054ea7262f26b4dfe8baaf2066662966dc507d26716c0468c97d09c590deec48ecd9d11a415ab2bf9ff
2022-08-05 14:40:46 +00:00
Tobin C. Harding b6c5fc3622 Remove MAX_SEQUENCE const
This is follow up work to the recent addition of the `Sequence` type. We
do not need to keep a public integer const for `MAX_SEQUENCE` because we
offer the `Sequenc::MAX` associated type.

Use the all-bits-set u64 directly in the associated type `Sequence::MAX`.
2022-08-05 13:53:37 +10:00
Tobin C. Harding 613f1cf2d5 Implement std::error::Error::source for bip152
During the recent merge of bip152 we ended up with a Rust 1.29 version
of the `error::Error`.

Implement `source` inline with our new MSRV.
2022-08-05 11:19:37 +10:00
Tobin C. Harding a37ab82503 Add non_exhaustive to _all_ errors
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.
2022-08-05 11:19:37 +10:00
Tobin C. Harding 110b5d8963 Bump version to v0.29.0
Add changelog notes and bump the version number to v0.29.0.
2022-08-05 11:14:41 +10:00
sanket1729 9bac1a0b8b
Merge rust-bitcoin/rust-bitcoin#1165: Update bitcoinconsensus dependency
7f554774a3 Update bitcoinconsensus dependency (Tobin C. Harding)

Pull request description:

  We recently released a couple of new versions of
  `rust-bitcoinconsensus`, the first was mainly to move to git subtree,
  included in this release was a bump of the patch version of bitcoin
  core. The next release updated bitcoin core major version to 0.20.2

  Update our bitcoinconsensus dependency to `0.20.2-0.5.0`.

ACKs for top commit:
  apoelstra:
    ACK 7f554774a3
  sanket1729:
    utACK 7f554774a3

Tree-SHA512: e30857846e6dcf237e6c87ea5cce81f091104772ce3293c8b7193f253aab3176627466ca41fc3764c949edb4f6c4ae5dc00968d71a4492e19a8a1a1e9dba7013
2022-08-04 16:26:14 -07:00
Tobin C. Harding 7f554774a3 Update bitcoinconsensus dependency
We recently released a couple of new versions of
`rust-bitcoinconsensus`, the first was mainly to move to git subtree,
included in this release was a bump of the patch version of bitcoin
core. The next release updated bitcoin core major version to 0.20.2

Update our bitcoinconsensus dependency to `0.20.2-0.5.0`.
2022-08-04 08:21:41 +10:00
Tobin C. Harding dfb8ef97dc Remove deprecated MerkleBlock methods
We have two methods that have been deprecated since 0.26.2,  we can
safely remove them now.
2022-08-03 12:34:51 +10:00
Tobin C. Harding b171f88bc3 Remove deprecated SighashComponents struct
This struct was deprecated in v0.24.0, we can safely remove it now.
2022-08-03 12:34:50 +10:00
Tobin C. Harding c2bbf7c343 Use SighashCache instead of SigHashCache
The `bip143::SigHashCache` is deprecated in favour of
`sighash::SighashCache` however we still use it in `bip143` unit tests.

Use the new `sighash::SighashCache` in `bip143` unit tests.
2022-08-03 12:30:20 +10:00
Tobin C. Harding 1c04a99ec3 Use sighash::SighashCache for bip143 unit tests
We have a bunch of unit tests that verify the BIP 143 test vectors.
Three of these use the deprecated `SighashComponents` struct. We should
implement these tests using the new `SighashCache`. In order to do so we
have to move the tests to the `sighash` module so they can get access to
the private `segwit_cache()` function, and verify the cache internal
state against the test vectors.

Re-write the BIP 143 test vector code using `SighashCache` and remove
the versions using `SighashComponents`.

Done in preparation for removing the deprecated `SighashComponents`.
2022-08-03 12:22:31 +10:00
Tobin C. Harding f65e034742 Refactor test module imports
In preparation for adding unit tests to the `sighash` module clean up
the import statements.

Refactor only, no logic changes.
2022-08-03 11:56:27 +10:00
Andrew Poelstra 5d44b2dda6
Merge rust-bitcoin/rust-bitcoin#1161: Fix public API clippy warnings
5cef2f1a8f Remove stutter for error variants (Tobin C. Harding)
08c4a2204a Allow wrong_self_convention for non-Copy type (Tobin C. Harding)
0786d92a5c Take self by value (Tobin C. Harding)

Pull request description:

  [Turns out](https://github.com/rust-lang/rust-clippy/issues/9248) by default clippy does not lint certain parts of the public API.

  Specifically, by setting `avoid-breaking-exported-api = false` we can get clippy to lint the public API for various things including
  `wrong_self_convention`.

  This means the saga of to/into/as continues ... we have used the wrong from for many of our `to_*` methods, they should consme `self`. Patch 1 fixes them. Patch 2 adds an `allow`. Patch 3 fixes a few error enum variant identifiers (removes `Error` suffix).

ACKs for top commit:
  Kixunil:
    ACK 5cef2f1a8f
  sanket1729:
    code review ACK 5cef2f1a8f
  apoelstra:
    ACK 5cef2f1a8f

Tree-SHA512: f1cdb94764a132a7c58f3e97a208f3f8d618e4f2620753d0394590b19d3dab0df7669e187f6e0a3d0aa358a7d8aee5495f78008f244b6eedb33715ff1df151b1
2022-08-02 14:37:58 +00:00
Tobin C. Harding 5cef2f1a8f Remove stutter for error variants
Error variants should not end with the same identifier as the enum,
i.e., they should not stutter.

Found by clippy after setting:

  avoid-breaking-exported-api = false
2022-08-02 08:55:00 +10:00