Commit Graph

3849 Commits

Author SHA1 Message Date
harshit933 5182a8d7a8 Remove unused variants from `Address::Error` 2024-02-23 03:36:35 +05:30
harshit933 05b24946eb Add the `FromScriptError` for handling errors in `address`
This commit adds the `FromScriptError` struct to handle the errors
while generating address from any script. It includes :
- Unrecognized script error.
- Witness Program error.
- Witness Version error.
2024-02-23 02:21:11 +05:30
yu 41e8fb0863 Support signing taproot in psbt 2024-02-22 10:42:44 +08:00
Tobin C. Harding 1ee887a2fc
Make from_hex inherent for byte-like types
Byte like types naturally display in hex, therefore they should have
an inherent method `from_hex` and not implement `FromHex`.
2024-02-22 09:16:31 +11:00
Andrew Poelstra 975ada3570
Merge rust-bitcoin/rust-bitcoin#2488: Fix CI new build warnings
9187bf3a65 Fix new nightly warnings/errors (Tobin C. Harding)

Pull request description:

  The latest nightly toolchain introduced a whole bunch of new warnings and errors, mostly to do with import statements - fix them all.

ACKs for top commit:
  apoelstra:
    ACK 9187bf3a65

Tree-SHA512: 205a100cd3b4cd9489c660b1699711cb1ff8c2eefa0ad6c7fefc3da34856be6dfd194e912b591abffeb0b6bca1756a13677a178961890464fac1758ad43250dc
2024-02-21 14:40:07 +00:00
Tobin C. Harding 9187bf3a65
Fix new nightly warnings/errors
The latest nightly toolchain introduced a whole bunch of new warnings
and errors, mostly to do with import statements - fix them all.
2024-02-21 14:13:49 +11:00
Andrew Poelstra 14e3bc6620
Merge rust-bitcoin/rust-bitcoin#2485: io: Bump version to 0.1.1
cf602583bd io: Bump version to 0.1.1 (Tobin C. Harding)

Pull request description:

  We attempted to release with the current 0.1.0 version forgetting that we had previously released an empty crate with that version to reserve the name on crates.io.

  Bump the version to 0.1.1 and release the actual code.

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

Tree-SHA512: 2efd4c72c135ba3e593a9854d459bacfd8ce1d8c1c18afad9288206cf5d2db6f6c77499912d9c1da40a93ebc8ae463e5cd15b5234bfc09b13f57923767a1f5dd
2024-02-18 14:20:25 +00:00
Tobin C. Harding cf602583bd
io: Bump version to 0.1.1
We attempted to release with the current 0.1.0 version forgetting that
we had previously released an empty crate with that version to reserve
the name on crates.io.

Bump the version to 0.1.1 and release the actual code.
2024-02-18 09:39:28 +11:00
Andrew Poelstra 422404f644
Merge rust-bitcoin/rust-bitcoin#2441: Release tracking PR: `io v0.1.0`
a464ec66a7 io: Add changelog (Tobin C. Harding)

Pull request description:

  In preparation for an initial release; add a changelog file. The version number is already set to `v0.1.0`.

ACKs for top commit:
  apoelstra:
    ACK a464ec66a7 woohoo
  Kixunil:
    ACK a464ec66a7

Tree-SHA512: 87cacbb4b615d57d9e0038a5e1b3f8f840641408b014d7592af25d47104f7e77d515bba77bb97623e419d99557589ead1c7457207340bc4e8a89cbe972d8aecb
2024-02-16 01:16:25 +00:00
Andrew Poelstra bf29a76d89
Merge rust-bitcoin/rust-bitcoin#2436: Add unchecked variants to Amount and SignedAmount
df1d2f6eb5 Add unchecked variants to Amount and SignedAmount (yancy)

Pull request description:

  The checked variants have worse performance than the unchecked variants due to the additional branching operations.  To improve performance where overflow is either not possible or not a concern, unchecked variants of `Amount` and `SignedAmount` are introduced for addition, subtraction and multiplication.

  Note, it seems the default behavior for the test framework is to panic on overflow, so I haven't figured out a good way to add tests for this.  Marking as a draft for now.

  closes: https://github.com/rust-bitcoin/rust-bitcoin/issues/2434

ACKs for top commit:
  Kixunil:
    ACK df1d2f6eb5
  apoelstra:
    ACK df1d2f6eb5 gonna go ahead and merge this, we can revisit if necessary when we look at `units` overflow behavior in general

Tree-SHA512: 3fbb0ec81a758b350569226c44e25f6ca49e551566bee83c05c1c2b343874ef657d63a36b5f51c41582d8a8e36466275c574ebff6d363ed7c112ac8b4d5376fa
2024-02-15 15:04:28 +00:00
yancy df1d2f6eb5 Add unchecked variants to Amount and SignedAmount
The checked variants have worse performance than the unchecked variants
due to the additional branching operations.  To improve performance where
overflow is either not possible or not a concern, unchecked variants
of Amount and SignedAmount are introduced.
2024-02-13 23:46:51 +01:00
Andrew Poelstra 668df1d22d
Merge rust-bitcoin/rust-bitcoin#2467: taproot: add TapNodeHash getter method on TapTree and NodeInfo
1384330029 taproot: add TapNodeHash getter method on TapTree and NodeInfo (conduition)

Pull request description:

  Submitting this to fix what I think is an API hole. Please correct me if I'm mistaken here and there is an easier way to do what I'm after.

  ## Problem

  From what I can tell of the existing 0.31.1 API, there doesn't seem to be any way for a consumer to build a taproot tree using `TaprootBuilder` and then simply output the resulting tap tree merkle root `TapNodeHash`.

  Instead, the API forces me to do `TaprootBuilder::finalize(secp_ctx, internal_key)` first to get a `TaprootSpendInfo`, and then call `TaprootSpendInfo::merkle_root()` to get the root `TapNodehash`. This requires ECC point addition/multiplication for the tweak operation (inside `TaprootBuilder::finalize`), so it is a lot less performant than the simple hashing operations needed to build a taproot tree.

  Obviously if I want to spend the taproot tree, I'll need to tweak an internal key. But if all I want is to examine the merkle root hashes of taproot trees (e.g. for quick validation), there should be a faster and more direct option for me.

  ## Suggested Solution

  My suggestion, demonstrated in this PR, would be to add a couple of simple getter methods:

  - `TapTree::node_hash() -> TapNodeHash`
  - `NodeInfo::node_hash() -> TapNodeHash`

  These rhyme with the existing `LeafNode::node_hash()` method. These provide a roundabout way for downstream consumers to extract a taptree merkle root `TapNodeHash` while still using the safe API provided by `TaprootBuilder`. I would simply use `TaprootBuilder` to build a `TapTree` or `NodeInfo`, and then invoke the `node_hash` method on that object. No point addition required.

  ## Footguns

  This does open up more opportunities for consumers to footgun themselves by, for example, committing a P2TR script pubkey to a leaf node by accident, instead of the root node. I'd argue this possibility already exists in the form of `LeafNode::node_hash()`. We're not making that problem much worse here.

  If the caller is using `TaprootBuilder` to construct their tree, the only way they'll be able to get a `NodeInfo` or `TapTree` in the first place would be to finalize the builder into it, which seems like an acceptable and intuitive-enough usage path to me.

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

Tree-SHA512: 9a3c7313fcf281e6439241d0cdc9ea018329ecb5e8b959cba88b0e36d4f1f0df54e09e5318073e1067618e85aea991d5ac7c50fa336a91782896c9cb3c98a973
2024-02-13 20:18:43 +00:00
conduition 1384330029
taproot: add TapNodeHash getter method on TapTree and NodeInfo
Fixes a gap in the API of the taproot module. Callers can now use
TapTree::root_hash or NodeInfo::node_hash to extract the taproot
tree merkle root hash for fast validation without any ECC overhead.
2024-02-12 23:47:33 +00:00
Andrew Poelstra 8f7cc4d6b3
Merge rust-bitcoin/rust-bitcoin#2462: feat: implement TryFrom trait to `SignedAmount` and `Amount`
251579f4ef feat: implement TryFrom trait to SignedAmount and Amount (Sumit Kumar)

Pull request description:

  Closes: #2245

  Adds `TryFrom<SignedAmount> for Amount` and `TryFrom<Amount> for Amount` in units module

ACKs for top commit:
  tcharding:
    ACK 251579f4ef
  Kixunil:
    ACK 251579f4ef
  apoelstra:
    ACK 251579f4ef

Tree-SHA512: 3e58d7a891019ccd272417eadc977037167439e3385a7b47c060fe93eba9c47fc37cdc0ca5551174ef2d93b256b2804ad7c01f5f2470ef9e9b7b912877aed11c
2024-02-12 23:11:41 +00:00
Tobin C. Harding a464ec66a7
io: Add changelog
In preparation for an initial release; add a changelog file.

The version number is already set to `v0.1.0`.
2024-02-13 09:48:45 +11:00
Andrew Poelstra 4544f5d3c2
Merge rust-bitcoin/rust-bitcoin#2453: io: Remove blanket trait impls
db888fa4cc io: Remove blanket trait impls (Tobin C. Harding)

Pull request description:

  Remove the blanket impls of `Read`, `BufRead`, and `Write`. Replace them with just the impls required to get `rust-bitcoin` building.

  Note, the `TcpStream` stuff is used in `examples/handshake.rs`.

  Fix: #2432

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

Tree-SHA512: 24a3196e740f7e16a493c2f54fb9bf875fceab66c8973ffe28c7cfc9e1a440e14a36d919cc1d8055ac9da8cd4ffb0fc26fff058b8dbb9da4768d7cf4c07ec48a
2024-02-12 20:07:44 +00:00
Andrew Poelstra bac493153a
Merge rust-bitcoin/rust-bitcoin#2471: units: Implement ops::Neg for SignedAmount
7d538c830d units: Implement ops::Neg for SignedAmount (Tobin C. Harding)

Pull request description:

  Its useful to be able to do `let x = -btc_amount;`

  Implement `core::ops::Neg for SignedAmount`, returning a `SignedAmount`.

  Fix: #2470

ACKs for top commit:
  Kixunil:
    ACK 7d538c830d
  apoelstra:
    ACK 7d538c830d

Tree-SHA512: 168808c34513ccf7773ba03abe9375f3bed0fa92b320af5538620142552fecda671b75295a8ba6720f1aead3c722869d8dcffeeaab565c370973d2bcb8b59d1b
2024-02-12 19:59:40 +00:00
Sumit Kumar 251579f4ef
feat: implement TryFrom trait to SignedAmount and Amount 2024-02-13 01:22:36 +05:30
Andrew Poelstra 9bdac92e1a
Merge rust-bitcoin/rust-bitcoin#2464: Remove broken kani test
7e1ba7895f Remove broken kani test (Tobin C. Harding)

Pull request description:

  This test is failing. I do not want to dive back into kani right now, just remove it.

  This is what I originally did in #2454 but changed directions and tried to fix it. Running kani test takes ages and I'd need to dig back to refresh my memory to work with kani. I don't have the motivation to do that at the moment. Just remove the test.

  FTR I added the test recently without fulling thinking it through and it has never passed so we are not loosing any coverage. Doing this was the original mistake I should not have made.

ACKs for top commit:
  Kixunil:
    ACK 7e1ba7895f
  apoelstra:
    ACK 7e1ba7895f

Tree-SHA512: cb76807173b637be9d5ce790b015e711ca76add95ce0f0acfdc56947c075f57ea89774c09c4314dbc89086dcf7a8e21053552bfae805fd5dc9c91051cd53c468
2024-02-12 14:23:33 +00:00
Andrew Poelstra 4523034ba3
Merge rust-bitcoin/rust-bitcoin#2463: Add conditional check for debug_assertions
1d13020129 test: Add conditional check for debug_assertions (yancy)

Pull request description:

  Currently running `cargo test --release` blows up because of the tests that panic.  This PR adds a conditional check `debug_assertions` which causes those tests to not be run in release mode.  Besides fixing `cargo test --release` this PR sets the stage for a larger PR to test arithmetic tests that are `unchecked` (will overflow in release mode instead of panic) started here https://github.com/rust-bitcoin/rust-bitcoin/pull/2436.  Also I think we ought to add `cargo test --release` to CI.

ACKs for top commit:
  Kixunil:
    ACK 1d13020129
  apoelstra:
    ACK 1d13020129

Tree-SHA512: 8964af57d20e314f491261b280ade053de03f5cb6a2857208b3cc16a9b39fa37fa4044cec84a46e35eac2a4b2637ebbd1c250817aab397b8a30f620eb61725fc
2024-02-12 13:37:55 +00:00
Tobin C. Harding 7d538c830d
units: Implement ops::Neg for SignedAmount
Its useful to be able to do `let x = -btc_amount;`

Implement `core::ops::Neg for SignedAmount`, returning a `SignedAmount`.

Fix: #2470
2024-02-12 13:06:34 +11:00
Tobin C. Harding 7e1ba7895f
Remove broken kani test
This test is failing. I do not want to dive back into kani right now,
just remove it.
2024-02-11 06:58:50 +11:00
Tobin C. Harding db888fa4cc
io: Remove blanket trait impls
Remove the blanket impls of `Read`, `BufRead`, and `Write`. Replace them
with a set of sane impls.

Note, we add code to the `impl_write` macro to implement both
`crate::Write` and `std::io::Write` when "std" feature is
enabled.

Fix: #2432
2024-02-11 06:46:27 +11:00
yancy 1d13020129 test: Add conditional check for debug_assertions
Adding debug_assertions where the test case panics allows the test suite
to run in release mode successfully.
2024-02-10 12:37:50 +01:00
Andrew Poelstra 53461f71c9
Merge rust-bitcoin/rust-bitcoin#2457: Inline private ScriptBuf::p2wpkh function
10cf51c4c5 Inline private ScriptBuf::p2wpkh function (Tobin C. Harding)

Pull request description:

  This function is a bit unclear and is only called once, just inline it.

  Refactor only, no logic changes.

ACKs for top commit:
  apoelstra:
    ACK 10cf51c4c5
  Kixunil:
    ACK 10cf51c4c5

Tree-SHA512: 3907923f2258089a5fc1cc1e1d0b34e99457d69a5822cefa7bf90405d7ac05d570fb2855f62e2b5b4b871485e349e8dc09eb8f14c0676a8bdd70593e345b9b41
2024-02-08 16:20:17 +00:00
Andrew Poelstra 814b72779f
Merge rust-bitcoin/rust-bitcoin#2352: io: Cleanup
f317d87ee6 io: Enable "alloc" from "std" (Tobin C. Harding)
1d00d47b32 io: Add Changelog (Tobin C. Harding)
83397c465c io: Add documentation to all public types and functions (Tobin C. Harding)
2810b08b0d io: Add code comment to feature gate (Tobin C. Harding)
4cf2bf4b40 io: Make Take::read_to_end public (Tobin C. Harding)

Pull request description:

  Do some cleanups to the new `io` crate.

  - Make `Take::read_to_end` public
  - Add CI script
  - Add documentation
  - Add changelog

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

Tree-SHA512: 6c7bc0d629a8995d985f8d8a245579ecdac6d0c10fa885c9a3550cc313a933c05ba087340fa3a638a9b631998157f86d439d17e56208f2457ee9ada9741f203d
2024-02-07 20:07:45 +00:00
Andrew Poelstra 241e78934c
Merge rust-bitcoin/rust-bitcoin#2335: Improve error handling in errors emmited by `keys`
d3d5ee1047 Improve error handling in errors emmited by `keys` (harshit933)

Pull request description:

  For now I have tried to group those functions which can produce more than one error and changed the functions which were  generating single error from `Key::Error` to the respective error. Let me know if this needs to be changed.

  Also in `psbt/error.rs` I have changed the `InvalidPublicKey(crate::crypto:🔑:Error)` to `InvalidPublicKey(crate::crypto:🔑:FromSliceError)`. What should be done here?

  Changes -
  - in `from_slice` changed the `error` to `FromSliceError`.
  - in `verify` changed to `secp256k1::Error` as it can return only one error.
  - in `from_str` changed to `FromSliceError`.
  - in `CompressedPublicKey` changed `verify` from `Error` to `secp236k1::Error` as it only returns one error.
  - introduces CompressedPublicKeyError
  - Removes impl from `bip32.rs`

  Potential fix #2291

ACKs for top commit:
  Kixunil:
    ACK d3d5ee1047
  tcharding:
    ACK d3d5ee1047

Tree-SHA512: 21681bbf87c37eb0caaefe4b356a8a5e1d9b17de3207a0c9294de66b367ab348a7dda1916eb866fe4382e852af14ccab7b9f25a279291cd5beb56bb60b2523c2
2024-02-07 20:01:10 +00:00
Andrew Poelstra 94c6526dbe
Merge rust-bitcoin/rust-bitcoin#2451: Remove m prefix requirement
ccbd09d5fb Remove unnecessary m/ prefix requirement (josibake)

Pull request description:

  `m` in BIP0032 is a variable, not a constant. Requiring it as a constant here is confusing and can lead to erroneous conclusions if using this library as a means of understanding BIP0032.

  Fixes #2449

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

Tree-SHA512: b641679f958f20a51c1890b23bbaa0153716802d6180dfd1f649e104f291c5a99143e02b75d292b22254201b28e5c53a04ecd7b6a88ff6f964073106419c5ec1
2024-02-07 19:52:16 +00:00
Andrew Poelstra 48dd9842ef
Merge rust-bitcoin/rust-bitcoin#2454: Remove broken kani test
47569302fc Fix broken kani test (Tobin C. Harding)

Pull request description:

  Recently we added a kani test that doesn't work because of `debug_assert` calls in ops traits.

  Instead of opening the can of worms that is correct panic behaviour in ops lets just remove the test.

ACKs for top commit:
  Kixunil:
    ACK 47569302fc
  apoelstra:
    ACK 47569302fc

Tree-SHA512: f4a862d99173c1502e70fe4c2b9085a1f23dd4501f2ae25dc8a92e3edda7804b42b0580ef32fef2a3d5ea0d98e16b6f0fdba456cf4f0926c5b051ec8a6e54c78
2024-02-07 15:42:24 +00:00
josibake ccbd09d5fb
Remove unnecessary m/ prefix requirement
In BIP0032, m is used as a variable for the root extended key. It is not
meant to be used as a constant prefix when serializing paths.

Update the DerivationPath parser to no longer require the m prefix.
Remove the m prefix from the unit tests and the bip32, ecdsa-psbt,
and taproot-psbt examples.

close #2449
2024-02-07 12:17:45 +01:00
Tobin C. Harding 10cf51c4c5
Inline private ScriptBuf::p2wpkh function
This function is a bit unclear and is only called once, just inline it.

Refactor only, no logic changes.
2024-02-07 10:09:02 +11:00
Tobin C. Harding 47569302fc
Fix broken kani test
We can only multiply numbers that do not overflow. Also inhibit div by
zero.
2024-02-07 09:58:57 +11:00
harshit933 d3d5ee1047 Improve error handling in errors emmited by `keys`
Changes -
- in `from_slice` changed the `error` to `FromSliceError`.
- in `verify` changed to `secp256k1::Error` as it can return only one error.
- in `from_str` changed to `FromSliceError`.
- in `CompressedPublicKey` changed `verify` from `Error` to `secp236k1::Error` as it only returns one error.
- introduces CompressedPublicKeyError
- Removes impl from `bip32.rs`
- introduces `ParsePubKeyError` to return errors while generating publickey from string
2024-02-06 22:28:18 +05:30
Andrew Poelstra 530899ae38
Merge rust-bitcoin/rust-bitcoin#2445: Add API functions `p2wpkh_script_code`
3c62f74684 Add public functions p2wpkh_script_code (Tobin C. Harding)
a246dc98a4 Run sighash example in CI (Tobin C. Harding)

Pull request description:

  This was done to fix #1920, it may be of questionable value though.

  - Patch 1 is definitely useful, its a CI fix.
  - Patch 2 adds two new API functions.

  Fix: #1920

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

Tree-SHA512: 58743612c48e392f9ac0a94477588aee959c5fe9191dd04405bbb71aed7b0730b5927ad98f9da34dc93caaaac939617348c3f71318cc7e65c2c154b0f3897b89
2024-02-06 14:06:11 +00:00
Andrew Poelstra 0f669404c4
Merge rust-bitcoin/rust-bitcoin#2443: Print hex in Debug for Sequence
c084afa8b2 Print hex in Debug for Sequence (Tobin C. Harding)

Pull request description:

  Printing the `Sequence` as a decimal is not super useful when debugging, print it in hex instead.

  Using code:

          let seq = Sequence::from_consensus(0xFFFFFFFF);
          println!("sequence: {:?}", seq);

  Before applying this patch we get:

          sequence: Sequence(4294967295)

  And after applying we get:

          sequence: Sequence(0xffffffff)

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

Tree-SHA512: d60cd8896ca56a30fc8bd030cf3dd1bc1fd3a1609e99bfc2f26b9bd665b11c34c9df93b3f3ad731506d916513ca4a192dde476e16d99f2d4c4b2697f70a7bc98
2024-02-06 13:45:35 +00:00
Andrew Poelstra 06dc05c55b
Merge rust-bitcoin/rust-bitcoin#2450: kani: fix Amount overflow test
343510d3a0 kani: fix Amount overflow test (Andrew Poelstra)

Pull request description:

  Our Kani CI job is currently failing. See https://github.com/rust-bitcoin/rust-bitcoin/actions/runs/7770495422/job/21190756253

  This fixes one of the issues; the other is that we're hitting a multiplication assertion in the test we added in https://github.com/rust-bitcoin/rust-bitcoin/pull/2393 which I'm unsure how to deal with.

  For reference, testing this was a bit of a PITA. I needed to

  ```
  # Ok, these steps are easy/obvious
  cargo install kani-verifier
  cargo kani
  ```

  This will give you an error located in core/panic.rs or something with the description `This is a placeholder message; Kani doesn't support message formatted at runtime` which is not super helpful. To get the actual failure, you need to write

  ```
  cargo kani --enable-unstable --concrete-playback=inplace
  ```

  which will add a weird unit test which calls into Kani to exercise the original test with a specific input value. Because it calls into Kani you can't just run it with `cargo test`. You need to run

  ```
  RUST_BACKTRACE=1 CARGO_INCREMENTAL=0 cargo kani playback -Z concrete-playback -- kani_concrete_playback_check_div_rem_8626518785677487871
  ```

  where `CARGO_INCREMENTAL=0` disables incremental compilation (this was causing rustc to flame out with a "filename too long" error because it was trying to create some intermediate file with multiple hashes and crate names in it), and the `kani_concrete_playback_123456789` thing is the name of the test that gets added (which you can easily find by reading `git diff`).

ACKs for top commit:
  tcharding:
    ACK 343510d3a0
  Kixunil:
    ACK 343510d3a0

Tree-SHA512: 398ce3c61ffa3246bd27ae5719b4ac4fda587e87b8645ec8418fdfd039e4ed78d58233faab27bc63df7e2a30bb5467660e77a6e3d3a08fe86e7ff3dd31869ec7
2024-02-06 13:19:06 +00:00
Tobin C. Harding 3c62f74684
Add public functions p2wpkh_script_code
Add two public API functions on the two public keys, both called
`p2wpkh_script_code` to do exactly as the name suggests.

Of note, I was not able to find anywhere to use these in example code,
this is because of we always use the new `p2wpkh_signature_hash`
function. The new functions may be useful for a user calling
`segwit_v0_encode_signing_data_to`. The may help document the library as
well.
2024-02-06 14:35:54 +11:00
Tobin C. Harding c084afa8b2
Print hex in Debug for Sequence
Printing the `Sequence` as a decimal is not super useful when debugging,
print it in hex instead.

Using code:

        let seq = Sequence::from_consensus(0xFFFFFFFF);
        println!("sequence: {:?}", seq);

Before applying this patch we get:

        sequence: Sequence(4294967295)

And after applying we get:

        sequence: Sequence(0xffffffff)
2024-02-06 12:25:37 +11:00
Andrew Poelstra 343510d3a0
kani: fix Amount overflow test 2024-02-05 18:52:13 +00:00
Andrew Poelstra 92a0969994
Merge rust-bitcoin/rust-bitcoin#2442: Remove non_exhaustive from struct errors with pub inner
8c17ad7fd7 Remove non_exhaustive from struct errors with pub inner (Tobin C. Harding)

Pull request description:

  Using `non_exhaustive` as well as a public inner field is incorrect, it prohibits users from creating or matching on the error and does not achieve forward comparability.

  This was never right, we shouldn't have done it.

ACKs for top commit:
  Kixunil:
    ACK 8c17ad7fd7
  apoelstra:
    ACK 8c17ad7fd7

Tree-SHA512: 41266aaea25e0e5dba22200725e71f7cc23f386f3990c9d0b831980db2cfb431791ba14d6c6b144bd7db90f2f5dc9df38856f23fade0d7aee68217c4c879d3e0
2024-02-05 15:32:10 +00:00
Andrew Poelstra f496eec487
Merge rust-bitcoin/rust-bitcoin#2448: Bump peter-evans/create-pull-request from 5 to 6
d61bb3816f Bump peter-evans/create-pull-request from 5 to 6 (dependabot[bot])

Pull request description:

  Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 6.
  <details>
  <summary>Release notes</summary>
  <p><em>Sourced from <a href="https://github.com/peter-evans/create-pull-request/releases">peter-evans/create-pull-request's releases</a>.</em></p>
  <blockquote>
  <h2>Create Pull Request v6.0.0</h2>
  <h2>Behaviour changes</h2>
  <ul>
  <li>The default values for <code>author</code> and <code>committer</code> have changed. See &quot;What's new&quot; below for details. If you are overriding the default values you will not be affected by this change.</li>
  <li>On completion, the action now removes the temporary git remote configuration it adds when using <code>push-to-fork</code>. This should not affect you unless you were using the temporary configuration for some other purpose after the action completes.</li>
  </ul>
  <h2>What's new</h2>
  <ul>
  <li>Updated runtime to Node.js 20
  <ul>
  <li>The action now requires a minimum version of <a href="https://github.com/actions/runner/releases/tag/v2.308.0">v2.308.0</a> for the Actions runner. Update self-hosted runners to v2.308.0 or later to ensure compatibility.</li>
  </ul>
  </li>
  <li>The default value for <code>author</code> has been changed to <code>${{ github.actor }} &lt;${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com&gt;</code>. The change adds the <code>${{ github.actor_id }}+</code> prefix to the email address to align with GitHub's standard format for the author email address.</li>
  <li>The default value for <code>committer</code> has been changed to <code>github-actions[bot] &lt;41898282+github-actions[bot]@users.noreply.github.com&gt;</code>. This is to align with the default GitHub Actions bot user account.</li>
  <li>Adds input <code>git-token</code>, the <a href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token">Personal Access Token (PAT)</a> that the action will use for git operations. This input defaults to the value of <code>token</code>. Use this input if you would like the action to use a different token for git operations than the one used for the GitHub API.</li>
  <li><code>push-to-fork</code> now supports pushing to sibling repositories in the same network.</li>
  <li>Previously, when using <code>push-to-fork</code>, the action did not remove temporary git remote configuration it adds during execution. This has been fixed and the configuration is now removed when the action completes.</li>
  <li>If the pull request body is truncated due to exceeding the maximum length, the action will now suffix the body with the message &quot;...<em>[Pull request body truncated]</em>&quot; to indicate that the body has been truncated.</li>
  <li>The action now uses <code>--unshallow</code> only when necessary, rather than as a default argument of <code>git fetch</code>. This should improve performance, particularly for large git repositories with extensive commit history.</li>
  <li>The action can now be executed on one GitHub server and create pull requests on a <em>different</em> GitHub server. Server products include GitHub hosted (github.com), GitHub Enterprise Server (GHES), and GitHub Enterprise Cloud (GHEC). For example, the action can be executed on GitHub hosted and create pull requests on a GHES or GHEC instance.</li>
  </ul>
  <h2>What's Changed</h2>
  <ul>
  <li>Update distribution by <a href="https://github.com/actions-bot"><code>@actions-bot</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2086">peter-evans/create-pull-request#2086</a></li>
  <li>fix crazy-max/ghaction-import-gp parameters by <a href="https://github.com/fharper"><code>@fharper</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2177">peter-evans/create-pull-request#2177</a></li>
  <li>Update distribution by <a href="https://github.com/actions-bot"><code>@actions-bot</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2364">peter-evans/create-pull-request#2364</a></li>
  <li>Use checkout v4 by <a href="https://github.com/okuramasafumi"><code>@okuramasafumi</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2521">peter-evans/create-pull-request#2521</a></li>
  <li>Note about <code>delete-branch</code> by <a href="https://github.com/dezren39"><code>@dezren39</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2631">peter-evans/create-pull-request#2631</a></li>
  <li>98 dependency updates by <a href="https://github.com/dependabot"><code>@dependabot</code></a></li>
  </ul>
  <h2>New Contributors</h2>
  <ul>
  <li><a href="https://github.com/fharper"><code>@fharper</code></a> made their first contribution in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2177">peter-evans/create-pull-request#2177</a></li>
  <li><a href="https://github.com/okuramasafumi"><code>@okuramasafumi</code></a> made their first contribution in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2521">peter-evans/create-pull-request#2521</a></li>
  <li><a href="https://github.com/dezren39"><code>@dezren39</code></a> made their first contribution in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2631">peter-evans/create-pull-request#2631</a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/peter-evans/create-pull-request/compare/v5.0.2...v6.0.0">https://github.com/peter-evans/create-pull-request/compare/v5.0.2...v6.0.0</a></p>
  <h2>Create Pull Request v5.0.2</h2>
  <p>⚙️ Fixes an issue that occurs when using <code>push-to-fork</code> and both base and head repositories are in the same org/user account.</p>
  <h2>What's Changed</h2>
  <ul>
  <li>fix: specify head repo by <a href="https://github.com/peter-evans"><code>@peter-evans</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/2044">peter-evans/create-pull-request#2044</a></li>
  <li>20 dependency updates by <a href="https://github.com/dependabot"><code>@dependabot</code></a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/peter-evans/create-pull-request/compare/v5.0.1...v5.0.2">https://github.com/peter-evans/create-pull-request/compare/v5.0.1...v5.0.2</a></p>
  <h2>Create Pull Request v5.0.1</h2>
  <h2>What's Changed</h2>
  <ul>
  <li>fix: truncate body if exceeds max length by <a href="https://github.com/peter-evans"><code>@peter-evans</code></a> in <a href="https://redirect.github.com/peter-evans/create-pull-request/pull/1915">peter-evans/create-pull-request#1915</a></li>
  <li>12 dependency updates by <a href="https://github.com/dependabot"><code>@dependabot</code></a></li>
  </ul>
  <p><strong>Full Changelog</strong>: <a href="https://github.com/peter-evans/create-pull-request/compare/v5.0.0...v5.0.1">https://github.com/peter-evans/create-pull-request/compare/v5.0.0...v5.0.1</a></p>
  </blockquote>
  </details>
  <details>
  <summary>Commits</summary>
  <ul>
  <li><a href="b1ddad2c99"><code>b1ddad2</code></a> feat: v6 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2717">#2717</a>)</li>
  <li><a href="bb809027fd"><code>bb80902</code></a> build(deps-dev): bump <code>@types/node</code> from 18.19.8 to 18.19.10 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2712">#2712</a>)</li>
  <li><a href="e0037d470c"><code>e0037d4</code></a> build(deps): bump peter-evans/create-or-update-comment from 3 to 4 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2702">#2702</a>)</li>
  <li><a href="94b1f99e3a"><code>94b1f99</code></a> build(deps): bump peter-evans/find-comment from 2 to 3 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2703">#2703</a>)</li>
  <li><a href="69c27eaf4a"><code>69c27ea</code></a> build(deps-dev): bump ts-jest from 29.1.1 to 29.1.2 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2685">#2685</a>)</li>
  <li><a href="7ea722a0f6"><code>7ea722a</code></a> build(deps-dev): bump prettier from 3.2.2 to 3.2.4 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2684">#2684</a>)</li>
  <li><a href="5ee839affd"><code>5ee839a</code></a> build(deps-dev): bump <code>@types/node</code> from 18.19.7 to 18.19.8 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2683">#2683</a>)</li>
  <li><a href="60fc256c67"><code>60fc256</code></a> build(deps-dev): bump eslint-plugin-prettier from 5.1.2 to 5.1.3 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2660">#2660</a>)</li>
  <li><a href="0c67723361"><code>0c67723</code></a> build(deps-dev): bump <code>@types/node</code> from 18.19.5 to 18.19.7 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2661">#2661</a>)</li>
  <li><a href="4e288e851b"><code>4e288e8</code></a> build(deps-dev): bump prettier from 3.1.1 to 3.2.2 (<a href="https://redirect.github.com/peter-evans/create-pull-request/issues/2659">#2659</a>)</li>
  <li>Additional commits viewable in <a href="https://github.com/peter-evans/create-pull-request/compare/v5...v6">compare view</a></li>
  </ul>
  </details>
  <br />

  [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=peter-evans/create-pull-request&package-manager=github_actions&previous-version=5&new-version=6)](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 d61bb3816f will merge with one ACK; appears this does not break CI

Tree-SHA512: fb05155a107500e169fd413551c970c0899bb1caea8e8ead4f9bac64f583f73d3c9145f92dfea6d97461676840e3a100e7e48ecd193e95a606c3be4c944a6035
2024-02-05 14:56:43 +00:00
dependabot[bot] d61bb3816f
Bump peter-evans/create-pull-request from 5 to 6
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 6.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v5...v6)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 10:29:03 +00:00
Tobin C. Harding a246dc98a4
Run sighash example in CI
Somehow we forgot to run the `sighash` example in CI.
2024-02-05 17:50:52 +11:00
Tobin C. Harding 8c17ad7fd7
Remove non_exhaustive from struct errors with pub inner
Using `non_exhaustive` as well as a public inner field is incorrect, it
prohibits users from creating or matching on the error and does not
achieve forward comparability.

This was never right, we shouldn't have done it.
2024-02-05 16:26:31 +11:00
Tobin C. Harding f317d87ee6
io: Enable "alloc" from "std"
As is customary in our crates, enable the "alloc" feature from the "std"
feature. This allows simplifying the feature gating.
2024-02-05 11:58:10 +11:00
Tobin C. Harding 1d00d47b32
io: Add Changelog
Done in preparation for an initial v0.1.0 release of the new `io` crate.

Add a changelog file with a brief description of whats in the initial release.
2024-02-05 11:58:10 +11:00
Tobin C. Harding 83397c465c
io: Add documentation to all public types and functions
Add docs for all public types and add a lint to enforce this going
forwards.

Use `allow` attribute in macro, will be fixed as a subsequent patch.
2024-02-05 11:58:10 +11:00
Tobin C. Harding 2810b08b0d
io: Add code comment to feature gate
This feature gate requires a little thought to understand, add a code
comment to save the next guy some clock cycles.
2024-02-05 11:58:10 +11:00
Tobin C. Harding 4cf2bf4b40
io: Make Take::read_to_end public
Currently `Take::read_to_end` is private forcing users to use our
"custom" `read_to_limit`, for seasoned Rust hackers
`foo.take(16).read_to_end(buf)` make be more unsurprising.

Make `read_to_end` public.
2024-02-05 11:58:10 +11:00
Andrew Poelstra a3c4194c3f
Merge rust-bitcoin/rust-bitcoin#2428: Remove the remaining TODOs
c69caafefc Remove attribute comments (Tobin C. Harding)
3e83ef9276 Remove consensus error wrapper TODO (Tobin C. Harding)
bfabea94e9 Remove unwrap comment (Tobin C. Harding)
8bdaf4a34d Remove carrying_mul TODO (Tobin C. Harding)

Pull request description:

  Add issues and remove the TODOs from the code.

  Resolves: #2368

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

Tree-SHA512: b10a3de8da7ace890735023f8441605dd11b0227c27a2357556b8aaa8276a7f34ed220e3bcbc93aad4b35357319318ff7de27210e8f60dd90f6c55af23e21470
2024-02-02 23:39:16 +00:00