Commit Graph

3831 Commits

Author SHA1 Message Date
Tobin C. Harding 1fe90223aa
Remove DO_COV
We have test coverage by way of `coveralls` now. Remove the old stale
`DO_COV` stuff.

Fix: #1853
2024-01-23 14:27:10 +11:00
Tobin C. Harding dae16f052c
Use any method on iterator
We have `Iterator::any` which better shows whats going on in this loop.

Refactor only, no logic changes.
2024-01-23 10:48:33 +11:00
Tobin C. Harding 671dc0e9e0
Use better predicate name
This function is a predicate, it should have identifier `uses` not
`use`.
2024-01-23 10:46:23 +11:00
Tobin C. Harding 9eeadaab98
bitcoin: Remove bech32 from the public API
The only place that `bech32` appears in the pubic API is as a pub extern
crate re-export. This is totally unnecessary since no other `bech32`
functions or types appear in the public API.

Removing `bech32` from the public API allows us to stabilize
`rust-bitcoin` without waiting for `bech32` to stabalize - WIN.
2024-01-23 10:21:10 +11:00
Andrew Poelstra d08d3efdfa
Merge rust-bitcoin/rust-bitcoin#2336: units: Enable parsing Amount from `u64::MAX`
b2344e019d units: Assert roundtrip SignedAmount/str overflows (Tobin C. Harding)
baadcf4c0a units: Test that SignedAmount float conversion overflows (Tobin C. Harding)
d768f25da8 units: Remove duplicate assertion (Tobin C. Harding)
1d536ac8b2 units: Enable parsing Amount from u64::MAX (Tobin C. Harding)

Pull request description:

  Our `Amount` type uses an internal `u64` and we maintain no invariants on the inner value. Therefore we should be able to parse `u64::MAX`.

  Fix the parsing code by removing the explicit, incorrect check and fix unit tests to mirror this behaviour.

  Fix: #2297

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

Tree-SHA512: 944f8d0bfedc559f0444f75eca7d3fba042fbc204c4c032d09ff0edc29be280a3707f5b363dbc04f0d7bdf64701c0c4619e2e0de683d804a2663c2a20ac963f6
2024-01-22 19:13:12 +00:00
Andrew Poelstra 8b9c2ae9cc
Merge rust-bitcoin/rust-bitcoin#2365: Add automated labeler job
c6c5f07880 Add automated labeler job (Martin Habovstiak)

Pull request description:

  Rather than modifying the labels manually, which we often forget, we can label the PRs automatically. This will make it easier to search PRs.

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

Tree-SHA512: d3f7ca8c69cc8734d914f871675568ca293e28c3dc7351ee54b9237645204b87d1b47db02863b27d930900ae4b41d6f169f130ed9f4c750d4afbb765921cfb66
2024-01-22 17:41:34 +00:00
Andrew Poelstra 463911d15b
Merge rust-bitcoin/rust-bitcoin#2378: Bump actions/cache from 3 to 4
bc3dd7c36e Bump actions/cache from 3 to 4 (dependabot[bot])

Pull request description:

  Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
  <details>
  <summary>Release notes</summary>
  <p><em>Sourced from <a href="https://github.com/actions/cache/releases">actions/cache's releases</a>.</em></p>
  <blockquote>
  <h2>v4.0.0</h2>
  <h2>What's Changed</h2>
  <ul>
  <li>Update action to node20 by <a href="https://github.com/takost"><code>@takost</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1284">actions/cache#1284</a></li>
  <li>feat: save-always flag by <a href="https://github.com/to-s"><code>@to-s</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1242">actions/cache#1242</a></li>
  </ul>
  <h2>New Contributors</h2>
  <ul>
  <li><a href="https://github.com/takost"><code>@takost</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1284">actions/cache#1284</a></li>
  <li><a href="https://github.com/to-s"><code>@to-s</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1242">actions/cache#1242</a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/actions/cache/compare/v3...v4.0.0">https://github.com/actions/cache/compare/v3...v4.0.0</a></p>
  <h2>v3.3.3</h2>
  <h2>What's Changed</h2>
  <ul>
  <li>Cache v3.3.3 by <a href="https://github.com/robherley"><code>@robherley</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1302">actions/cache#1302</a></li>
  </ul>
  <h2>New Contributors</h2>
  <ul>
  <li><a href="https://github.com/robherley"><code>@robherley</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1302">actions/cache#1302</a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/actions/cache/compare/v3...v3.3.3">https://github.com/actions/cache/compare/v3...v3.3.3</a></p>
  <h2>v3.3.2</h2>
  <h2>What's Changed</h2>
  <ul>
  <li>Fixed readme with new segment timeout values by <a href="https://github.com/kotewar"><code>@kotewar</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1133">actions/cache#1133</a></li>
  <li>Readme fixes by <a href="https://github.com/kotewar"><code>@kotewar</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1134">actions/cache#1134</a></li>
  <li>Updated description of the lookup-only input for main action by <a href="https://github.com/kotewar"><code>@kotewar</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1130">actions/cache#1130</a></li>
  <li>Change two new actions mention as quoted text by <a href="https://github.com/bishal-pdMSFT"><code>@bishal-pdMSFT</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1131">actions/cache#1131</a></li>
  <li>Update Cross-OS Caching tips by <a href="https://github.com/pdotl"><code>@pdotl</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1122">actions/cache#1122</a></li>
  <li>Bazel example (Take <a href="https://redirect.github.com/actions/cache/issues/2">#2</a>️⃣) by <a href="https://github.com/vorburger"><code>@vorburger</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1132">actions/cache#1132</a></li>
  <li>Remove actions to add new PRs and issues to a project board by <a href="https://github.com/jorendorff"><code>@jorendorff</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1187">actions/cache#1187</a></li>
  <li>Consume latest toolkit and fix dangling promise bug by <a href="https://github.com/chkimes"><code>@chkimes</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1217">actions/cache#1217</a></li>
  <li>Bump action version to 3.3.2 by <a href="https://github.com/bethanyj28"><code>@bethanyj28</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1236">actions/cache#1236</a></li>
  </ul>
  <h2>New Contributors</h2>
  <ul>
  <li><a href="https://github.com/vorburger"><code>@vorburger</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1132">actions/cache#1132</a></li>
  <li><a href="https://github.com/jorendorff"><code>@jorendorff</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1187">actions/cache#1187</a></li>
  <li><a href="https://github.com/chkimes"><code>@chkimes</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1217">actions/cache#1217</a></li>
  <li><a href="https://github.com/bethanyj28"><code>@bethanyj28</code></a> made their first contribution in <a href="https://redirect.github.com/actions/cache/pull/1236">actions/cache#1236</a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/actions/cache/compare/v3...v3.3.2">https://github.com/actions/cache/compare/v3...v3.3.2</a></p>
  <h2>v3.3.1</h2>
  <h2>What's Changed</h2>
  <ul>
  <li>Reduced download segment size to 128 MB and timeout to 10 minutes by <a href="https://github.com/kotewar"><code>@kotewar</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1129">actions/cache#1129</a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/actions/cache/compare/v3...v3.3.1">https://github.com/actions/cache/compare/v3...v3.3.1</a></p>
  <h2>v3.3.0</h2>
  <h2>What's Changed</h2>
  <ul>
  <li>Bug: Permission is missing in cache delete example by <a href="https://github.com/kotokaze"><code>@kotokaze</code></a> in <a href="https://redirect.github.com/actions/cache/pull/1123">actions/cache#1123</a></li>
  </ul>
  <!-- raw HTML omitted -->
  </blockquote>
  <p>... (truncated)</p>
  </details>
  <details>
  <summary>Changelog</summary>
  <p><em>Sourced from <a href="https://github.com/actions/cache/blob/main/RELEASES.md">actions/cache's changelog</a>.</em></p>
  <blockquote>
  <h1>Releases</h1>
  <h3>3.0.0</h3>
  <ul>
  <li>Updated minimum runner version support from node 12 -&gt; node 16</li>
  </ul>
  <h3>3.0.1</h3>
  <ul>
  <li>Added support for caching from GHES 3.5.</li>
  <li>Fixed download issue for files &gt; 2GB during restore.</li>
  </ul>
  <h3>3.0.2</h3>
  <ul>
  <li>Added support for dynamic cache size cap on GHES.</li>
  </ul>
  <h3>3.0.3</h3>
  <ul>
  <li>Fixed avoiding empty cache save when no files are available for caching. (<a href="https://redirect.github.com/actions/cache/issues/624">issue</a>)</li>
  </ul>
  <h3>3.0.4</h3>
  <ul>
  <li>Fixed tar creation error while trying to create tar with path as <code>~/</code> home folder on <code>ubuntu-latest</code>. (<a href="https://redirect.github.com/actions/cache/issues/689">issue</a>)</li>
  </ul>
  <h3>3.0.5</h3>
  <ul>
  <li>Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. (<a href="https://redirect.github.com/actions/cache/pull/834">PR</a>)</li>
  </ul>
  <h3>3.0.6</h3>
  <ul>
  <li>Fixed <a href="https://redirect.github.com/actions/cache/issues/809">#809</a> - zstd -d: no such file or directory error</li>
  <li>Fixed <a href="https://redirect.github.com/actions/cache/issues/833">#833</a> - cache doesn't work with github workspace directory</li>
  </ul>
  <h3>3.0.7</h3>
  <ul>
  <li>Fixed <a href="https://redirect.github.com/actions/cache/issues/810">#810</a> - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.</li>
  </ul>
  <h3>3.0.8</h3>
  <ul>
  <li>Fix zstd not working for windows on gnu tar in issues <a href="https://redirect.github.com/actions/cache/issues/888">#888</a> and <a href="https://redirect.github.com/actions/cache/issues/891">#891</a>.</li>
  <li>Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable <code>SEGMENT_DOWNLOAD_TIMEOUT_MINS</code>. Default is 60 minutes.</li>
  </ul>
  <h3>3.0.9</h3>
  <ul>
  <li>Enhanced the warning message for cache unavailablity in case of GHES.</li>
  </ul>
  <h3>3.0.10</h3>
  <ul>
  <li>Fix a bug with sorting inputs.</li>
  <li>Update definition for restore-keys in README.md</li>
  </ul>
  <!-- raw HTML omitted -->
  </blockquote>
  <p>... (truncated)</p>
  </details>
  <details>
  <summary>Commits</summary>
  <ul>
  <li><a href="13aacd865c"><code>13aacd8</code></a> Merge pull request <a href="https://redirect.github.com/actions/cache/issues/1242">#1242</a> from to-s/main</li>
  <li><a href="53b35c5439"><code>53b35c5</code></a> Merge branch 'main' into main</li>
  <li><a href="65b8989fab"><code>65b8989</code></a> Merge pull request <a href="https://redirect.github.com/actions/cache/issues/1284">#1284</a> from takost/update-to-node-20</li>
  <li><a href="d0be34d544"><code>d0be34d</code></a> Fix dist</li>
  <li><a href="66cf064d47"><code>66cf064</code></a> Merge branch 'main' into update-to-node-20</li>
  <li><a href="1326563738"><code>1326563</code></a> Merge branch 'main' into main</li>
  <li><a href="e71876755e"><code>e718767</code></a> Fix format</li>
  <li><a href="01229828ff"><code>0122982</code></a> Apply workaround for earlyExit</li>
  <li><a href="3185ecfd61"><code>3185ecf</code></a> Update &quot;only-&quot; actions to node20</li>
  <li><a href="25618a0a67"><code>25618a0</code></a> Bump version</li>
  <li>Additional commits viewable in <a href="https://github.com/actions/cache/compare/v3...v4">compare view</a></li>
  </ul>
  </details>
  <br />

  [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/cache&package-manager=github_actions&previous-version=3&new-version=4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

  Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

  [//]: # (dependabot-automerge-start)
  [//]: # (dependabot-automerge-end)

  ---

  <details>
  <summary>Dependabot commands and options</summary>
  <br />

  You can trigger Dependabot actions by commenting on this PR:
  - `@dependabot rebase` will rebase this PR
  - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
  - `@dependabot merge` will merge this PR after your CI passes on it
  - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
  - `@dependabot cancel merge` will cancel a previously requested merge and block automerging
  - `@dependabot reopen` will reopen this PR if it is closed
  - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
  - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

  </details>

ACKs for top commit:
  apoelstra:
    ACK bc3dd7c36e will one-ACK merge

Tree-SHA512: 1fc6f89603bfd7b192107451c3e998a6605db16b8102b3851a07b2de110cd1691f53e113285356f3b38582fcf17423fb80fbcbef7ef3881082c0cbca820d5a86
2024-01-22 15:01:53 +00:00
Andrew Poelstra ce1704a6e7
Merge rust-bitcoin/rust-bitcoin#2268: Add convenience constants to `Denomination`
22747149a9 Add convenience constants to `Denomination` (Martin Habovstiak)

Pull request description:

  `Denomination::Bitcoin` and `Denomination::Satoshi` are often used, especially in test code so this change adds `BTC` and `SAT` - short, readable constants. Notably this doesn't add the other constants as that would lead to either unidiomatic names or confusing casing (MSAT meaning millisat not megasat) and they are not used that much anyway.

ACKs for top commit:
  apoelstra:
    ACK 22747149a9
  tcharding:
    ACK 22747149a9

Tree-SHA512: fb49e61c28f5df14d5432a81ec946a367696fe36e96798d35831cd5cb88b813fe3aa1e7be201997956b4d4f6e5431e4da20d0d24e4d6c036aa199fc9b9c87da1
2024-01-22 13:55:27 +00:00
Martin Habovstiak 3c4f6850f4 Flatten trivial errors.
The errors `SegwitV0Error` and `LegacyScripthashError` contained only
one variant - out of range. There will not be a new one in the future so
this change flattens it to simplify.
2024-01-22 14:20:33 +01:00
dependabot[bot] bc3dd7c36e
Bump actions/cache from 3 to 4
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 10:53:21 +00:00
Tobin C. Harding b2344e019d
units: Assert roundtrip SignedAmount/str overflows
Add a unit test to prove that attempting to roundtrip a `SignedAmount`
greater than `MAX` through a string fails.
2024-01-22 09:14:26 +11:00
Tobin C. Harding baadcf4c0a
units: Test that SignedAmount float conversion overflows
We should not be able to roundtrip a `SignedAmount` value greater than
`MAX`, add a test to prove so.

While we are at it document the assertion above that proves we can parse
a float representing an `Amount` greater than `SignedAmount::MAX`.
2024-01-22 09:08:54 +11:00
Tobin C. Harding d768f25da8
units: Remove duplicate assertion
Unit test has a duplicate assertion, remove it.
2024-01-22 09:06:26 +11:00
Andrew Poelstra ff51619c79
Merge rust-bitcoin/rust-bitcoin#2364: Test: add invalid segwit transaction test
fe8d559d69 test: add invalid segwit transaction test (startup-dreamer)

Pull request description:

  Tries to close #2183

  Added the test for invalid segwit transaction (witness flag is set but no witness is present) using [This suggested hex](https://github.com/rust-bitcoin/rust-bitcoin/issues/2183#issuecomment-1901207149) by Kixunil

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

Tree-SHA512: 723027e0ad9944a4763fba1e12398d7bcacdef691a40168f0be7cecdb170936f7e0c3690c4de911d086b8c5d42f5a25784f53fe096404f5cf69d6fc75c645d6e
2024-01-21 14:45:34 +00:00
Martin Habovstiak 22747149a9 Add convenience constants to `Denomination`
`Denomination::Bitcoin` and `Denomination::Satoshi` are often used,
especially in test code so this change adds `BTC` and `SAT` - short,
readable constants. Notably this doesn't add the other constants as that
would lead to either unidiomatic names or confusing casing (MSAT meaning
millisat not megasat) and they are not used that much anyway.
2024-01-20 22:12:52 +01:00
Martin Habovstiak c6c5f07880 Add automated labeler job
Rather than modifying the labels manually, which we often forget, we can
label the PRs automatically. This will make it easier to search PRs.
2024-01-20 16:35:37 +01:00
Andrew Poelstra 782c2d17bd
Merge rust-bitcoin/rust-bitcoin#2361: Add github action for llvm-cov coverage
47b476ec5b Ignore fuzz dir from coverage reports (pool2win)
50ff68550c Add github action for llvm-cov coverage (pool2win)

Pull request description:

  There has been discussion around generating coverage reports for tests. See #1853  and #2353.

  This PR adds an action using llvm-cov and coveralls.

  The action generates lcov coverage report using llvm-cov and uploads the generated report to coveralls. You can see sample reports for my fork here: https://coveralls.io/github/pool2win/rust-bitcoin

  I am using the [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) wrapper around llvm-cov.

  I also use the coveralls official github action to push the coverage report to coveralls. It removes the need to deal with repository secrets etc, making the action easy to run for all contributors on their forks.

  We can move this action later to rust.yml if we need to.

ACKs for top commit:
  apoelstra:
    ACK 47b476ec5b
  Kixunil:
    ACK 47b476ec5b
  tcharding:
    ACK 47b476ec5b

Tree-SHA512: 7a7b8caf94d4b4828416bc1e6df49bfe47fede7b8fa4386d905a6f40439a95df1d3fedecdd6d64675f2f6858851f18d2f8863994aa20ac1ab224f97ca48b4af2
2024-01-20 14:31:32 +00:00
startup-dreamer fe8d559d69
test: add invalid segwit transaction test 2024-01-19 23:12:08 +05:30
pool2win 47b476ec5b
Ignore fuzz dir from coverage reports 2024-01-19 18:09:59 +01:00
Martin Habovstiak a4d01d0b6c Factor out `io::Error` from sighash errors
The hadnling of `io::Error` in sighash had a few problems:

* It used `io::ErrorKind` instead of `io::Error` losing inforation
* Changing `io::ErrorKind` to `io::Error` would disable `PartialEq`&co
* The `Io` error wariants were duplicated

It turns out all of these can be solved by moving the `Io` variant into
a separate error.
2024-01-19 17:10:18 +01:00
Andrew Poelstra 01c8f2021e
Merge rust-bitcoin/rust-bitcoin#2358: Remove quadratic algorithm
a338a61cc3 Remove quadratic algorithm (Tobin C. Harding)

Pull request description:

  Currently we loop over transaction inputs within a loop over transaction inputs - ouch.

  Cache the `use_segwit_serialization` outside the iteration loop.

  Fix: #2357

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

Tree-SHA512: 91d0b46b235db57d9c28fc8da5d43a52c76a29916797a4ec44273b91eb120a928050a79cdbd704b922635dd2130db7b6e7863fd10e878eee52882c661af54c11
2024-01-19 15:27:06 +00:00
Andrew Poelstra 111094ca9e
Merge rust-bitcoin/rust-bitcoin#2329: Improve error handling in the `sighash` module
e356ff6611 Remove the now unused sighash::Error type (Tobin C. Harding)
c17324c574 Introduce segwit sighash error types (Tobin C. Harding)
f0b567313b Introduce sighash::LegacyError (Tobin C. Harding)
a1b21e2f1d Introduce sighash::TaprootError (Tobin C. Harding)
b0f20903a5 Introduce AnnexError (Tobin C. Harding)
a1a2056829 Add tx_in/tx_out accessor methods on Transaction (Tobin C. Harding)
f08aa16e91 Use Self:: in error return type (Tobin C. Harding)

Pull request description:

  Improve the error handling in the `sighash` module by adding small specific error types.

  Close: #2150

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

Tree-SHA512: e2e98a4caccae4e4acdc0e577e369fc90ee39a2206a8a1451739695fbe33ec2c3a52482b70cec8f9ee6bdb3ad7a2f4f639e8c87031878cd5d816fae24d913c42
2024-01-19 15:11:29 +00:00
Andrew Poelstra 783ba73799
Merge rust-bitcoin/rust-bitcoin#2356: Use full path in all macro usage of Result
61bf462806 Use full path in all macro usage of Result (josibake)

Pull request description:

  Follow-up to https://github.com/rust-bitcoin/rust-bitcoin/pull/2355

  Couldn't think of a clever way to do this , so just grepped for all instances of `macro_rules` and added the full path for the imports. Wasn't sure if it was necessary for `fmt::Result`, but went ahead and added the full path for consistency.

  Tested locally and confirmed this fixes the issue I was seeing.

ACKs for top commit:
  apoelstra:
    ACK 61bf462806
  Kixunil:
    ACK 61bf462806
  tcharding:
    ACK 61bf462806

Tree-SHA512: 8af105b3e6a36723804b290f8254f52e65cd42a61c323f1190e3bcbcb9e4427ff9b026a4530bafcd14aab644ccd9401fed351494457194c3a68a55f11b2a3d04
2024-01-19 13:48:33 +00:00
pool2win 50ff68550c
Add github action for llvm-cov coverage
The action reports the generated report to coveralls.
2024-01-19 11:06:25 +01:00
Tobin C. Harding e356ff6611
Remove the now unused sighash::Error type 2024-01-19 12:21:26 +11:00
Tobin C. Harding c17324c574
Introduce segwit sighash error types
Introduce two new error types to use for the segwit v0 sighash
calculation functions.
2024-01-19 12:21:26 +11:00
Tobin C. Harding f0b567313b
Introduce sighash::LegacyError
Introduce a `sighash::LegacyError` type and return it for all the
legacy sighash calculation functions.
2024-01-19 12:21:26 +11:00
Tobin C. Harding a1b21e2f1d
Introduce sighash::TaprootError
Introduce a `sighash::TaprootError` type and return it for all the
taproot sighash calculation functions.
2024-01-19 12:21:26 +11:00
Tobin C. Harding b0f20903a5
Introduce AnnexError
Split the annex related error out of the general `sighash::Error`.
2024-01-19 12:21:26 +11:00
Tobin C. Harding a1a2056829
Add tx_in/tx_out accessor methods on Transaction
In a few places in the codebase we want to grab an reference to an input
by index. To reduce code duplication add two methods on `Transaction`,
each to get a reference to an input or output respectively.

These are public methods, do not use them yet internally.
2024-01-19 12:21:25 +11:00
Tobin C. Harding a338a61cc3
Remove quadratic algorithm
Currently we loop over transaction inputs within a loop over transaction
inputs - ouch.

Cache the `use_segwit_serialization` outside the iteration loop.

Fix: #2357
2024-01-19 11:58:19 +11:00
Andrew Poelstra aa1fc35b1b
Merge rust-bitcoin/rust-bitcoin#2359: Fix cut'n'pasta error in map variable
bd41c836ab Fix cut'n'pasta error in map variable (Tobin C. Harding)

Pull request description:

  We are mapping outputs not inputs.

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

Tree-SHA512: 2f2f788662a56077ac7b3623a4c4969d3248a2f374368b6a08e7ae4fd04baefee72c75e961cfb4edb973396627ac869ad7845217572eb21460af8aad58b0fa55
2024-01-19 00:29:25 +00:00
Tobin C. Harding bd41c836ab
Fix cut'n'pasta error in map variable
We are mapping outputs not inputs.
2024-01-19 07:36:11 +11:00
josibake 61bf462806
Use full path in all macro usage of Result
If a user has defined their own alias for Result and tries to use a macro,
relative paths cause an issue. Use full paths to fix this.
2024-01-18 19:11:01 +01:00
Andrew Poelstra 9eec1082ec
Merge rust-bitcoin/rust-bitcoin#2354: Fix typos
b196f6b897 hashes: fix typos (Thabokani)
80665671cd bitcoin: fix typos (Thabokani)

Pull request description:

  bitcoin: fix typos
  hashes: fix typos

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

Tree-SHA512: 702e03a08f9500adf0ee7b7e565eeceba170691cb0ca281d8ff3ba904e857bb305c2504c48aa72a60a635508c31f98e379e31bbd5ad9685b1c241d86846ae074
2024-01-18 16:07:14 +00:00
Andrew Poelstra 1cfc7b0585
Merge rust-bitcoin/rust-bitcoin#2355: Use full path in all macro usage of Result
aa6e5cd342 Use full path in all macro usage of Result (Steven Roose)

Pull request description:

  Apparently when someone uses a custom `Result` type and then uses some of these macros, they can get type conflict errors.

  (Thanks josibake for finding this using the `sha256t_hash_newtype` macro.)

ACKs for top commit:
  josibake:
    utACK aa6e5cd342
  Kixunil:
    ACK aa6e5cd342
  apoelstra:
    ACK aa6e5cd342

Tree-SHA512: 04e51d6a4da520fd03f8c20c41707e43fc8d909de68533959373afd99e654068cedc5a6ca30bdc867a33e7e42b971a3bba623fad0fd294359948018ed55dc662
2024-01-18 15:48:21 +00:00
Andrew Poelstra 0d0eee5597
Merge rust-bitcoin/rust-bitcoin#2351: Remove `Cursor` usage in `PublicKey` unit test
3ea44a166b Remove usage of Cursor in pubkey sanity checks (Tobin C. Harding)
35b5350088 Remove usage of Cursor in multi key read (Tobin C. Harding)

Pull request description:

  We do not need to use `Cursor` in these tests, remove the usage.

  PR touches test code only.

ACKs for top commit:
  Kixunil:
    ACK 3ea44a166b
  apoelstra:
    ACK 3ea44a166b

Tree-SHA512: 9fefdc4a8d7fcf3dd09fa60b993f5a61e55865b830c9519efd2de99c4e871cf665facc68fd6c06829d166e76e181fe2026ab5475e7fc6241a5d627212a2cff2f
2024-01-18 15:12:03 +00:00
Steven Roose aa6e5cd342
Use full path in all macro usage of Result 2024-01-18 13:20:19 +00:00
Thabokani b196f6b897
hashes: fix typos 2024-01-18 14:06:32 +08:00
Thabokani 80665671cd
bitcoin: fix typos 2024-01-18 14:06:23 +08:00
Tobin C. Harding 3ea44a166b
Remove usage of Cursor in pubkey sanity checks
We do not need to use `Cursor`, `io::Read` is implemented for slices of
`u8`s.
2024-01-18 09:18:56 +11:00
Tobin C. Harding 35b5350088
Remove usage of Cursor in multi key read
We do not need to know the position of the reader when reading multiple
keys, usage of `Cursor` is unnecessary.
2024-01-18 09:18:56 +11:00
Andrew Poelstra fa716fb638
Merge rust-bitcoin/rust-bitcoin#2339: io: Add read_to_end trait method to Read
3333dbab24 Use new read_to_limit function (Tobin C. Harding)
f29da57ef6 io: Add functions to read to the end of a reader (Tobin C. Harding)

Pull request description:

  Total re-write, now does:

  - Add a method to the `io::Take` trait `read_to_end`
  - Add a method to the `io::Read` trait `read_to_limit` (with default impl that calls through to `Take::read_to_end`)
  - Use the new methods and remove `psbt::read_to_end`

ACKs for top commit:
  apoelstra:
    ACK 3333dbab24

Tree-SHA512: ce4439a85296db36013e284ebce6f91665b1daa21e6d5a570746a3dea789aec3e6a32d295ab88a8c72b56ee8d50b18e142cbd684980076f2e88c3ae7acf5c322
2024-01-17 16:11:22 +00:00
Tobin C. Harding f08aa16e91
Use Self:: in error return type
As is becoming customary in this codebase use `Self::Foo` to return the
error variant in `From` impl.

Refactor only, no logic changes.
2024-01-17 13:28:31 +11:00
Tobin C. Harding 3333dbab24
Use new read_to_limit function
In the `psbt` code we have a custom `read_to_end` function, now we have
`io::Read::read_to_limit` we can remove this function.
2024-01-17 11:23:06 +11:00
Tobin C. Harding f29da57ef6
io: Add functions to read to the end of a reader
The `std::io::Read` trait includes `read_to_end` but that method
provides a denial of service attack vector since an unbounded reader
will exhaust all system memory.

Add a method to our `Read` trait called `read_to_limit` that does the
same as `std::io::Read::read_to_end` but with memory exhaustion
protection.

Add a `read_to_end` method on our `Take` trait and call through to it
from the new method on our `Read` trait called `read_to_limit`.
2024-01-17 11:23:06 +11:00
Andrew Poelstra 2073a40c50
Merge rust-bitcoin/rust-bitcoin#2240: Require `BufRead` instead of `Read`
263a8b3603 Require BufRead instead of Read (Tobin C. Harding)
32d68fd1fa io: Add BufRead trait (Tobin C. Harding)

Pull request description:

  Require `BufRead` instead of `Read` for consensus decode trait.

ACKs for top commit:
  Kixunil:
    ACK 263a8b3603
  apoelstra:
    ACK 263a8b3603

Tree-SHA512: 58ad04c7267f9091738463331473bd22b61e6b06a13aec38b3602a369cd8e571d7d1388fd81dd7a0a05f2e8d5a9c35270cd8a918a4fafe636506591ed06a4cb2
2024-01-16 15:16:54 +00:00
Andrew Poelstra a3d698ac7c
Merge rust-bitcoin/rust-bitcoin#2230: Add effective value calculation
d69d62822d Add effective_value method (yancy)

Pull request description:

  Draft PR for adding effective value calculation to TxOut.  Adding this method was discussed here: https://github.com/rust-bitcoin/rust-bitcoin/pull/2217

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

Tree-SHA512: e74788fea2f97a10ccf2015406178bdac99a54207fe51f0c830937d2106d564beeebe6f70b49aded572aa17ccb42f47e25905a8f791bd9b442eff223ea59baae
2024-01-16 14:24:39 +00:00
Tobin C. Harding 263a8b3603
Require BufRead instead of Read
Our decoding code reads bytes in very small chunks. Which is not
efficient when dealing with the OS where the cost of a context switch is
significant. People could already buffer the data but it's easy to
forget it by accident.

This change requires the new `io::BufRead` trait instead of `io::Read`
in all bounds.

Code such as `Transaction::consensus_decode(&mut File::open(foo))` will
break after this is applied, uncovering the inefficiency.

This was originally Kix's work, done before we had the `io` crate.
Changes to `bitcoin` were originally his, any new mistakes are my own.
Changes to `io` are mine.

Co-developed-by: Martin Habovstiak <martin.habovstiak@gmail.com>
2024-01-16 14:36:00 +11:00
Andrew Poelstra 6702f1a144
Merge rust-bitcoin/rust-bitcoin#2342: Remove mention of core2
2dfe455161 Remove mention of core2 (Tobin C. Harding)

Pull request description:

  We no longer depend on `core2`, remove stale code comment mention of the crate.

  Fix: #2034

ACKs for top commit:
  Kixunil:
    ACK 2dfe455161
  apoelstra:
    ACK 2dfe455161

Tree-SHA512: cb723a384cd69e5b1aa70bdb25f53c818092c465783bd8a9b1ec60af488ed013d39f29057b4b09d6347b8bc52911eb6daf609bd088dec172647dbfedc2ea1791
2024-01-16 01:41:19 +00:00