Commit Graph

3640 Commits

Author SHA1 Message Date
Andrew Poelstra 26195570d9
Merge rust-bitcoin/rust-bitcoin#2312: Add allow for out of bounds indexing
278229def5 Add allow for out of bounds indexing (yancy)

Pull request description:

  Out of bounds indexing is a workaround for const panic until MSRV +1.57

ACKs for top commit:
  apoelstra:
    ACK 278229def5 Happy New Year! Will merge based on CI one-ack carveout.

Tree-SHA512: 5d525b682c28407e910ae45e8999fe6c95226d5079db917ccda296c68d4ed7a204c9ff1c5ea36d0ae647ee605780939028bf04a3948b1034c71e88cf6f03c782
2024-01-02 15:49:03 +00:00
yancy 278229def5 Add allow for out of bounds indexing
Out of bounds indexing is a workaround for const panic until MSRV +1.57
2024-01-01 10:35:52 +01:00
harshit933 429a3ecec4 Add the implementation of `Display` for `transaction::Version` 2023-12-22 21:08:26 +05:30
Andrew Poelstra 9ea3e29d61
Merge rust-bitcoin/rust-bitcoin#2304: Whitelist some recent clippy lints
504f77adca ci: revert #2301 "update download-artifact to v4" (Andrew Poelstra)
5fd731f095 Don't match on complex expression (Martin Habovstiak)
6cdbb04820 clippy: whitelist uninhabited_references lint (Andrew Poelstra)

Pull request description:

  Clippy has introduced a couple new lints that are causing our CI to fail. `allow` them.

ACKs for top commit:
  tcharding:
    ACK 504f77adca
  Kixunil:
    ACK 504f77adca

Tree-SHA512: 4b2312dcd1645792fa7c08ca02e8ec9f6a13fc5c275559e78293bb55be93997e21f952cf1ac66c1291c4699b6c2976289222201d7e9bbf68349030d83804f8f7
2023-12-20 20:40:01 +00:00
Tobin C. Harding 03bfe1d433
Impove rustdoc on assume_checked_ref
Add a newline to separate the body and heading of function rustdoc.
2023-12-20 09:34:53 +11:00
Tobin C. Harding 769809f1f2
Improve the docs on as_unchecked function
The `as_unchecked` method is never dangerous to call because an
`Address<UncheckedNetwork>` provides a subset of functionality that is
always ok to use. It is only dangerous to go the other way unchecked to
checked.
2023-12-20 09:34:24 +11:00
Andrew Poelstra 504f77adca
ci: revert #2301 "update download-artifact to v4" 2023-12-19 19:28:44 +00:00
Martin Habovstiak 5fd731f095
Don't match on complex expression
Passing a complex expression to `match` is hard to read. Assign it to a
variable first.
2023-12-19 19:28:44 +00:00
Andrew Poelstra 6cdbb04820
clippy: whitelist uninhabited_references lint
This lint triggers on `fn input_len(&self) -> usize { match *self {} }`
where Self is an infallible type, claiming that the dereference of self
is UB. Maybe it would be, if this were possible. But it's not, and this
is literally the only point of using infallible types, so this lint is
always wrong.

Enabled in rustc 1.76 as warn by default.
2023-12-19 16:38:56 +00:00
Andrew Poelstra 8315760403
Merge rust-bitcoin/rust-bitcoin#2301: Bump actions/download-artifact from 3 to 4
7e2321de75 Bump actions/download-artifact from 3 to 4 (dependabot[bot])

Pull request description:

  Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
  <details>
  <summary>Release notes</summary>
  <p><em>Sourced from <a href="https://github.com/actions/download-artifact/releases">actions/download-artifact's releases</a>.</em></p>
  <blockquote>
  <h2>v4.0.0</h2>
  <h2>What's Changed</h2>
  <p>The release of upload-artifact@v4 and download-artifact@v4 are major changes to the backend architecture of Artifacts. They have numerous performance and behavioral improvements.</p>
  <p>For more information, see the <a href="https://github.com/actions/toolkit/tree/main/packages/artifact"><code>@actions/artifact</code></a> documentation.</p>
  <h2>New Contributors</h2>
  <ul>
  <li><a href="https://github.com/bflad"><code>@bflad</code></a> made their first contribution in <a href="https://redirect.github.com/actions/download-artifact/pull/194">actions/download-artifact#194</a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/actions/download-artifact/compare/v3...v4.0.0">https://github.com/actions/download-artifact/compare/v3...v4.0.0</a></p>
  <h2>v3.0.2</h2>
  <ul>
  <li>Bump <code>@actions/artifact</code> to v1.1.1 - <a href="https://redirect.github.com/actions/download-artifact/pull/195">actions/download-artifact#195</a></li>
  <li>Fixed a bug in Node16 where if an HTTP download finished too quickly (&lt;1ms, e.g. when it's mocked) we attempt to delete a temp file that has not been created yet <a href="hhttps://redirect.github.com/actions/toolkit/pull/1278">actions/toolkit#1278</a></li>
  </ul>
  <h2>v3.0.1</h2>
  <ul>
  <li><a href="https://redirect.github.com/actions/download-artifact/pull/178">Bump <code>@actions/core</code> to 1.10.0</a></li>
  </ul>
  </blockquote>
  </details>
  <details>
  <summary>Commits</summary>
  <ul>
  <li><a href="7a1cd3216c"><code>7a1cd32</code></a> Merge pull request <a href="https://redirect.github.com/actions/download-artifact/issues/246">#246</a> from actions/v4-beta</li>
  <li><a href="8f32874a49"><code>8f32874</code></a> licensed cache</li>
  <li><a href="b5ff8444b1"><code>b5ff844</code></a> Merge pull request <a href="https://redirect.github.com/actions/download-artifact/issues/245">#245</a> from actions/robherley/v4-documentation</li>
  <li><a href="f07a0f73f5"><code>f07a0f7</code></a> Update README.md</li>
  <li><a href="7226129829"><code>7226129</code></a> update test workflow to use different artifact names for matrix</li>
  <li><a href="ada9446619"><code>ada9446</code></a> update docs and bump <code>@actions/artifact</code></li>
  <li><a href="7eafc8b729"><code>7eafc8b</code></a> Merge pull request <a href="https://redirect.github.com/actions/download-artifact/issues/244">#244</a> from actions/robherley/bump-toolkit</li>
  <li><a href="3132d12662"><code>3132d12</code></a> consume latest toolkit</li>
  <li><a href="5be1d38671"><code>5be1d38</code></a> Merge pull request <a href="https://redirect.github.com/actions/download-artifact/issues/243">#243</a> from actions/robherley/v4-beta-updates</li>
  <li><a href="465b526e63"><code>465b526</code></a> consume latest <code>@actions/toolkit</code></li>
  <li>Additional commits viewable in <a href="https://github.com/actions/download-artifact/compare/v3...v4">compare view</a></li>
  </ul>
  </details>
  <br />

  [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/download-artifact&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 7e2321de75 and will use CI-only one-ack carveout

Tree-SHA512: 8eb6c18ce8c2b99721f134a26e7407c8ebc1d6af4999a013ed395b52795852ddee1c24b1f8aaf60487f13a0c1288d6b496c34d0dbfe20f806fd6fe5643e02250
2023-12-18 18:01:26 +00:00
dependabot[bot] 7e2321de75
Bump actions/download-artifact from 3 to 4
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-18 10:36:58 +00:00
Andrew Poelstra 4fd88e2f30
Merge rust-bitcoin/rust-bitcoin#2298: Automated nightly rustfmt (2023-12-17)
5af7727250 2023-12-17 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  Kixunil:
    ACK 5af7727250
  apoelstra:
    ACK 5af7727250

Tree-SHA512: f3a4c7e80cc7d30eb10572bf44f3a0cd44748dd4f24a0d9f0fcf7de4f5c351c1dd17cbd80253b074f9fdac7e1bcf4bab7b0fbe61067e9a9dafc4fe5c25f1ab52
2023-12-17 15:03:24 +00:00
Fmt Bot 5af7727250 2023-12-17 automated rustfmt nightly 2023-12-17 00:59:05 +00:00
Martin Habovstiak 089ce8f0fb Deprecate `Script::is_provably_unspendable`
This method is not really that useful because it checked an arbitrary
condition. There already exists `OP_RETURN` semantics and the method
didn't cover all possible ways the script may be invalid.

This deprecates the method and documents why.
2023-12-15 23:55:21 +01:00
Andrew Poelstra eadc6a6c9e
Merge rust-bitcoin/rust-bitcoin#2207: policy: Add section on standard set of derives
cb42c74f58 policy: Add section on standard set of derives (Tobin C. Harding)
ec1a5a25c7 CONTRIBUTING: Remove stale links (Tobin C. Harding)

Pull request description:

  We can have a standard set of derives to make it easier for new devs to work out what to use and also to help us move towards a uniform set in preparation for crate stabilization.

  This is not me imposing my view but rather a place for the discussion to happen, could have been a discussions topic also? Using "open" instead of "draft" to aid visibility. Probably requires more than the usual amount of acks.

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

Tree-SHA512: b4c4094ea3652e92a5bea90e16f13971202710166524cc15abef5e8318ba5f59df084f5246331870fc641456b49d4e35d266c937375bdc5035f03699a7d4c1b9
2023-12-15 22:47:57 +00:00
Andrew Poelstra 9f68e6a6b5
Merge rust-bitcoin/rust-bitcoin#2286: fix : adds the arrayvec dependency
8783d526bd fix : adds the arrayvec dependency (harshit933)

Pull request description:

  This commit adds the arrayvec dependency to the sortKey.

  Potential fix #2276

ACKs for top commit:
  Kixunil:
    ACK 8783d526bd
  apoelstra:
    ACK 8783d526bd

Tree-SHA512: 35f28ade02dd526ce5dfa2f42578b36cd5af29a5a9f409da70a775bc12046674737e9bce9fabcc87f1b4669080ad10465c75601342f280c11eab11f791f44c36
2023-12-15 22:37:00 +00:00
Andrew Poelstra a90104af2d
Merge rust-bitcoin/rust-bitcoin#2232: Add `NetworkKind`
4354f37f51 Use NetworkKind in bip32 module (Tobin C. Harding)
35bbfcded7 Use NetworkKind in PrivateKey (Tobin C. Harding)
d22f3828f6 Use NetworkKind in address module (Tobin C. Harding)
6d5ef23e61 Add NetworkKind (Tobin C. Harding)

Pull request description:

  Add a new type `NetworkKind` the describes the kind of network we are on, ether mainnet or one of the test nets (testnet, regtest, signet).

  Use it in `Address`, `PrivateKey`, and `bip32`.

ACKs for top commit:
  Kixunil:
    ACK 4354f37f51
  apoelstra:
    ACK 4354f37f51

Tree-SHA512: d015283b55b2dc68c0a5cc5f17332fce648d3e4fb4e63e0b61943b7edfe4112e8ace760cb743cd3fd5ad0c34636e51a6a12382b34b6e62dfd7dab894d2ceefc0
2023-12-15 21:08:36 +00:00
harshit933 8783d526bd fix : adds the arrayvec dependency
This commit adds the arrayvec dependency to the sortKey.
2023-12-15 23:46:12 +05:30
Andrew Poelstra 37a6b48933
Merge rust-bitcoin/rust-bitcoin#2284: policy: Add section on returning `Self`
472da02c58 policy: Add section on returning Self (Tobin C. Harding)

Pull request description:

  Returning `Self` instead of the actual type makes refactoring easier, especially for error enums.

ACKs for top commit:
  Kixunil:
    ACK 472da02c58
  apoelstra:
    ACK 472da02c58

Tree-SHA512: 22c74ed02b06907a3e2d79e82620e90e5cad2bd64322fc87ce01640c1ca51907c43329211952c62776834bbdce936f312f82ab166e85a8559614cfa25c0db708
2023-12-15 15:07:30 +00:00
Andrew Poelstra 12e11a089c
Merge rust-bitcoin/rust-bitcoin#2287: Implement custom `ArrayVec` that is `Copy`
7c3b198127 Add a simple `Copy`-able `ArrayVec` (Martin Habovstiak)
f17c0402b7 Add tools that help with making code `const` (Martin Habovstiak)

Pull request description:

  While we decided to use `arrayvec::ArrayVec`, unfortunately it currently isn't `Copy` even if `T` is because of unfortunate interactions with the `Drop` trait. So this adds a super-simple custom version that is `Copy` and may be extended if we need to or replaced with `arrayvec` if they start supporting `Copy`.

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

Tree-SHA512: 545cb99c910f9455185a78a77a1110374e45a11e374c698316a222e599737b82ec2ac5c8ef1a8fe7037f20d938b1a4061685b6c673061b706dc9df9478de2b48
2023-12-15 14:47:06 +00:00
Tobin C. Harding cb42c74f58
policy: Add section on standard set of derives
We can have a standard set of derives to make it easier for new devs to
work out what to use and also to help us move towards a uniform set in
preparation for crate stabilization. Mention the new `ordered` crate.
2023-12-15 12:06:37 +11:00
Tobin C. Harding ec1a5a25c7
CONTRIBUTING: Remove stale links
These sections have been removed but still have links in the index.
2023-12-15 12:06:36 +11:00
Tobin C. Harding 4354f37f51
Use NetworkKind in bip32 module
BIP-32 only differentiates between mainnet and some testnet when
encoding and decoding xpubs and xprivs. As such we can use the new
`NetworkKind` type instead of `Network` throughout the `bip32` module.
2023-12-15 11:50:50 +11:00
Tobin C. Harding 35bbfcded7
Use NetworkKind in PrivateKey
We only use the network to serialize and deserialize from WIF.
For this we only really need network kind since WIF only differentiates
between mainnet and non-mainnet.
2023-12-15 11:49:43 +11:00
Tobin C. Harding d22f3828f6
Use NetworkKind in address module 2023-12-15 11:49:41 +11:00
Tobin C. Harding 6d5ef23e61
Add NetworkKind
Add a new type `NetworkKind` the describes the kind of network we are
on, ether mainnet or one of the test nets (testnet, regtest, signet).

Do not use the type yet.
2023-12-15 11:40:38 +11:00
Martin Habovstiak 7c3b198127 Add a simple `Copy`-able `ArrayVec`
The `arrayvec::ArrayVec` type is not `Copy` which is not nice and we
would like to have a `Copy` type in our crates. While the PR to add
support to the `arrayvec` crate is not merged we implement our own
simplified version.

This one acts mostly as a dumb storage - it has just a few methods and
traits. The new ones can be added as needed later.
2023-12-15 01:37:53 +01:00
Martin Habovstiak f17c0402b7 Add tools that help with making code `const`
There are various challenges when making code `const`: making it
conditional, awkward copying of slices... This change adds tools that
help dealing with these challenges.
2023-12-15 01:37:33 +01:00
Tobin C. Harding 472da02c58
policy: Add section on returning Self
Returning `Self` instead of the actual type makes refactoring easier,
especially for error enums.
2023-12-15 10:44:34 +11:00
Andrew Poelstra 3d6151b9e1
Merge rust-bitcoin/rust-bitcoin#2277: Implement `CompressedPublicKey`
a92d49fe33 Implement `CompressedPublicKey` (Martin Habovstiak)

Pull request description:

  P2WPKH requires keys to be compressed which introduces error handling even in cases when it's statically known that a key is compressed. To avoid it, this change introduces `CompressedPublicKey` which is similar to `PublicKey` except it's statically known to be compressed.

  This also changes relevant code to use `CompressedPublicKey` instead of `PublicKey`.

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

Tree-SHA512: ff5ff8f0cf81035f042dd8fdd52a0801f0488aea56f3cdd840663abaf7ac1d25a0339cd8d1b00f1f92878c5bd55881bc1740424683cde0c28539b546f171ed4b
2023-12-14 00:08:46 +00:00
Andrew Poelstra e5272f3467
Merge rust-bitcoin/rust-bitcoin#2283: Remove unnecessary private extern crate
0d9c7add4a Remove unnecessary private extern crate (Tobin C. Harding)

Pull request description:

  In #2278 I mistakenly left in the `use extern crate` after removing the `pub` from it - while not incorrect it is unnecessary.

ACKs for top commit:
  apoelstra:
    ACK 0d9c7add4a

Tree-SHA512: 60a2638feda2ca5aea234de74fc751c8c140a47946f20cac95d804099f0ba7c78d8eef51912446024e2aafa97008bb93334c0fd3e97267a7f91c4ab86ffcd908
2023-12-13 23:05:26 +00:00
Tobin C. Harding 0d9c7add4a
Remove unnecessary private extern crate
In #2278 I mistakenly left in the `use extern crate` after removing the
`pub` from it - while not incorrect it is unnecessary.
2023-12-14 08:49:44 +11:00
Andrew Poelstra 8afa379f39
Merge rust-bitcoin/rust-bitcoin#2264: Improve the `io` crate
b58c235733 io: Make crate MSRV 1.56.1 (Tobin C. Harding)
063dac03bd Import core::cmp (Tobin C. Harding)
c038d00bd1 io: Move use statement (Tobin C. Harding)
21c44df76e inline sink function (Tobin C. Harding)
5610b9a6b6 Remove unnecessary rustdoc (Tobin C. Harding)

Pull request description:

  In preparation for adding the `BufRead` trait do a few improvements, the first ones are all trivial, the last sets the MSRV to Rust 1.56.1

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

Tree-SHA512: e750cd615d9423f4a581b80acb8c928d537538703e2079d7bb700e6155eee4bd9b768c1eb53b0b2aa841497474460ec5926ac59c11eea1722f028efacc87c813
2023-12-13 18:28:23 +00:00
Andrew Poelstra 6b9f927f7f
Merge rust-bitcoin/rust-bitcoin#2278: Fully encapsulate bitcoinconsensus
43b1ed1b86 Fully encapsulate bitcoinconsensus (Tobin C. Harding)

Pull request description:

  The `bitcoinconsensus` crate is not fully under our control because it exposes code from Core, so we cannot guarantee its stability across versions. To make our semver compliance easier we can fully encapsulate the `bitcoinconsensus` crate so it does not appear in our public API.

  ### Please note that with this applied:

  - The `bitcoinconsenus` crate is no longer exported at the crate root
  - No `bitcoinconsensus` types appear in our public API

ACKs for top commit:
  Kixunil:
    ACK 43b1ed1b86
  apoelstra:
    ACK 43b1ed1b86

Tree-SHA512: 9fc4f01a35396562e980a647784b22667cbd289e45b5c122610d23a1f8bcf0fe8b9c27e33745f14ee010050d4c2d2669b679fb39c7a108e4e86d2c14fd60571a
2023-12-13 15:07:41 +00:00
Tobin C. Harding b58c235733
io: Make crate MSRV 1.56.1
Same as for `rust-bitcoin`, make the MSRV of the `io` crate Rust 1.56.1
2023-12-13 14:22:01 +11:00
Tobin C. Harding 063dac03bd
Import core::cmp 2023-12-13 14:22:01 +11:00
Tobin C. Harding c038d00bd1
io: Move use statement
Use the newly settled upon policy governing layout for imports.
2023-12-13 14:22:01 +11:00
Tobin C. Harding 21c44df76e
inline sink function 2023-12-13 14:22:00 +11:00
Tobin C. Harding 5610b9a6b6
Remove unnecessary rustdoc
This doc does not document any type, remove it.
2023-12-13 14:22:00 +11:00
Tobin C. Harding 43b1ed1b86
Fully encapsulate bitcoinconsensus
The `bitcoinconsensus` crate is not fully under our control because it
exposes code from Core, so we cannot guarantee its stability across
versions. To make our semver compliance easier we can fully encapsulate
the `bitcoinconsensus` crate so it does not appear in our public API.
However, it is useful to have the crate itself exported, here we add an
"unstable" feature and only publicly export the `bitcoinconsensus` crate
if the "unstable" feature is enabled.
2023-12-13 13:37:52 +11:00
Andrew Poelstra 2a6b4c1f43
Merge rust-bitcoin/rust-bitcoin#2262: Clean up `io` usage
f06d12455f bitcoin: Remove the custom sink (Tobin C. Harding)
b503aa1544 Run the formatter (Tobin C. Harding)
3ca55fb163 Remove qualifying path from Read and Write (Tobin C. Harding)
ebeb21fa7a Import fmt::Write using underscore (Tobin C. Harding)
e2dbcb1d28 Use W for writer generic type (Tobin C. Harding)
8704d9f0ae docs: Fix grammar (Tobin C. Harding)

Pull request description:

  A few cleanups to how we use the `io` crate, this is reasonably trivial but commit `a6c7e696 Remove qualifying path from Read and Write` is big, I have however gone to some effort to make sure it is easy to flick through the diff.

  Done in preparation for another go at the `BufRead` stuff.

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

Tree-SHA512: 751c489c67901c7563f1cc91f7761a4e3c276ae1981010338134e8c13200720ba69fcc74948c1dc1e6e65390197da0da27b2b69b86034029748321b404142cba
2023-12-12 20:07:06 +00:00
Andrew Poelstra 24bc6aaad2
Merge rust-bitcoin/rust-bitcoin#2281: Allow `SignedAmount` parse values equal to `i64::MIN`
daa47b2061 Allow `SignedAmount` parse values equal to i64::MIN (Jiri Jakes)

Pull request description:

  Fixes #2267.

  Previously, parsing such textual value returned 'too big' error. This change fixes it and adds relevant tests. Without this patch, the newly added tests fail with `TooBig`.

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

Tree-SHA512: b6e4ee8ed3fa15ecb988b3a6f32f16a17ba9c6de0b99c8a198254d85d263cfffa0498487a3f47b7ddc2c976cade128ac6a7952baecc8721d5d45e057c0eb87b4
2023-12-12 18:04:33 +00:00
Martin Habovstiak a92d49fe33 Implement `CompressedPublicKey`
P2WPKH requires keys to be compressed which introduces error handling
even in cases when it's statically known that a key is compressed. To
avoid it, this change introduces `CompressedPublicKey` which is similar
to `PublicKey` except it's statically known to be compressed.

This also changes relevant code to use `CompressedPublicKey` instead of
`PublicKey`.
2023-12-12 15:16:16 +01:00
Jiri Jakes daa47b2061
Allow `SignedAmount` parse values equal to i64::MIN
Previously, parsing such textual value returned 'too big' error. This
change fixes it and adds relevant tests.
2023-12-12 18:33:44 +08:00
Tobin C. Harding f06d12455f
bitcoin: Remove the custom sink
We have a sink in the new `io` crate, use that one and remove the one in
`bitcoin::prelude`.
2023-12-12 11:48:29 +11:00
Tobin C. Harding b503aa1544
Run the formatter
Run `cargo +nightly fmt`, no manual changes. Done separately to make
review of the last patch easier.
2023-12-12 11:48:29 +11:00
Tobin C. Harding 3ca55fb163
Remove qualifying path from Read and Write
There is no advantage in having `io::Read` as opposed to `Read` and
importing the trait. It is surprising that we do so.

Remove `io::` path from `io::Read` and `io::Write`. Some docs keep the
path, leave them as is. Add import `use io::{Read, Write}`.

Refactor only, no logic changes.
2023-12-12 11:48:29 +11:00
Tobin C. Harding ebeb21fa7a
Import fmt::Write using underscore
When we use the `fmt::Write` trait it is just to call its methods, we
can therefore, without any change to the logic, use `as _` when
importing the trait. This prevents naming conflicts.

Done in preparation for importing the `io::Write` trait.
2023-12-12 11:48:29 +11:00
Tobin C. Harding e2dbcb1d28
Use W for writer generic type
Generic types can be single letters, and a writer is conventionally, in
this codebase at least, called `W`.

Use `W` instead of `Write` with no loss of clarity.
2023-12-12 11:48:29 +11:00
Tobin C. Harding 8704d9f0ae
docs: Fix grammar 2023-12-12 11:48:29 +11:00