Commit Graph

1873 Commits

Author SHA1 Message Date
Tobin C. Harding 281af7c1b9 Move broken-intra-doc-link lint config to command line
The docs lint `broken-intra-doc-links` has been changed but the new name
is not available in our MSRV, this means we get a build warning. We only
build docs with the nightly toolchain so we can move this lint control
to the docs build command in `test.sh` instead of doing it crate wide.

With this patch applied devs risk not noticing docs link issues until
they hit them on CI _if_ they do not build with the test script or
explicitly pass in `-- -D rustdoc::broken-intra-doc-links`, which no one
is going to do. Hence we add a line to the readme with a shell alias
that can be used to check docs, taken directly from `test.sh`.
2022-06-21 09:21:19 +10:00
Andrew Poelstra e7a3bdda66
Merge rust-bitcoin/rust-bitcoin#1053: Implement iter::size_hint and ExactSizeIterator for Witness Iter
ec8dadaf86 Implement iter::size_hint and ExactSizeIterator for Witness Iter (Riccardo Casatta)

Pull request description:

  close https://github.com/rust-bitcoin/rust-bitcoin/issues/1050

  I don't think we need to change the `collect` since it use the `size_hint()` lower bound to initially allocate

  // with size_hint
  // test blockdata::witness::benches::bench_big_witness_to_vec              ... bench:         313 ns/iter (+/- 13)
  // test blockdata::witness::benches::bench_witness_to_vec                  ... bench:         204 ns/iter (+/- 11)

  // without
  // test blockdata::witness::benches::bench_big_witness_to_vec              ... bench:         489 ns/iter (+/- 28)
  // test blockdata::witness::benches::bench_witness_to_vec                  ... bench:         221 ns/iter (+/- 102)

  The reason why the small witness doesn't get big perf boost is because by default vec allocates 4 slots

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

Tree-SHA512: dbe09ba6ebd4014fe0639412894beedab6cc7e844a5ec1697af8f0694b62ae5d423a801df1b48ac7029444c01877975e2d5168728f038fbd4f5808bda90e0f2f
2022-06-16 13:35:24 +00:00
Andrew Poelstra e00b0c39ca
Merge rust-bitcoin/rust-bitcoin#1042: Refactor `serve_tcp` code
abfeb32e35 Remove unnecessary local variable (Tobin C. Harding)
04b09a4e8d Remove unused loop (Tobin C. Harding)
380e0016cc Use write_all instead of write (Tobin C. Harding)

Pull request description:

  Done while clearing clippy warnings, done as a separate PR because its not a simple glance to review like the others.

  Remove 2 clippy warnings and remove unnecessary local variable.

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

Tree-SHA512: 965708999c067dd8c156bbc54b711f608d524fab7051a0e56066f53b5c8d7bea1c233f04e77873b2624cd22e26a58f1d22f47870d2afe4347aa85335c3142245
2022-06-16 12:53:20 +00:00
Riccardo Casatta ec8dadaf86
Implement iter::size_hint and ExactSizeIterator for Witness Iter
// with size_hint
// test blockdata::witness::benches::bench_big_witness_to_vec              ... bench:         313 ns/iter (+/- 13)
// test blockdata::witness::benches::bench_witness_to_vec                  ... bench:         204 ns/iter (+/- 11)

// without
// test blockdata::witness::benches::bench_big_witness_to_vec              ... bench:         489 ns/iter (+/- 28)
// test blockdata::witness::benches::bench_witness_to_vec                  ... bench:         221 ns/iter (+/- 102)
2022-06-16 10:42:58 +02:00
Andrew Poelstra f30df076d0
Merge rust-bitcoin/rust-bitcoin#1051: Add getter methods for PartialMerkleTree fields
9ff0e06810 Add getter methods for PartialMerkleTree fields (eunoia_1729)

Pull request description:

  Resolves: #1046

ACKs for top commit:
  apoelstra:
    ACK 9ff0e06810
  tcharding:
    ACK 9ff0e06810

Tree-SHA512: 849f2bf87ab99a8f975ee9c78eaaf3b8d392c3338317d94234ceb9da0d78bddd488c67dfb3ded1c572d5ce400c10263d75815315a4cd52b80cd6b60e12d55078
2022-06-15 13:27:10 +00:00
Andrew Poelstra d363cd2ebc
Merge rust-bitcoin/rust-bitcoin#1039: Fix incorrect argument passed to Error::InvalidSegwitV0ProgramLength and add test
24fdb53c9c Fix incorrect argument passed to Error::InvalidSegwitV0ProgramLength (eunoia_1729)

Pull request description:

  See also: #995, #1038

ACKs for top commit:
  sanket1729:
    utACK 24fdb53c9c. Nice catch
  apoelstra:
    ACK 24fdb53c9c
  tcharding:
    ACK 24fdb53c9c

Tree-SHA512: ced78b69054ec81431399a853291c7bad5b1a49d6683b1ac153a0f1449935bb5d75a31e3d86160602064530959a2ddc3c59a2a2ca268252c42a6805253ead9d0
2022-06-15 13:26:12 +00:00
eunoia_1729 9ff0e06810
Add getter methods for PartialMerkleTree fields 2022-06-11 15:36:59 +05:30
eunoia_1729 24fdb53c9c
Fix incorrect argument passed to Error::InvalidSegwitV0ProgramLength 2022-06-11 07:04:20 +05:30
sanket1729 09dd83add5
Merge rust-bitcoin/rust-bitcoin#1048: Removed edition change heads up from CONTRIBUTING
7743be00cf Removed edition change heads up from CONTRIBUTING (Martin Habovštiak)

Pull request description:

  It is done.

ACKs for top commit:
  apoelstra:
    ACK 7743be00cf
  sanket1729:
    ACK 7743be00cf

Tree-SHA512: 9cc63a97d959061db1b04757fbf993a5f2cf0e1fff388b23a8729995bf764aced18b3ef49ec25a5a324d8e49168b9e841baf2118f0769fc8689f46c3d9b3463c
2022-06-09 12:02:16 -07:00
Martin Habovštiak 7743be00cf
Removed edition change heads up from CONTRIBUTING
It is done.
2022-06-09 15:26:49 +02:00
sanket1729 8670c53d26
Merge rust-bitcoin/rust-bitcoin#1034: README: remove stale info about upcoming edition change
29cfdc8614 README: remove stale info about upcoming edition change (Dawid Ciężarkiewicz)

Pull request description:

  It is done.

ACKs for top commit:
  tcharding:
    ACK 29cfdc8614
  apoelstra:
    ACK 29cfdc8614
  sanket1729:
    ACK 29cfdc8614

Tree-SHA512: fc5b694229e4a3ebcc8f25cd4d73b65cb798d441934b2e2b473c0811367bb9c5bd6cfae9e5b68b072e3c6320f386ab54138b8589a57fc0816702474ab6de06f8
2022-06-09 01:38:47 -07:00
Andrew Poelstra 3ed3d574dc
Merge rust-bitcoin/rust-bitcoin#1038: Modify from_script functions in address.rs to return result
66e852cd19 Update format of ExcessiveScriptSize error message (eunoia_1729)
89bd4b61a4 Modify from_script functions in address.rs to return result (eunoia_1729)

Pull request description:

  Modify from_script functions to return result instead of option so that, in case of errors, there is more
  information on what went wrong.

  Resolves: #1022

ACKs for top commit:
  sanket1729:
    ACK 66e852cd19. LGTM
  tcharding:
    ACK 66e852cd19
  apoelstra:
    ACK 66e852cd19

Tree-SHA512: 0d9529aee0a5459351bed2cc8b2c5571736d3293e2931c43d98f53330e9ac5f3d998a19da2b4575af0a3c1c4dcfd5a24c8813390bf6f5492a689c36ebb9cb426
2022-06-08 23:59:35 +00:00
eunoia_1729 66e852cd19
Update format of ExcessiveScriptSize error message 2022-06-09 01:22:23 +05:30
eunoia_1729 89bd4b61a4
Modify from_script functions in address.rs to return result
Modify from_script functions to return result instead of option so that, in case of errors, there is more
information on what went wrong.

Resolves: #1022
2022-06-09 01:13:51 +05:30
Andrew Poelstra 8fd700859a
Merge rust-bitcoin/rust-bitcoin#1043: Clear clippy warnings from `--all-targets`
271d0ba068 Allow many arguments in test function (Tobin C. Harding)
c0c88fe87d Use vec instead of pushing to a mutable vector (Tobin C. Harding)
73066e7e48 Use values() to iterate map values (Tobin C. Harding)
38ff025122 Remove useless use of vec! (Tobin C. Harding)
d8e82d5cd4 Remove length comparison to zero (Tobin C. Harding)
c1f34f5c0e Return Address directly (Tobin C. Harding)
ff8d585c17 Use flat_map instead of map().flatten() (Tobin C. Harding)
b24a112f08 Remove calls to clone from types that implement Copy (Tobin C. Harding)
2b8d93ec4b Remove unnecessary explicit reference (Tobin C. Harding)
ef90e3d4ed Use plus-equals operator (Tobin C. Harding)
922b820105 Replace assert!(false) with panic! (Tobin C. Harding)
a8039e1742 Remove redundant clone (Tobin C. Harding)
cf8de73169 Remove unnecessary cast of integer literal (Tobin C. Harding)
999ac450bb Do not use assert_eq with literal bool (Tobin C. Harding)
827fcd8a89 Allow unusual digit grouping (Tobin C. Harding)
242c640603 Remove redundant field names (Tobin C. Harding)
0f8f4c5609 Collapse if statements (Tobin C. Harding)
229fcb9f1f Use if let instead of destructuring pattern (Tobin C. Harding)

Pull request description:

  Clear all the clippy warnings (excl. #1042) that are returned by running `cargo clippy --all-targets`.

  I apologize in advance for the review burden :)

ACKs for top commit:
  elichai:
    ACK 271d0ba068
  apoelstra:
    ACK 271d0ba068

Tree-SHA512: 71ad2ec3db808e795791b7513f8b2a1c13dc90317f5328602c9ecbc31c09f82471f79c9c31a71a0ded5280554d1019d2bb4899fb9e8fa6421d46a2397cd31242
2022-06-08 12:50:37 +00:00
Tobin C. Harding 271d0ba068 Allow many arguments in test function
This is a unit test helper function, it is ok to have a whole bunch of
arguments.
2022-06-07 15:34:59 +10:00
Tobin C. Harding c0c88fe87d Use vec instead of pushing to a mutable vector
Clippy emits:

  warning: calls to `push` immediately after creation

Use `vec` instead of pushing to a mutable vector.
2022-06-07 15:34:59 +10:00
Tobin C. Harding 73066e7e48 Use values() to iterate map values
Clippy emits:

  warning: you seem to want to iterate on a map's values

As suggested, iterate using `values`.
2022-06-07 15:34:59 +10:00
Tobin C. Harding 38ff025122 Remove useless use of vec!
Clippy warns of useless use of `vec!` macro, remove it.
2022-06-07 15:34:58 +10:00
Tobin C. Harding d8e82d5cd4 Remove length comparison to zero
Clippy emits:

  warning: length comparison to zero

Remove length comparison to zero, use `!is_empty`.
2022-06-07 15:26:59 +10:00
Tobin C. Harding c1f34f5c0e Return Address directly
Clippy emits:

  warning: returning the result of a `let` binding from a block

Remove the local binding, return the `Address` directly.
2022-06-07 15:26:59 +10:00
Tobin C. Harding ff8d585c17 Use flat_map instead of map().flatten()
Clippy emits:

  warning: called `map(..).flatten()` on `Iterator`

As suggested, use `flat_map` instead of chaining `map` with `flatten`.
2022-06-07 15:26:59 +10:00
Tobin C. Harding b24a112f08 Remove calls to clone from types that implement Copy
Clippy emits:

  warning: using `clone` on type `blockdata::transaction::OutPoint`
  which implements the `Copy` trait

Remove calls to `clone` from types that implement `Copy`.
2022-06-07 15:26:59 +10:00
Tobin C. Harding 2b8d93ec4b Remove unnecessary explicit reference
Clippy warns about creating a reference that is immediately
de-referenced.

Remove unnecessary explicit `&`, while we are at it remove unnecessary
explicit types that appear on the same lines of code.
2022-06-07 15:26:59 +10:00
Tobin C. Harding ef90e3d4ed Use plus-equals operator
Clippy emits:

  warning: manual implementation of an assign operation

Use the more conventional `+=` operator.
2022-06-07 15:15:26 +10:00
Tobin C. Harding 922b820105 Replace assert!(false) with panic!
Clippy emits:

  warning: `assert!(false)` should probably be replaced

As suggested, replace assert with a call to panic.
2022-06-07 15:15:26 +10:00
Tobin C. Harding a8039e1742 Remove redundant clone
Clippy emits:

  warning: redundant clone

Remove the redundant calls to clone.
2022-06-07 15:15:26 +10:00
Tobin C. Harding cf8de73169 Remove unnecessary cast of integer literal
Clippy emits:

  warning: casting integer literal to `usize` is unnecessary

Remove the unnecessary cast.
2022-06-07 15:15:26 +10:00
Tobin C. Harding 999ac450bb Do not use assert_eq with literal bool
Clippy emits:

  warning: used `assert_eq!` with a literal bool

Use `assert!` instead of `assert_eq!(foo, true)`.
2022-06-07 15:15:25 +10:00
Tobin C. Harding abfeb32e35 Remove unnecessary local variable
In test functions; we bind to `istream` only to re-bind immediately to
`stream`, this is unnecessary and adds no additional information to the
code.
2022-06-07 14:56:06 +10:00
Tobin C. Harding 04b09a4e8d Remove unused loop
We only simulate a single connection in the test function `serve_tcp`.
Remove the unused loop (includes an unconditional break after first
iteration) and use `next` directly.

Found by clippy. Refactor only, no logic changes.
2022-06-07 14:56:06 +10:00
Tobin C. Harding 380e0016cc Use write_all instead of write
In this unit test we want to write all the pieces, use `write_all`.

Clears clippy warning about not using return value of `write`.
2022-06-07 14:55:54 +10:00
Tobin C. Harding 827fcd8a89 Allow unusual digit grouping
Clippy emits:

  warning: digits grouped inconsistently by underscores

Add allow directive for grouping that aims to make explicit 100,000,000
sats/per bitcoin.
2022-06-07 14:29:15 +10:00
Tobin C. Harding 242c640603 Remove redundant field names
Clippy emits:

  warning: redundant field names in struct initialization

As suggested, remove redundant field names in struct initialization.
2022-06-07 14:26:57 +10:00
Tobin C. Harding 0f8f4c5609 Collapse if statements
Clippy emits:

  warning: this `if` statement can be collapsed

As suggested, collapse the if statements into a single statement, with
no loss of clarity.
2022-06-07 14:24:44 +10:00
Tobin C. Harding 229fcb9f1f Use if let instead of destructuring pattern
Clippy emits:

 warning: you seem to be trying to use `match` for destructuring a
 single pattern. Consider using `if let`

As suggested, use `if let`.
2022-06-07 14:22:38 +10:00
Andrew Poelstra a9365375c1
Merge rust-bitcoin/rust-bitcoin#1037: Document `Txid` being displayed backwards
28049ce2d9 Document `Txid` being displayed backwards (Dawid Ciężarkiewicz)

Pull request description:

  Fix #958

  I hope putting it on the most notorious type where people actually notice it is enough. I couldn't find a good way to put it on all other `sha256d` automatically, and copy pasting it seems not worth it.

ACKs for top commit:
  tcharding:
    ACK 28049ce2d9
  apoelstra:
    ACK 28049ce2d9

Tree-SHA512: a5acf5d7a73361a6c48b45ed264fafb911930ae9f1bdb03895dc39c679d508dc56dbf44896fd38cf6569abb652e7fce721028ef06344462747a77078ef5a8f4f
2022-06-06 11:35:13 +00:00
Dawid Ciężarkiewicz 28049ce2d9 Document `Txid` being displayed backwards
Fix #958
2022-06-04 12:08:16 -07:00
Andrew Poelstra de17554a3c
Merge rust-bitcoin/rust-bitcoin#1033: Avoid allocation in build_scriptint
c80dbc2169 Avoid allocation in build_scriptint (Steven Roose)

Pull request description:

  Hehe, reason for party, let's invite apoelstra !

ACKs for top commit:
  apoelstra:
    ACK c80dbc2169
  tcharding:
    ACK c80dbc2169

Tree-SHA512: 8446e765d8b9fa562f636817327db6fad4bb9c906d3f69fda76e61cd258fc4c296e6ffaa440a357125c2ab45603eb05c58cb8d6822deea2fe5746e5c7c3f1e4d
2022-06-03 18:27:21 +00:00
Dawid Ciężarkiewicz 29cfdc8614 README: remove stale info about upcoming edition change
It is done.
2022-06-02 21:07:23 -07:00
Steven Roose c80dbc2169
Avoid allocation in build_scriptint 2022-06-02 15:36:45 +01:00
Andrew Poelstra 21f4493813
Merge rust-bitcoin/rust-bitcoin#1032: Remove network::Error
99aab446c3 Remove network::Error (Tobin C. Harding)

Pull request description:

  The `network::Error` is not used, remove it.

  (This description has been changed, the thumbs up emojis were put on the previous PR description.)

ACKs for top commit:
  sanket1729:
    reACK 99aab446c3
  apoelstra:
    ACK 99aab446c3

Tree-SHA512: 2342531160966860b7b65f8c5df10e169876ec446e6fd30093d5d81d0b0304cad04e2c2057eb3ca6b23a2fc56453c91ad4ddf426d3796fb301acb7f7d03a66b9
2022-06-02 14:14:41 +00:00
Andrew Poelstra adf3958127
Merge rust-bitcoin/rust-bitcoin#1011: Add non_exhaustive compiler directive to `AddressType`
43b684bbe6 Add non_exhaustive compiler directive to AddressType (Tobin C. Harding)

Pull request description:

  Add non_exhaustive compiler directive to AddressType

  Currently adding variants to enums is a breaking change. In an effort to
  reduce the upgrade burden on users we can use the `non_exhaustive`
  compiler directive so that adding a new variant does not cause
  downstream code to break.

  Add `non_exhaustive` to the `AddressType` since it may be extended in
  the future.

ACKs for top commit:
  sanket1729:
    ACK 43b684bbe6
  Kixunil:
    ACK 43b684bbe6
  apoelstra:
    ACK 43b684bbe6

Tree-SHA512: 2b2a15fb501d23058acca94318776ffcccedf463d43d07afa290fba46a7bd58b3a730f6e1f25605ef399afcfdb5de4c7ad67eaa0adff0ba39b0096cbcec10f57
2022-06-02 14:13:52 +00:00
Tobin C. Harding 43b684bbe6 Add non_exhaustive compiler directive to AddressType
Currently adding variants to enums is a breaking change. In an effort to
reduce the upgrade burden on users we can use the `non_exhaustive`
compiler directive so that adding a new variant does not cause
downstream code to break.

Add `non_exhaustive` to the `AddressType` since it may be extended in
the future.
2022-06-02 12:43:25 +10:00
Tobin C. Harding 99aab446c3 Remove network::Error
The `network::Error` is not used, remove it.
2022-06-02 09:49:33 +10:00
Andrew Poelstra 09b4198b16
Merge rust-bitcoin/rust-bitcoin#1031: refactor: remove SchnorrSignatureHash::Reserved variant
69707b0ccd refactor: remove SchnorrSignatureHash::Reserved variant (eunoia_1729)

Pull request description:

  Resolves #1030

ACKs for top commit:
  sanket1729:
    utACK 69707b0ccd. For reference to other reviewers:
  tcharding:
    ACK 69707b0ccd
  apoelstra:
    ACK 69707b0ccd

Tree-SHA512: d5afe9217e15db8dfd7d712e2fa69d22acda0f93fd7efbc80cf9459303a135a69c8ddf43842584769accb8cffba722ec202dc51f100e0f50262b2561a2fb1699
2022-06-01 23:27:30 +00:00
sanket1729 165cae959a
Merge rust-bitcoin/rust-bitcoin#1003: Improve error `Display` implementations
57dd6739c3 Do not print error when displaying for std builds (Tobin C. Harding)
b80cfeed85 Bind to error_kind instead of e (Tobin C. Harding)
241ec72497 Bind to b instead of e (Tobin C. Harding)
01f481bf5c Bind to s instead of e (Tobin C. Harding)
5c6d369289 network: Remove unused error variants (Tobin C. Harding)
e67e97bb37 Put From impl below std::error::Error impl (Tobin C. Harding)
6ca98e5275 Remove error TODO (Tobin C. Harding)

Pull request description:

  As part of the ongoing error improvement work and as a direct result of [this comment](https://github.com/rust-bitcoin/rust-bitcoin/pull/987#issuecomment-1135563287) improve the `Display` implementations of all our error types so as to not repeat the source error when printing.

  The first 5 patches are trivial clean ups around the errors. Patch 6 is the real work.

  EDIT: ~CC @Kixunil, have I got the right idea here bro?~ Patch 6 now includes a macro as suggested.

ACKs for top commit:
  Kixunil:
    ACK 57dd6739c3
  apoelstra:
    ACK 57dd6739c3
  sanket1729:
    ACK 57dd6739c3. Did not check if we covered all cases. We need to remember to use `write_err!` instead of `write!` in future.

Tree-SHA512: 1ed26b0cc5f9a0f71684c431cbb9f94404c116c9136be696434c56a2f56fd93cb5406b0955edbd0dc6f8612e77345c93fa70a70650118968cc58e680333a41de
2022-06-01 15:17:24 -07:00
sanket1729 911a9ec579
Merge rust-bitcoin/rust-bitcoin#1018: Add more documentation to some core types
1875c912c3 Extend docstring for more types (Dawid Ciężarkiewicz)
325ea8fb7d Add "Relevant BIPs` to `Address` (Dawid Ciężarkiewicz)
7c2ca3d20b Add `BlockHeader` Bitcoin Core reference link (Dawid Ciężarkiewicz)
f4922f6fe7 Update `BlockHeader::version` documentation (Dawid Ciężarkiewicz)

Pull request description:

  This is meant to make it more educational, and handy even for experienced developers.

  A first step to make https://docs.rs/bitcoin (or `cargo doc --open`) a go-to place for
  convenient Bitcoin documentation.

ACKs for top commit:
  tcharding:
    tACK 1875c912c3
  apoelstra:
    ACK 1875c912c3
  sanket1729:
    utACK 1875c912c3. Thanks for doing this.

Tree-SHA512: 8457e120f9979bfd95e55e8b18faf6131610aa2241f8e5fc4630fe61dc7e16ddfc35fb6eff46339804016db7b176465943cc0c02d84dcf478ed55da9f5e06fc5
2022-06-01 15:06:35 -07:00
eunoia_1729 69707b0ccd
refactor: remove SchnorrSignatureHash::Reserved variant 2022-06-02 03:18:58 +05:30
sanket1729 471f90923d
Merge rust-bitcoin/rust-bitcoin#1006: Feature `use-serde` renamed to `serde`
2e7effc604 Feature `use-serde` renamed to `serde` (Martin Habovstiak)

Pull request description:

  Features activating external crates are supposed to have same name as
  those crates. However we depend on same feature in other crates so we
  need a separate feature. After MSRV bump it is possible to rename the
  crates and features so we can now fix this inconsistency.

  Sadly, derive can't see that the crate was renamed so all derives must
  be told to use the other one.

  Replaces #373

ACKs for top commit:
  apoelstra:
    ACK 2e7effc604

Tree-SHA512: b20364b9e8f30c2269bef915e821b2b2ec929e71dd0e88af2bc3a021821f87011d35e095cb8efe99add77a23dde940a17537eb387fb4582b05c57c8679969eb0
2022-06-01 14:29:02 -07:00