Commit Graph

4285 Commits

Author SHA1 Message Date
Andrew Poelstra 741589c5ad
Merge rust-bitcoin/rust-bitcoin#2828: fuzz: add more coverage for `deserialize_block`
ee30eaa81b fuzz: add more coverage for `deserialize_block` (Bruno Garcia)

Pull request description:

  This PR adds more coverage for the `deserialize_block` target. First, it serializes the block and compares with the data provided and then call some block functions to ensure they run without any issue.

ACKs for top commit:
  apoelstra:
    ACK ee30eaa81b Thanks!

Tree-SHA512: db6c7befa7b429267e9b28fb7910d2b9e8d462e22c791b544b1aa528c7ba4f8e1cd32e1276c67d3da1f97ce484e7ed19ec20b10d2030f2977fd8f855cf510ffe
2024-06-03 13:57:09 +00:00
Tobin C. Harding 4ce7ee179a
Merge rust-bitcoin/rust-bitcoin#2826: Automated daily update to rustc (to nightly-2024-06-02)
5cff6b4765 Automated update to Github CI to rustc nightly-2024-06-02 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 5cff6b4765

Tree-SHA512: 02513ed90221b2a31a3cc839dde89eb0239d3537ce19bd32bbc4541f58469a9d88de57e921fea3d653b0f52405b94677ea4470d469ae5f7ace463611be7cd9cd
2024-06-03 12:09:45 +10:00
Update Nightly Rustc Bot 5cff6b4765 Automated update to Github CI to rustc nightly-2024-06-02 2024-06-03 01:23:52 +00:00
Bruno Garcia ee30eaa81b fuzz: add more coverage for `deserialize_block` 2024-06-02 15:44:35 -03:00
Andrew Poelstra db9a1a41d3
Merge rust-bitcoin/rust-bitcoin#2825: Automated nightly rustfmt (2024-06-02)
07ef78ea96 2024-06-02 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:
  apoelstra:
    ACK 07ef78ea96

Tree-SHA512: 55aa43a0a1e3bc4d65246f949d91a56ab758488e7c2633f81735eab39c0f739d2b4ac180d69352e8a3296256fb5a5d1a16d434f7997e4d86143abdd68581076e
2024-06-02 16:32:29 +00:00
Fmt Bot 07ef78ea96 2024-06-02 automated rustfmt nightly 2024-06-02 01:07:10 +00:00
Andrew Poelstra ee68e80315
Merge rust-bitcoin/rust-bitcoin#2535: Move `read_scriptint` to `PushBytes` & create `read_int` function
d6ef16af30 update api (Divyansh Gupta)
a336ec0dda refactor(script): move `read_scriptint` to `PushBytes` & create `read_int` function (Divyansh Gupta)

Pull request description:

  * Moved `read_scriptint` method to `Push_Bytes` struct
  * Created `Instruction::read_int` method which acts as a wrappper around this  function.

  Done as part of #1547

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

Tree-SHA512: e33df8adcb1c23351da303f6bad1ea4a8eae30e65943d230ae886183a01f970aecd0c8c8fd3a6c337cfe6dde1b7590778d88c308415e393f137065ef7da4b29c
2024-06-01 22:38:44 +00:00
Andrew Poelstra 6cfdbc978a
Merge rust-bitcoin/rust-bitcoin#2819: docs: Add more info to the update api files section
0ae5be3e42 docs: Add more info to the update api files section (Tobin C. Harding)

Pull request description:

  Done to try to further help new contributors and save maintainer time.

  Add an example of using `just check-api` and an example `git` command for devs to create the api patch now required for all changes to the public API.

ACKs for top commit:
  apoelstra:
    ACK 0ae5be3e42

Tree-SHA512: 042dad94c1887fcfad535b1eb51cb38a450f3928742d0887c8470888ba53cf79687b65cf7040bdcbe4ce4d49a843f66f198139c22d4f3c4d2689b94b946e6929
2024-06-01 14:52:22 +00:00
Andrew Poelstra 0d1cab68ee
Merge rust-bitcoin/rust-bitcoin#2644: Add HKDF to bitcoin_hashes
c9d1ff7037 Update hashes API changes (Nick Johnson)
878ab924d1 Add HMAC Extract-and-Expand Key Derivation Function (Nick Johnson)

Pull request description:

  rustaceanrob and I have been working on a Rust-based BIP324 implementation over at https://github.com/rustaceanrob/bip324. We have been attempting to keep the code pretty clean in hopes of a future "soft landing" in rust-bitcoin. I figured the HKDF implementation is a small, self-contained chunk that might allow us to learn the ropes here first.

  There was a mention in the [discussion thread on BIP324](https://github.com/rust-bitcoin/rust-bitcoin/discussions/1691) that the hashes interface may be changing in the near future. I am not sure the effect that would have on this implementation, but happy to work through any issues.

  Closes #2551

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

Tree-SHA512: 404d51ca055db4366ec57f1503fcf350aebcd181f36a20a17763ea8c47ade851213fc882acd2785313953a3e768d588c230f737ff93f88121b97c34b37c65127
2024-05-31 22:13:08 +00:00
Tobin C. Harding 0ae5be3e42
docs: Add more info to the update api files section
Done to try to further help new contributors and save maintainer time.

Add an example of using `just check-api` and an example `git` command
for devs to create the api patch now required for all changes to the
public API.
2024-06-01 05:08:32 +10:00
Andrew Poelstra 21cd53a1c8
Merge rust-bitcoin/rust-bitcoin#2818: CI: Remove shebang from non-executable scripts
60ab3d26e5 CI: Remove shebang from non-executable scripts (Tobin C. Harding)

Pull request description:

  Some of our CI shell scripts are meant only to be sourced and not run directly however they include an initial shebang line, implying that they should be run.

  Remove the shebang line from `crates.sh` and the various `test_vars.sh` scripts. Add a `shellcheck` directive to inhibit the no-shebang warning.

  Please note, the issue mentions the following in the discussion thread and it is _not_ implemented here.

  > It would be good also to find a way to detect whether the script is being run directly, and to print an error message. I'm sure this is a common thing and we can find a stackexchange post telling us how to do it.

  I don't see an immediate way to do this because CI is run using `run_task.sh` which is not in this repo. And since one can still run a script without the shebang (by doing eg, `bash script.sh`) the lack of shebang is only an indicator of how we are using the script.

  Fix: #2764

ACKs for top commit:
  apoelstra:
    ACK 60ab3d26e5

Tree-SHA512: fe829226fb50e88bb84a2bbe324fbf977b7d5abc3637e9b7f8148e74a45a995b526bbe8c7263d903fd03f4563cdf95887433daa76f81faa7cd88d830bf6e0205
2024-05-31 18:37:06 +00:00
Tobin C. Harding 60ab3d26e5
CI: Remove shebang from non-executable scripts
Some of our CI shell scripts are meant only to be sourced and not
run directly however they include an initial shebang line, implying that
they should be run.

Remove the shebang line from `crates.sh` and the various `test_vars.sh`
scripts. Add a `shellcheck` directive to inhibit the no-shebang warning.

Fix: #2764
2024-05-31 10:10:00 +10:00
Nick Johnson c9d1ff7037 Update hashes API changes 2024-05-30 15:50:51 -07:00
Nick Johnson 878ab924d1 Add HMAC Extract-and-Expand Key Derivation Function
BIP324's peer to peer encryption protocol requires an HMAC-based extract
and expand key derivation function (HKDF). HKDFs were not part of many
bitcoin protocols before BIP324, but the hope is that the encrypted
protocol becomes the dominant standard justifying this implementation.
2024-05-30 15:12:18 -07:00
Tobin C. Harding 3c87d0c5a3
Merge rust-bitcoin/rust-bitcoin#2745: Automated daily update to rustc (to nightly-2024-05-29)
4137c5c7a2 Automated update to Github CI to rustc nightly-2024-05-29 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 4137c5c7a2

Tree-SHA512: 022339e41f69f1d8518cd8902fbe3fab329df8564366d2ea8d4fe47337693ca7a344d1d799aa8db1235bc45e87c6f70f172efbd75b80a7a3ad79293b8e0fe4e5
2024-05-31 08:00:29 +10:00
Andrew Poelstra aabaf6f2a3
Merge rust-bitcoin/rust-bitcoin#2815: Add `const` modifier to `Magic::from_bytes`
d2be969a51 Add `const fn Magic::from_bytes` patch for API files (Velnbur)
b7458256af Add `const` modifier to `Magic::from_bytes` (Velnbur)

Pull request description:

  Resolves: rust-bitcoin/rust-bitcoin#2814

ACKs for top commit:
  apoelstra:
    ACK d2be969a51

Tree-SHA512: 4e8f24b665a2919bcf135333be097114d72f473684b14a8fdd4e8d82bf57e89b4166352f75f744105f76eddc9ffabcb07971a669a7c93dfff6928a3fe519a38f
2024-05-30 16:34:53 +00:00
Andrew Poelstra 22e244c84c
Merge rust-bitcoin/rust-bitcoin#2615: units: Add BlockHeight and BlockInterval types
eb723740f1 api: Run just check-api (Tobin C. Harding)
853026071f bitcoin: Use new BlockHeight and BlockInterval types (Tobin C. Harding)
1173f3fbff units: Add BlockHeight and BlockInterval types (Tobin C. Harding)

Pull request description:

  Add two simple integer wrapper types for abstracting over block height (from genesis block) and block interval.

  This does not include hex because block height is typically written in decimal.

  These types are very thin wrappers, their usecase is to assist in code readability instead of enforcing any logic.

  Based on discussion in #2533

  Close: #2532

ACKs for top commit:
  apoelstra:
    ACK eb723740f1

Tree-SHA512: e6ae637461a813022e5236622143c658ac731730cb568c14c90cb358ed40452609d0e815ea99619ad7a2ea36f8dd053094b55f09b267e9a7cf5bab73cd3f81c8
2024-05-30 15:02:00 +00:00
Velnbur d2be969a51
Add `const fn Magic::from_bytes` patch for API files
To reflect changes from b7458256af
2024-05-30 13:23:37 +03:00
Velnbur b7458256af
Add `const` modifier to `Magic::from_bytes`
Resolves: rust-bitcoin/rust-bitcoin#2814
2024-05-30 12:58:29 +03:00
Tobin C. Harding eb723740f1
api: Run just check-api 2024-05-30 16:50:02 +10:00
Tobin C. Harding 853026071f
bitcoin: Use new BlockHeight and BlockInterval types
We just added to now types that are thin wrappers around `u32`s for
block heights and intervals.

Add `Encodable` and `Decodable` impls and use the new types. While we
are at it re-export the types from the crate root so users don't have to
dig into the `units` crate.
2024-05-30 16:49:30 +10:00
Tobin C. Harding 1173f3fbff
units: Add BlockHeight and BlockInterval types
Add two simple integer wrapper types for abstracting over block
height (from genesis block) and block interval.

This does not include hex because block height is typically written in
decimal.

These types are very thin wrappers, their usecase is to assist in code
readability instead of enforcing any logic.
2024-05-30 16:49:30 +10:00
Update Nightly Rustc Bot 4137c5c7a2 Automated update to Github CI to rustc nightly-2024-05-29 2024-05-30 01:21:58 +00:00
Andrew Poelstra b0870634f0
Merge rust-bitcoin/rust-bitcoin#2813: api: Run just check-api
18d298ab4f api: Run just check-api (Tobin C. Harding)

Pull request description:

  During a bunch of merges the api/ files have gotten out of sync.

  Run just check-api, no other changes.

ACKs for top commit:
  apoelstra:
    ACK 18d298ab4f

Tree-SHA512: 44d8f691e0ef919b851c43e19ffa28c48598163be056ef95498b5b868a57f83a274e6b69b5172417ac8ef61d56b4d16ed99a91b4e9b5bb9261750afeda301cfa
2024-05-29 23:20:40 +00:00
Tobin C. Harding 18d298ab4f
api: Run just check-api
During a bunch of merges the api/ files have gotten out of sync.

Run just check-api, no other changes.
2024-05-30 07:34:29 +10:00
Andrew Poelstra 3c7ac53e89
Merge rust-bitcoin/rust-bitcoin#2715: psbt: Use macro to hash instead of relying on `Hash` trait
9e4b092fce psbt: Use macro instead of function (Tobin C. Harding)

Pull request description:

  We have a private function that makes use of the `Hash` trait to generically hash map entries. This usage makes patching the `hashes` module difficult. We can achieve the same thing by using a macro and passing in the concrete type.

  This is an internal change, no effect on logic or public API.

ACKs for top commit:
  apoelstra:
    ACK 9e4b092fce

Tree-SHA512: 8b788fa91d21bbae556c746c2e55e6e9395e022bedf13193555ef7482109b6ef5032b233c5f37543a31ebda49d9b4761c161ca0db501472047eb661a48e944b7
2024-05-28 16:54:13 +00:00
Andrew Poelstra 65a5dfcd6b
Merge rust-bitcoin/rust-bitcoin#2585: Improve array macros
6ba7758b30 Improve array macros (Tobin C. Harding)

Pull request description:

  Currently we have two macros used when creating array wrapper types, one is in `internals` and the other in `bitcoin::internal_macros`. It is not immediately obvious what is what and why there are two.

  Improve the macros by:

  - Move the inherent functions to `impl_array_newtype`
  - Use `*_byte_array` for the names instead of `*_bytes`
  - Re-name the other macro to match what it now does

ACKs for top commit:
  apoelstra:
    ACK 6ba7758b30

Tree-SHA512: 36ed0fae0d28f24d29287062eb05bbc1e9e8b565f4ff41fd893503a25404ed8e185a34d75e398a8a660923ffda3b832b6157011598d5a75a5c4aafdffc74af2a
2024-05-28 16:25:59 +00:00
Andrew Poelstra 6d06a32d9c
Merge rust-bitcoin/rust-bitcoin#2755: Fix units public re-exports
d2a597c90d unit: Group re-exports (Tobin C. Harding)
d242125ae4 units: Fix error re-exports (Tobin C. Harding)

Pull request description:

  First patch is the meat and potatoes, second one is just a trivial refactor to the same code, done separately so as to make the changes in the first patch more clear.

  From patch 1
  ```
      units: Fix error re-exports

      Currently we re-export two error types at the crate root, this is
      surprising because:

      - Why not none or all the rest?
      - Why these two?

      Observe that the `ParseIntError` is special in that it is used by
      other modules so its good to have at the crate root (other errors are
      expected to be used with a module prefix eg, `amount::ParseError`).

      There is no obvious reason why `ParseAmountError` is re-exported.

      Comment and doc inline the `ParesIntError`, remove the re-export of
      the `ParseAmountError`.
  ```

ACKs for top commit:
  apoelstra:
    ACK d2a597c90d

Tree-SHA512: 38d3f590357e66d07cbd7fedff134c39e0920e076ea99cb34ba276749a14695d428345d7b0f9ec8222f7899cb57e7c97068d3b6e7b2a9be25a0278e0a1abf762
2024-05-28 15:46:53 +00:00
Andrew Poelstra b31ac0fcb7
Merge rust-bitcoin/rust-bitcoin#2768: Deprecate `to_vec` in favour of `to_bytes`
eda61ddfef Deprecate to_vec in favour of to_bytes (Tobin C. Harding)

Pull request description:

  Currently we have to method names for the same thing "copy this object into a vector". The library is easier to use if we are uniform and just use one.

  Elect to use `to_bytes`, for context see discussion in PR #2585.

ACKs for top commit:
  apoelstra:
    ACK eda61ddfef Nice. IMO we should start deprecating stuff for two releases rather than one, so that people have a year to update.

Tree-SHA512: 0aadd1258a07bfa53806f19a3c41af8d3b1132aa42e7a2015a59c58c4309d7a9b50b86d076c181ce5870ba5acd989feec32669352ecf857ae6fd982873482c34
2024-05-28 15:19:35 +00:00
Andrew Poelstra 6e407e44e4
Merge rust-bitcoin/rust-bitcoin#2809: doc: fix "lazy line continuations" in markdown
1282b7f34b examples: drop a couple allocations (Andrew Poelstra)
45e0241267 doc: fix "lazy line continuations" in markdown (Andrew Poelstra)

Pull request description:

  Rust nightly as of 2024-05-27 has a new lint which detects list items which are continued by a non-indented line. Markdown treats these as single list items, which they sometimes are, but sometimes we intended them to be on a separate line.

  Also changes the docs for `UntweakedKeypair::tap_tweak` because the existing ones were overly technical and out-of-date.

  Also fixes a minor "no need to create a vec then dereference it" lint in the examples.

ACKs for top commit:
  storopoli:
    ACK 1282b7f34b
  tcharding:
    ACK 1282b7f34b

Tree-SHA512: 989c83b6bbbfbf8ddd2ade63b5f590f76810f4ec56fab432b580a40e3cc1468a0ea657dcc7ad0d4a31d49eb1390219616fec5a76b5680d5fddc3a06d81db30d7
2024-05-28 13:34:58 +00:00
Divyansh Gupta d6ef16af30 update api 2024-05-28 15:36:17 +05:30
Divyansh Gupta a336ec0dda refactor(script): move `read_scriptint` to `PushBytes` & create `read_int` function
* Moved read_scriptint method to Push_Bytes struct
 * Created Instruction::read_int method
fix #1547
2024-05-28 15:36:17 +05:30
Andrew Poelstra 1741229526
Merge rust-bitcoin/rust-bitcoin#2808: Add an `AddressData` type
b5ef7db3c0 api: Run just check-api (Tobin C. Harding)
1b40550ce8 Add an AddressData type (Tobin C. Harding)

Pull request description:

  In the 0.32.0 release we removed the `address::Payload` struct because it was deemed an implementation detail. As a byproduct of doing so we made it impossible for users to match on an enum and get the address payload (or data).

  - Add a public `AddressData` enum that holds an address' encoded data.
  - Add a conversion function to `Address` that returns the data enum.

  This patch is additive and is expected to be backported and release as a `0.32` point release.

ACKs for top commit:
  apoelstra:
    ACK b5ef7db3c0 I still feel a little partial to calling the struct "DecodedAddress" and the method "decode"...but this is good, and I do not want to bikeshed

Tree-SHA512: d97836bb2d7fc0f6e9fbba2afb30eeefefc88e7105d4765a146dd444c8397dd4d1ef4fd3e3eb925589294d46bfc8a66d33797a05dbc2131923534364424c135c
2024-05-27 16:29:06 +00:00
Andrew Poelstra 1282b7f34b
examples: drop a couple allocations
Detected by clippy.
2024-05-27 12:54:22 +00:00
Andrew Poelstra 45e0241267
doc: fix "lazy line continuations" in markdown
Rust nightly as of 2024-05-27 has a new lint which detects list items
which are continued by a non-indented line. Markdown treats these as
single list items, which they sometimes are, but sometimes we intended
them to be on a separate line.

Also changes the docs for `UntweakedKeypair::tap_tweak` because the
existing ones were overly technical and out-of-date.
2024-05-27 12:50:26 +00:00
Tobin C. Harding b5ef7db3c0
api: Run just check-api 2024-05-27 14:50:55 +10:00
Tobin C. Harding 1b40550ce8
Add an AddressData type
In the 0.32.0 release we removed the `address::Payload` struct because
it was deemed an implementation detail. As a byproduct of doing so we
made it impossible for users to match on an enum and get the address
payload (or data).

- Add a public `AddressData` enum that holds an address' encoded data.
- Add a conversion function to `Address` that returns the data enum.

This patch is additive and is expected to be backported and release as a
`0.32` point release.
2024-05-27 14:46:25 +10:00
Andrew Poelstra 24bb3aec4f
Merge rust-bitcoin/rust-bitcoin#2805: Automated nightly rustfmt (2024-05-26)
4499c4c046 2024-05-26 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:
  apoelstra:
    ACK 4499c4c046

Tree-SHA512: 6a5eb8b2044f435038e58857dbc5a173ad6e3f5b636021241f96fa349220ff168d620952bdd0bce746fcae6c3e984d2b3bf9518c8dd794ae0553a8bdf392639d
2024-05-26 14:38:37 +00:00
Fmt Bot 4499c4c046 2024-05-26 automated rustfmt nightly 2024-05-26 01:07:01 +00:00
Andrew Poelstra 4fde89f77c
Merge rust-bitcoin/rust-bitcoin#2795: Make `Address:p2sh_from_hash` public
3615410d21 api: Run just check-api (Tobin C. Harding)
a3d2d1a184 Make Address:p2sh_from_hash public (Tobin C. Harding)

Pull request description:

  We previously made this function Private and added a comment that doing so was somehow better to remove the footgun of hashing the wrong length script. However in hindsight this was a bad idea and users want the functionality.

  Make the `Address:p2sh_from_hash` public and document it as we do for `Address::p2sh`.

  This is an additive change and is expected to be backported to `v0.32`, as part of the fix to #2784. Please note it introduces the footgun that is described in the function rustdoc. This will be improved as a separate patch and added to the current release.

ACKs for top commit:
  apoelstra:
    ACK 3615410d21

Tree-SHA512: 535bb7894eeef8ecb5afb7bf6e5c483cd42c6a4282d1c116e5bf86cd1364a8327bbec1efb8634a578f07ad2832c1e5daf7fe7e844574b88b1ad355a443627bef
2024-05-25 21:12:12 +00:00
Andrew Poelstra e96961f333
Merge rust-bitcoin/rust-bitcoin#2798: Standardize rustdoc subheadings
11bb1ff6ff Standardize function doc Safety, Returns and Parameters (jamil.lambert)
df83016c98 Standardize function doc Errors (jamil.lambert)
d219ceb68e Standardize function doc Examples (jamil.lambert)
233a9133d8 Standardize function doc Panics (jamil.lambert)

Pull request description:

  The subheadings in the rustdocs have been standardized according to [./CONTRIBUTING.md](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/CONTRIBUTING.md):
  ```rust
  impl FooBar {
      /// Constructs a `FooBar` from a [`Baz`].
      ///
      /// # Errors
      ///
      /// Returns an error if `Baz` is not ...
      ///
      /// # Panics
      ///
      /// If the `Baz`, converted to a `usize`, is out of bounds.
      pub fn from_baz(baz: Baz) -> Result<Self, Error> {
          ...
      }
  }
  ```

ACKs for top commit:
  apoelstra:
    ACK 11bb1ff6ff
  tcharding:
    ACK 11bb1ff6ff

Tree-SHA512: 163af3cd1cfb47cea3e55eddeaeb6843ff7ec89c57354e3247d6bae85e756b183e8045c2555cfcf87e8c23c1388ff9d7592cfb6a951a37a9ec41d27263e5a2e4
2024-05-25 14:55:16 +00:00
Andrew Poelstra a43f9774db
Merge rust-bitcoin/rust-bitcoin#2803: fuzz: delete CBOR test
830a6e1b0c fuzz: delete CBOR test (Andrew Poelstra)
91eb50b2db fuzz: add lint to generate-files.sh (Andrew Poelstra)

Pull request description:

  We were using an outdated CBOR crate for MSRV reasons. But this old crate is causing suprious test failures. So delete it. (Sadly, updating the crate doesn't fix the issue, replacing it with ciborium breaks our MSRV tests because it needs a more recent `half` dependency, and replacing it with `minicbor` doesn't work because minicbor is not based on serde. So we don't really have any options.)

  In general, I am suspicious of this decode-then-reencode test. CBOR has some ambiguity in integer encoding. Empirically it has seemed to work for a long time, but this seems more like an indictment of our test than a positive result.

  Also, round-trip testing serde encoding of a byte vector is probably not a great use of our fuzz resources. I don't believe we have ever had a problem with this.

  Fixes #2801

ACKs for top commit:
  tcharding:
    ACK 830a6e1b0c

Tree-SHA512: f207b68da2f0910542cd8b6a35bb2364462030bdf08ac1e954fd9dcdbef47b2035ac85f964adb9590078dfc2151e8fc7fe2ed41ec0919ff937723c5954612a47
2024-05-25 14:08:37 +00:00
Andrew Poelstra 8d5399f881
Merge rust-bitcoin/rust-bitcoin#2765: Flesh out hex unit parsing API
cf3e1eb198 api: Run just check-api (Tobin C. Harding)
98bf213c52 bitcoin: Remove error module (Tobin C. Harding)
a5b93cb159 Flesh out hex unit parsing API (Tobin C. Harding)

Pull request description:

  Add to `units::parse` the complete suit of hex unit parsing functions:

  - remove prefix
  - assert without prefix
  - parse with or without prefix
  - parse with prefix
  - parse without prefix
  - parse prefix unchecked

  Refactor `bitcoin` to use the exact function we need, removing code duplication.

  This is a breaking change to `units`, it does however keep the current re-exports from the public, now empty, `bitcoin::error` module.

ACKs for top commit:
  apoelstra:
    ACK cf3e1eb198

Tree-SHA512: 1778108d4364e290e8956cfea6f23fcdd82c835844d034a00b4cf5cab5552e3efbe853dfbf8a3e0a4bd53a8e3da9d6f7c7408d332d18cd7090aec16fc1f02fe7
2024-05-25 13:32:52 +00:00
Tobin C. Harding 3615410d21
api: Run just check-api 2024-05-25 07:55:21 +10:00
Tobin C. Harding a3d2d1a184
Make Address:p2sh_from_hash public
We previously made this function Private and added a comment that doing
so was somehow better to remove the footgun of hashing the wrong length
script. However in hindsight this was a bad idea and users want the
functionality.

Make the `Address:p2sh_from_hash` public and document it as we do for
`Address::p2sh`.
2024-05-25 07:54:11 +10:00
Andrew Poelstra d994aba063
Merge rust-bitcoin/rust-bitcoin#2586: Hard code genesis script bytes instead of hex
726ff25c46 Hard code genesis script bytes instead of hex (Tobin C. Harding)
6e5592db77 Use test_hex_unwrap in bench code (Tobin C. Harding)

Pull request description:

  Currently we have a dependency on `hex_lit` and it is used in exactly one place outside of test code, if we instead use a hardcoded array instead we can move the `hex_lit` dependency to `dev-dependencies`.

  Hard code the genesis block script bytes as an array of hex digits, link to the blockstream explorer for those interested and comment the bytes liberally since it took me a while to work out what they were.

  Move the `hex_lit` dependency and update the lock files.

ACKs for top commit:
  apoelstra:
    ACK 726ff25c46

Tree-SHA512: 96110332fc24dd5b251150b32737fa198113244c3b51b35453c8c1fcc8386c5a2f68dddb30d78cf2f9e1762550099fdb4109dc550f4c144625795ce60b86e574
2024-05-24 20:43:37 +00:00
Andrew Poelstra 543b387d72
Merge rust-bitcoin/rust-bitcoin#2796: Enable getting the witness program from an address
7f29313d36 Update API (Tobin C. Harding)
4f29adf163 Enable getting the witness program from an address (Tobin C. Harding)

Pull request description:

  We have getters for the pubkey hash and script hash but we forgot one for the witness program - add it.

  Done as part of fixing #2784, this is an additive change and is expected to be backported to `v0.32`

ACKs for top commit:
  apoelstra:
    ACK 7f29313d36

Tree-SHA512: 365aba572eaacb789f5424c233be067500ceff18dc27e28fc3be123c49d27333e95bbf4527469a9caf8cc2fe54f8e13a0fc83bc3fc7c3356aea876c9dd2fa5f0
2024-05-24 20:11:17 +00:00
Andrew Poelstra 830a6e1b0c
fuzz: delete CBOR test
We were using an outdated CBOR crate for MSRV reasons. But this old
crate is causing suprious test failures. So delete it. (Sadly, updating
the crate doesn't fix the issue, replacing it with ciborium breaks our
MSRV tests because it needs a more recent `half` dependency, and
replacing it with `minicbor` doesn't work because minicbor is not based
on serde. So we don't really have any options.)

In general, I am suspicious of this decode-then-reencode test. CBOR has
some ambiguity in integer encoding. Empirically it has seemed to
work for a long time, but this seems more like an indictment of our test
than a positive result.

Also, round-trip testing serde encoding of a byte vector is probably not
a great use of our fuzz resources. I don't believe we have ever had a
problem with this.

Fixes #2801
2024-05-24 14:32:19 +00:00
Andrew Poelstra 91eb50b2db
fuzz: add lint to generate-files.sh
In #2785 I modified fuzz/Cargo.toml without updating the Cargo.toml
generating script. Oops. Fix that.
2024-05-24 14:30:49 +00:00
Andrew Poelstra 613f1fb126
Merge rust-bitcoin/rust-bitcoin#2792: Header change from arguments to parameters
9bb75703a1 Header change from arguments to parameters (jamil.lambert)

Pull request description:

  In a few cases a function header documents the parameters of the following function under the heading "Arguments", this has been changed to "Parameters".

  Since the description is at the level of the function definition and not where it is being called parameters seems the more accurate term.

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

Tree-SHA512: aa24af3fd6e086c09f5e2605fa58289969fc7188f63d7f53c0e325315644f9704d51d4cf526ebfc51b2cf9216155fc3d48cc6bca759dc14bae15e4770de5116e
2024-05-24 13:14:25 +00:00