Commit Graph

561 Commits

Author SHA1 Message Date
Tobin C. Harding 58033cf14e
pin serde dep on 1.47 2023-03-19 12:15:56 +11:00
Andrew Poelstra f5f4a33fa9
pin serde dep on 1.41 2023-03-18 22:10:18 +00:00
Andrew Poelstra ee9b297e98
ci: update dupe check to whitelist syn 2023-03-18 22:08:45 +00:00
Andrew Poelstra 6aa640ff8d
update rust-secp to 0.27.0
Also remove the spurious dev-dependency copy of rust-secp, which
should've been updated to remove the "recovery" feature in
https://www.github.com/rust-bitcoin/rust-bitcoin/pull/545 and
then been removed entirely in https://www.github.com/rust-bitcoin/rust-bitcoin/pull/1387
2023-03-18 22:01:42 +00:00
junderw 4924148dc6
Swap out `Work::log2` implementation for `U256::to_f64` 2023-03-17 14:10:00 -07:00
Martin Habovstiak 00b46d6d9d Indent functions
This fixes indentatiion that was intentionally "messed up" to make code
review easier.
2023-03-17 08:16:21 +01:00
Martin Habovstiak d56d202aeb Support weight prediction in `const` context
Some smart contracts or simplified wallets statically know the sizes of
transactions or inputs. The possible approaches to handling them so far
were re-computing the values (and hoping the optimizer will const fold
them) or using a simple constant which may be harder to understand and
get right. It's much nicer to just use a `const` but our code didn't
support it until now.

This change adds methods that can compute the prediction in `const`
context for Rust versions >= 1.46.0 which allow use of loops (and
conditions but those could be workaround anyway).

As a side effect of this, the change also adds `const` to `VarInt::len`
in Rust 1.46+. While this one could be made unconditional using array
trick it's probably not worth it because of the planned MSRV bump.

Note: this commit is intentionally unformatted to make diff easier to
understand. Formatting will be done in future commit.
2023-03-17 08:16:17 +01:00
Salvatore Ingala 2961c0c589
Exclude usage of atomic types if not supported for the target
The gate is only added for Rust >= v1.60, since earlier versions don't support #[cfg(target_has_atomic = ...)]
2023-03-16 22:42:15 +01:00
Martin Habovstiak a6188a90c0 Improve QR code formatting documentation
It wasn't obvious that displaying address with alternate formatting
upper cases bech32 addresses.

This change adds information about this and also a note about the
compatibility of various wallets.
2023-03-15 06:45:58 +01:00
Andrew Poelstra edcb6fb81f
Merge rust-bitcoin/rust-bitcoin#1700: update internals CHANGELOG for release
51f2f8483c rename bitcoin-internals to bitcoin-private (Andrew Poelstra)
ca3b4330e8 specify `internals` version in other Cargo.toml files (Andrew Poelstra)
be02045561 update internals CHANGELOG for release (Andrew Poelstra)

Pull request description:

  .

ACKs for top commit:
  Kixunil:
    ACK 51f2f8483c
  tcharding:
    ACK 51f2f8483c

Tree-SHA512: 6eca1dded06da2567f4f7b032b800f8dbd5f6ea768693eb70c7853a06ae7e19be109fbeaf2af45a196180597f7e122b85e8f0abaa702ec60e1b72868c5a74db9
2023-03-14 19:12:05 +00:00
Andrew Poelstra 37b02199e6
Merge rust-bitcoin/rust-bitcoin#1707: Add a method to `pow::Target` for returning difficulty as an f64.
2158f88f1d Add a method to `pow::Target` for returning difficulty as an f64. (junderw)

Pull request description:

  Closes #1703

  This adds a conversion function to U256 to get an f64. We use the method shown in the following blog post.

  https://blog.m-ou.se/floats/

  Target::MAX was converted to a f64 and set as a const that is verified in a unit test.

  The code is rather confusing, so I took a crack at explaining it in my comments as well. Please let me know if you want it cleaned up some more.

ACKs for top commit:
  apoelstra:
    ACK 2158f88f1d
  tcharding:
    ACK 2158f88f1d

Tree-SHA512: 7c0e82bd1756950c1c6dfb9da91fd71b276e2e7dc8a33e69112f87b87e358240f0f7c4894d24ab228e149d862938833a2e65e345ce2712a78dc86dec197da34f
2023-03-14 18:25:38 +00:00
Andrew Poelstra 51f2f8483c
rename bitcoin-internals to bitcoin-private 2023-03-13 16:02:12 +00:00
Steven Roose 9dd4c54a74
Fix CI builds where default features are added accidentally 2023-03-12 20:24:55 +00:00
junderw 2158f88f1d
Add a method to `pow::Target` for returning difficulty as an f64.
This adds a conversion function to U256 to get an f64. We use the method shown in the following blog post. https://blog.m-ou.se/floats/
Target::MAX was converted to a f64 and set as a const that is verified in a unit test.
2023-03-10 07:54:36 -07:00
yancy f0a3aad5b8 Add tests to Weight type 2023-03-09 17:00:22 +01:00
Andrew Poelstra ca3b4330e8
specify `internals` version in other Cargo.toml files 2023-03-08 15:02:31 +00:00
yancy b311e96603 Fix weight subtract bug 2023-03-08 12:22:50 +01:00
Andrew Poelstra 9ffbbb8efb
Merge rust-bitcoin/rust-bitcoin#1694: release bitcoin_hashes 0.12
bfd401c96e bitcoin_hashes: add CHANgELOG (Andrew Poelstra)
d1b7b54e3a bump bitcoin-hashes version to 0.12 (Andrew Poelstra)

Pull request description:

  It was a little tricky to bump the version number because of https://github.com/rust-bitcoin/rust-bitcoin/issues/1553. There are a couple other things I considered trying, which maybe we'll do for future releases, but I believe this works for now.

  Maybe should wait for #1111.

ACKs for top commit:
  tcharding:
    ACK bfd401c96e
  sanket1729:
    utACK bfd401c96e. ChangeLog looks good to me, did not review whether all noteworthy changes were included.

Tree-SHA512: d2104fc93e364415ae955e8123e6087c1eaa4c955aeaf4647ead051a223563326f66c0e278d68f64335e22c9d0af9b296dc3b744cd9d82d206844461fe7bf9c9
2023-03-08 02:13:45 +00:00
Andrew Poelstra d6134248df
Merge rust-bitcoin/rust-bitcoin#1690: Add tests for the FeeRate type
e3f95ee22b Add tests for the FeeRate type (yancy)

Pull request description:

  Adds some tests for the `FeeRate` type.

ACKs for top commit:
  apoelstra:
    ACK e3f95ee22b
  tcharding:
    ACK e3f95ee22b
  Kixunil:
    ACK e3f95ee22b

Tree-SHA512: 74d6597c747d5aa62a6510bf9fa8de971f89ad56f571aadd496f6487e80cc88bb2b5a1c6bcfed825d09d18ca2310b2bfd6fdbe330f2760369d167a653d26bef8
2023-03-08 01:07:48 +00:00
Andrew Poelstra e9e8be3acc
Merge rust-bitcoin/rust-bitcoin#1692: Add constants to `InputWeightPrediction`
3eb648df01 Add constants to `InputWeightPrediction` (Martin Habovstiak)

Pull request description:

  There are several common spends in Bitcoin that have known input weight predictions. It can be useful to have these as constants, so this change adds them. However, this only adds native segwit ones as the others are slowly fading away and might clutter the API.

  If anyone wants other constants, please write them for me, their value is not that great to me so I'm not motivated to figure out the correct numbers. :)

  This would be nice to add to 0.30 since it's small and easy but not critical.

ACKs for top commit:
  apoelstra:
    ACK 3eb648df01
  tcharding:
    ACK 3eb648df01
  sanket1729:
    ACK 3eb648df01

Tree-SHA512: 51d2cd2ecef7e6b79f9d4b52319e34b908fe8b5a337551dc2088994feeafc9c3ca87884c3db8369f8bd002947d6d14b373f08ef1419db282713206ed6f1b309a
2023-03-08 00:37:05 +00:00
Andrew Poelstra cfc4fd943f
Merge rust-bitcoin/rust-bitcoin#1695: fix clippy lint
4a2f11cc49 fix clippy lint (Andrew Poelstra)

Pull request description:

  Looks like a new clippy lint landed.

ACKs for top commit:
  yancyribbens:
    ACK 4a2f11cc49
  tcharding:
    ACK 4a2f11cc49
  sanket1729:
    utACK 4a2f11cc49

Tree-SHA512: 04fd77c2daeeeed99ea854731d73bcb43fbe5fbdba2e241a93a5058ca81f05dfbf6759d055236a8c70c58331d2b93d0fafd81e7cd631b636f881d9a0b1cdc5ca
2023-03-07 21:11:52 +00:00
Martin Habovstiak 3eb648df01 Add constants to `InputWeightPrediction`
There are several common spends in Bitcoin that have known input weight
predictions. It can be useful to have these as constants, so this change
adds them. However, this only adds native segwit ones as the others are
slowly fading away and might clutter the API.
2023-03-07 09:50:13 +01:00
Tobin C. Harding c1360067e9
Enable formatting in CI
Enable formatting in CI by doing:

- Add a section to the `test.sh` scripts to run the formatter (guarded by
  the env variable `DO_FMT`) for all crates (bitcoin, hashes, internals).
- Add `DO_FMT` to the nightly `Tests` CI job.
2023-03-07 08:57:32 +11:00
yancy e3f95ee22b Add tests for the FeeRate type 2023-03-06 10:30:45 +01:00
Tobin C. Harding 61c560baba
Improve the DO_BENCH error message
Benchmarking requires a non-stable toolchain not a nightly toolchain
i.e., includes beta.

Improve the error output to indicate as such.
2023-03-06 10:22:31 +11:00
Tobin C. Harding a11cf07501
Run the formatter
Various formatting issues have crept into the codebase because we do not
run the formatter in CI.

In preparation for enabling formatting checks in CI run `cargo +nightly
fmt` to fix current formatting issues. No changes other than those
create by the formatter.
2023-03-06 10:22:29 +11:00
Andrew Poelstra 4a2f11cc49
fix clippy lint 2023-03-05 17:19:03 +00:00
Andrew Poelstra d1b7b54e3a
bump bitcoin-hashes version to 0.12
Because we have rust-secp in the loop, we need to update rust-secp, push
a new tag, and use that here, to ensure that the direct dependency on
bitcoin_hashes, and the rust-secp version, are compatible.
2023-03-05 13:40:20 +00:00
Andrew Poelstra 10eb0da1ef
Merge rust-bitcoin/rust-bitcoin#1533: Implement support for Hidden nodes in taproot trees and Fix taproot serde bugs
74022baa44 Rename ScriptLeaf to LeafNode (sanket1729)
289dc1e7f5 Remove serde for taprootspendinfo (sanket1729)
a397ab0c19 Remove serde for ScriptLeaf (sanket1729)
9affda3012 Introduce Hidden leaves in ScriptLeaves (sanket1729)
22bc39a143 Fix serde for TaprootMerkleBranch (sanket1729)
38ed9bdf49 MOVE ONLY: Move TapTree to taproot module (sanket1729)

Pull request description:

  This PR changes/removes the serde implementation for the following types

  - TaprootSpendInfo: Removed. This data structure contains derived information for taproot spending that cannot be validated easily. To elaborate, `TaprootSpendInfo` is constructed from a tree, but loses information about the tree structure and maintains handy information like `script_control_block_map`, cached tweaked key, Merkle root etc.
  - TaprootBuillder: Removed. Hard to implement and not very useful.
  - TapTree: Modified to check invariants.
  - NodeInfo: Now implements serde with support for Hidden nodes
  - ScriptLeaf: Removed serde. Users should not directly construct this. This is just an output iterator item of `TapTree::script_leaves()`

  Data structure changes:

  - Introduced `LeafNode`: Supports Hidden leaves. Has serde implemented
  - Cleanly separate `TapTree` and `NodeInfo`:  `TapTree` is a full BIP370 compatible tree with no hidden nodes. `NodeInfo` is a tree that can potentially contain hidden leaves.
  - Added `NodeInfo::leaf_nodes`: Iterator that iterates over known and hidden leaves of `NodeInfo`.
  - Updated `TapTree::script_leaves`: Iterator that is guaranteed to output known leaves.

ACKs for top commit:
  tcharding:
    ACK 74022baa44
  apoelstra:
    ACK 74022baa44

Tree-SHA512: 919ea5bf60dc0cd8431301c1b744b046d1d781b3bed302b83a600cfa644216b6c682752795d463646b2723ac8661879284f557862a67e4572fd965fcf3dc194d
2023-03-04 13:41:37 +00:00
Andrew Poelstra 1679ad878d
Merge rust-bitcoin/rust-bitcoin#1685: Improve the public API for Feerate and Weight
b0b0cdb46c Improve the public API for Feerate and Weight (yancy)

Pull request description:

  Small nit for https://github.com/rust-bitcoin/rust-bitcoin/pull/1627/ to re-export `Weight` and `FeeRate` to shorten the use path.

  ```
  use bitcoin::Weight;
  use bitcoin::FeeRate;
  ````

ACKs for top commit:
  tcharding:
    ACK b0b0cdb46c
  Kixunil:
    ACK b0b0cdb46c
  apoelstra:
    ACK b0b0cdb46c

Tree-SHA512: 81e508c980c4f37e3791d26616459608dd60e5a6255ef28b3a049c1d27281b2853b92474d42f10031254c8c46878adf666eb709826aa4ffde1b4b3542451e080
2023-03-04 01:55:53 +00:00
Andrew Poelstra ea606d93a0
Merge rust-bitcoin/rust-bitcoin#1682: Include address in Error::NetworkValidation
73e876ffd4 Include address in Error::NetworkValidation (Subhradeep Chakraborty)

Pull request description:

  Fixes: #1677

  ## Change
  In `bitcoin/src/address.rs`, a new field `address` is added to the enum variant `Error::NetworkValidation`. Also, the implementation of `Display` trait for `Error` is updated to print the `address` field.

  However, to print the `address` through `Display`, either the reference is needed or `Address` and `Payload` both need to derive the `Copy` trait. Since I am little new to both the rust-bitcoin codebase and rust itself, I am confused about choosing between the two and have moved with the first one. Would appreciate any feedback on this.

ACKs for top commit:
  Kixunil:
    ACK 73e876ffd4
  tcharding:
    ACK 73e876ffd4
  apoelstra:
    ACK 73e876ffd4

Tree-SHA512: dd53b8648bccc8372c829e56817402fb02a9d51d1dffc854f24e68814bbefe7ea777f67aefb0d170762dbf6cdd50bd3ec55af325a1ffc21b1241d1df5531cd24
2023-03-03 16:09:21 +00:00
Subhradeep Chakraborty 73e876ffd4 Include address in Error::NetworkValidation 2023-03-02 20:46:48 +05:30
yancy b0b0cdb46c Improve the public API for Feerate and Weight 2023-03-02 09:57:36 +01:00
sanket1729 74022baa44 Rename ScriptLeaf to LeafNode
ScriptLeaf feels like leaf has to be a script, but it can a hidden
subtree. LeafNode conveys this better
2023-03-01 16:59:13 -08:00
sanket1729 289dc1e7f5 Remove serde for taprootspendinfo
Implementing this for spendinfo is really complicated because it
contains some cached data without retaining the components that are used
to compute them.

Users should serde the 1) NodeInfo and 2) internal key and reconstruct
TaprootSpendInfo from it.
2023-03-01 16:58:24 -08:00
sanket1729 a397ab0c19 Remove serde for ScriptLeaf
This was incorrect and not needed. Users should not be able to create
only tree leaves directly without going through the tree construction in
rust-bitcoin
2023-03-01 16:58:24 -08:00
sanket1729 9affda3012 Introduce Hidden leaves in ScriptLeaves
Cleanly separate `TapTree` and `NodeInfo`. Fix serde not respecting
invariants for several data structures

Repurpose some tests from removed taproot builder for taptree
2023-03-01 16:58:24 -08:00
sanket1729 22bc39a143 Fix serde for TaprootMerkleBranch 2023-03-01 16:57:56 -08:00
sanket1729 38ed9bdf49 MOVE ONLY: Move TapTree to taproot module 2023-03-01 16:57:55 -08:00
Andrew Poelstra 2cf1a4c088
Merge rust-bitcoin/rust-bitcoin#1678: Improve the public API
42b07586ac Improve the public API (Tobin C. Harding)

Pull request description:

  We created the `crypto` crate as a container for cryptography modules with the idea that it may be split out into a separate crate. There is no reason for users of the lib to know about this module. Also, we have two `taproot` modules, one in `crypto` and one at the crate root, this makes for un-ergonomic usage of the lib.

  Improve the public API by doing:

  - Make the `crypto` module private (`pub(crate)`).
  - Re-export `crypto::taproot::Signature` (and `Error`) from `crate::taproot`

  Fix: #1668

ACKs for top commit:
  apoelstra:
    ACK 42b07586ac
  Kixunil:
    ACK 42b07586ac

Tree-SHA512: 5713b98b2a48d2776cdd6ca2c0e798d6e2df604d780e5182bd770fb2df807cf1f65bc24663ee6f7734fc1e0c80494c5a87dc60e44c83acefcffec7f059203a47
2023-03-01 15:42:36 +00:00
Tobin C. Harding 42b07586ac
Improve the public API
We created the `crypto` crate as a container for cryptography modules
with the idea that it may be split out into a separate crate. There is
no reason for users of the lib to know about this module. Also, we have
two `taproot` modules, one in `crypto` and one at the crate root, this
makes for un-ergonomic usage of the lib.

Improve the public API by doing:

- Make the `crypto` module private (`pub(crate)`).
- Re-export `crypto::taproot::Signature` (and `Error`) from
  `crate::taproot`
2023-03-01 09:28:42 +11:00
Andrew Poelstra 5ad2bec626
Merge rust-bitcoin/rust-bitcoin#1679: Add constant for coinbase maturity
7d1645aea0 Add constant for coinbase maturity (benthecarman)

Pull request description:

  Not sure if this is the best place to put this but it is nice to have a constant for this instead of having other libraries make their own (ie https://github.com/lightningdevkit/rust-lightning/pull/1924#pullrequestreview-1222807626)

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

Tree-SHA512: 5ac2a3359cadd303158c66ba45db8f4bf8cc80b6c19604262999ff361fd0bd98e2a4851c57da1962cb5c74f5789a85c8b3861f1742706a60ce1fbc57c3c200cc
2023-02-28 22:01:34 +00:00
benthecarman 7d1645aea0
Add constant for coinbase maturity 2023-02-28 05:37:10 -06:00
Andrew Poelstra 13143d0f6f
Merge rust-bitcoin/rust-bitcoin#1675: Add utils to convert ChainHash to a Network
56569b32ef Add utils to convert ChainHash to a Network (benthecarman)

Pull request description:

ACKs for top commit:
  Kixunil:
    ACK 56569b32ef
  tcharding:
    ACK 56569b32ef

Tree-SHA512: a489fcb1c1208db4271076d88288658988a63209e56e7433bde82d7d5719450433348fcc3cb6aae59ffa6ed8aff510d6b031c6899d5cf64c503a53b2d4c692b8
2023-02-27 23:55:24 +00:00
benthecarman 56569b32ef
Add utils to convert ChainHash to a Network 2023-02-27 12:28:04 -06:00
Andrew Poelstra 4d8ba9be31
Merge rust-bitcoin/rust-bitcoin#1577: Re-name hash inner/byte methods
161273b209 Re-name hash inner/byte methods (Tobin C. Harding)
324b6f264b Use `into` for hash argument (Tobin C. Harding)

Pull request description:

  Currently we have an associated type on hash types `Inner` with accompanying methods `into_inner`, `from_inner`, `as_inner`. Also, we provide a way to create new wrapped hash types. The use of 'inner' becomes ambiguous with the addition of wrapped types because the inner could be the inner hash type or the `Inner` byte array of the inner wrapped hash type.

  In an effort to make the API more clear and uniform do the following:

  - Rename `Inner` -> `Bytes`
  - Rename `*_inner` -> `*_byte_array`
  - Rename the inner hash to/from methods to `*_raw_hash`

  Correct method prefix `into_` -> `to_` because theses methods convert owned `Copy` types.

  Add the trait Bound `Copy` to the `Bytes` type because we rely on this trait bound for the conversion methods to be correctly named according to convention.

  Because of the dependency hole created by `secp256k1` this patch changes the secp dependency to a git tag dependency that includes changes to the hashes calls required so that we can get green lights on CI in this repo.

  Fix: #1554

ACKs for top commit:
  Kixunil:
    ACK 161273b209
  apoelstra:
    ACK 161273b209

Tree-SHA512: b51b851a1855e6a26a7ef8ccb9f554723d4cc39b368812703587a50e81e7ab49714a81696af0be743b947f09e1fca227a5331b6735912c5b0d5cd0178905f006
2023-02-27 17:28:14 +00:00
Andrew Poelstra a40427b177
Merge rust-bitcoin/rust-bitcoin#1676: Fix docs for UnknownMagic to be accurate
a4b5fb4002 Fix docs for UnknownMagic to be accurate (benthecarman)

Pull request description:

  I assume the old docs are a copy-paste error, strings are not involved when this error is encountered.

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

Tree-SHA512: b2b71f81be8a0d979b15471e7262e01284443e05626b26a19236fd25581700d9e37409576a4b73d5bb537c49ae83a4b7d40f0888dff078b07bd7550026cd778a
2023-02-27 15:54:07 +00:00
Andrew Poelstra 826a988be8
Merge rust-bitcoin/rust-bitcoin#1674: Reexport `Magic`
76c4c647cf Reexport `Magic` (Martin Habovstiak)

Pull request description:

  Writing `network::Magic` is more natural and less annoying than `network::constants::Magic`, so this change reexports it.

  Closes #1667

ACKs for top commit:
  apoelstra:
    ACK 76c4c647cf
  tcharding:
    ACK 76c4c647cf

Tree-SHA512: 1d85372ecd9723c0871faa4552ba5f93a3c95d0b213fa8aace398949f97157cdfde164bbcb2c35bae4c61ae0185e3fbdb854714cde0849c1afaf90e4e8ec223f
2023-02-27 13:51:03 +00:00
benthecarman a4b5fb4002
Fix docs for UnknownMagic to be accurate 2023-02-27 00:33:20 -06:00
Tobin C. Harding 161273b209
Re-name hash inner/byte methods
Currently we have an associated type on hash types `Inner` with
accompanying methods `into_inner`, `from_inner`, `as_inner`. Also, we
provide a way to create new wrapped hash types. The use of 'inner'
becomes ambiguous with the addition of wrapped types because the inner
could be the inner hash type or the `Inner` byte array of the inner
wrapped hash type.

In an effort to make the API more clear and uniform do the following:

- Rename `Inner` -> `Bytes`
- Rename `*_inner` -> `*_byte_array`
- Rename the inner hash to/from methods to `*_raw_hash`

Correct method prefix `into_` -> `to_` because theses methods convert
owned `Copy` types.

Add the trait Bound `Copy` to the `Bytes` type because we rely on this
trait bound for the conversion methods to be correctly named according
to convention.

Because of the dependency hole created by `secp256k1` this patch changes
the secp dependency to a git tag dependency that includes changes to the
hashes calls required so that we can get green lights on CI in this
repo.
2023-02-27 14:23:58 +11:00
Tobin C. Harding 324b6f264b
Use `into` for hash argument
Hash types can be converted into a `Message` because `Message`
implements `From` for any type that implements `ThirtyTwoByteHash`,
which hash types do.

Use `into` to convert the hash argument to a message to sign.
2023-02-27 12:00:08 +11:00
Andrew Poelstra 5a867821aa
Merge rust-bitcoin/rust-bitcoin#1623: Improve string parsing
090dad770f Improve string parsing (Tobin C. Harding)

Pull request description:

  Currently we implement string parsing for height/time from the `absolute` module but not the `relative` module.

  Improve the macros used to implement string parsing and use the new versions to implement string parsing for the height and time types in `relative`.

  Done while reviewing data structures in relation to `serde`.

ACKs for top commit:
  apoelstra:
    ACK 090dad770f
  Kixunil:
    ACK 090dad770f

Tree-SHA512: bfa88efbaf5dc35755eb46df373a08e223f112860e8a65f58db9fdd77e2c01dc9377da735b33ef58940004fe5fe11690ac09be19591fded2c9fd04cd7d2bdf73
2023-02-25 21:16:38 +00:00
Martin Habovstiak 76c4c647cf Reexport `Magic`
Writing `network::Magic` is more natural and less annoying than
`network::constants::Magic`, so this change reexports it.

Closes #1667
2023-02-25 19:10:36 +01:00
Harshil Jani f62885890d Accept borrowed values in InputWeightPrediction::new()
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
2023-02-25 17:20:40 +05:30
Andrew Poelstra fbb3b82b93
Merge rust-bitcoin/rust-bitcoin#1663: Create Address::matches_script_pubkey method
d71c31c235 Create Address::matches_script_pubkey method (hashmap)

Pull request description:

  to check if an address creates a particular script without allocating.

  fixes rust-bitcoin/rust-bitcoin#1604

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

Tree-SHA512: cb60a53ae2be7c47dcd27415c883a73c81d57cbbf0bc92eaf76243d79d9c8e2c2efe91bef65a7e67ed26fec376f11325709ff27025d054813b1907ea2bf4961c
2023-02-24 14:51:05 +00:00
Andrew Poelstra 9c1872f96d
Merge rust-bitcoin/rust-bitcoin#1659: Make `hash_newtype` evocative of the output
06f1f027ab Make `hash_newtype` evocative of the output (Martin Habovstiak)
b018f3e90b Remove the `$len` argument from `hash_newtype` (Martin Habovstiak)
752817e20d Stop using `$len` in `hash_newtype` (Martin Habovstiak)

Pull request description:

  The API guidelines say macro input should be evocative of the output.
  `hash_newtype` didn't have this property.

  This change makes it look exactly like the resulting struct, `$len`
  parameter was removed since it's not needed, reversing is controlled
  using an attribute. The macro is also better documented and ready to be
  extended in the future.

  The tagged SHA256 newtype is not yet modified because it has a more
  complicated input parameters.

  Closes #1648

ACKs for top commit:
  apoelstra:
    ACK 06f1f027ab

Tree-SHA512: 9762db1eca9cd749980e5d68ca286f6c926620295a602f62365f199c7b333334b976db25ba25c64e56403cd1ba046b21b99e1c73cc528ad95612ef8901f216e5
2023-02-24 13:47:22 +00:00
hashmap d71c31c235
Create Address::matches_script_pubkey method
to check if an address creates a particular script without allocating.

fixes rust-bitcoin/rust-bitcoin#1604
2023-02-24 11:07:53 +01:00
Tobin C. Harding 596e756d01
Pin syn dependency for MSRV toolchain
The recent 1.0.108 `syn` update violated our MSRV, pin `syn` in the CI
script.
2023-02-24 08:41:40 +11:00
Andrew Poelstra 3a53e7e12e
Merge rust-bitcoin/rust-bitcoin#1653: Show cache construction in rustdoc
438ee45691 Show cache construction in rustdoc (Tobin C. Harding)

Pull request description:

  To make it more clear what the cache is show the cache construction line in rustdoc.

ACKs for top commit:
  apoelstra:
    ACK 438ee45691
  Kixunil:
    ACK 438ee45691

Tree-SHA512: d6da6bad57fddf9e2f4bcfb7c9b87df38bf4b2bb914e92e52d5ae8afa3405a9793536d7164223021ab6d183ddde732cf6889370834e36f37bae470127b0271fa
2023-02-22 15:28:56 +00:00
Andrew Poelstra 17490f3734
Merge rust-bitcoin/rust-bitcoin#1654: Do trivial manifest cleanup
2620f3b69d Put optional = true at the end (Tobin C. Harding)
d86ef3b01b Put non-optional dependency with other non-optional (Tobin C. Harding)

Pull request description:

  Late stage, super anal, manifest cleanup.

  - Patch 1: put non-optional dependencies together
  - Patch 2: put `optional = true` at the end of the line

ACKs for top commit:
  apoelstra:
    ACK 2620f3b69d
  Kixunil:
    ACK 2620f3b69d

Tree-SHA512: bca2bd2eb9a50aea04cab7c6eab7c264e91937ff20473ccf4496ba380897d1d50696719aa3379bd3f29b8a3cbe43d5485ac068f0e2c126462f361fcfe9941548
2023-02-22 15:19:34 +00:00
Martin Habovstiak 06f1f027ab Make `hash_newtype` evocative of the output
The API guidelines say macro input should be evocative of the output.
`hash_newtype` didn't have this property.

This change makes it look exactly like the resulting struct, `$len`
parameter was removed since it's not needed, reversing is controlled
using an attribute. The macro is also better documented and ready to be
extended in the future.

The tagged SHA256 newtype is not yet modified because it has a more
complicated input parameters.

Closes #1648
2023-02-22 14:35:50 +01:00
Martin Habovstiak b018f3e90b Remove the `$len` argument from `hash_newtype`
Now that the `$len` argument is no longer used, remove it completely.
2023-02-22 14:35:14 +01:00
Lorenzo Maturano f69363d71a adding suggested documentation for path arg 2023-02-21 16:58:22 -03:00
Lorenzo Maturano 673ca2d2fe changing docs and examples to use reference to slice in `derive_pub` 2023-02-21 14:34:14 -03:00
Tobin C. Harding 2620f3b69d
Put optional = true at the end
In order to be uniform and make it easier to quickly see that the
dependency is optional put `optional = true` as the last item in the
config set.
2023-02-21 08:35:25 +11:00
Tobin C. Harding d86ef3b01b
Put non-optional dependency with other non-optional
We have a separation between optional dependencies and non-optional
dependencies, `hex_lit` snuck in to the wrong group.
2023-02-21 08:33:51 +11:00
Tobin C. Harding 438ee45691
Show cache construction in rustdoc
To make it more clear what the cache is show the cache construction line
in rustdoc.
2023-02-21 08:12:32 +11:00
Martin Habovstiak d83739a980 Clarify the intention of strange condition
It may not be obvious why the condition in `push_bytes` module checks
for negation of 16 and 32 bit architectures rather than 64 bit. This
adds a comment about it being conservative.
2023-02-20 19:40:19 +01:00
Andrew Poelstra 182fa9bd76
Merge rust-bitcoin/rust-bitcoin#1651: Get rid of BadFormat error
6fb2d12373 Get rid of BadFormat error (hashmap)

Pull request description:

  add additional variants instead.
  as discussed in https://github.com/rust-bitcoin/rust-bitcoin/pull/1365

ACKs for top commit:
  Kixunil:
    ACK 6fb2d12373
  apoelstra:
    ACK 6fb2d12373

Tree-SHA512: 2cf9146670c372a3a482448f84a30943cd2ff2fa4e724075d67a52dba5ac0ad38f99ca2af3dd3494e13584653f2b23e913e6421328d40be52e868a107fffe03b
2023-02-20 15:51:13 +00:00
hashmap 6fb2d12373
Get rid of BadFormat error
add additional variants instead.
2023-02-20 12:53:57 +01:00
Tobin C. Harding be7b3754a9
Rename schnorr module to taproot
"schnorr" is a dirty word; the current `schnorr` module defines a
`Signature` that includes a sighash type, this sighash type is a bitcoin
specific construct related to taproot. Therefore the `Signature` is
better named `taproot::Signature`. Note also that the usage of `schnorr`
in `secp256k1` is probably justified because the
`secp256::schnorr::Signature` is just doing the crypto.

While we are at it, update docs and error messages to use "taproot"
instead of "schnorr". Also change function names and identifiers that
use "schnorr".
2023-02-20 12:58:09 +11:00
Tobin C. Harding 9f39e872bc
Rename SchnorrSighashType to TapSighashType
As we did for `SchnorrSighash`, rename the `SchnorrSighashType` to
`TapSighashType`.
2023-02-20 12:58:09 +11:00
Tobin C. Harding f5c26693c5
Make match arms more terse
Add function local import statements so we can make the match arms more
terse.

Refactor only, no logic changes.
2023-02-20 12:58:09 +11:00
Tobin C. Harding 40c246743b
Split Sighash into LegacySighash and SegwitV0Sighash
Currently we have `TapSighash` that is used for taproot sighashes but
for non-taproot sighashes we use `hash_types::Sighash`. We can improve
the API by creating a `LegacySighash`, and `SegwitV0Sighash`.

Copy the original `Sighash` macro calls to create the two new types in
the `sighash` module.

While we are at it, put the `TapSighash` and `TapSighashTag` into the
`sighash` module also.
2023-02-20 12:58:09 +11:00
Tobin C. Harding e38d843536
Do not use deprecated function in rustdoc example
Currently we are use the deprecated signing method on `Transaction`, we
should use the new method on the sighash cache.
2023-02-20 12:58:08 +11:00
Tobin C. Harding 98130f49f1
Rename TapSighashHash to TapSighash
The TapSighash is the taproot sighash, no need to append `Hash` to the
identifier.
2023-02-20 12:58:08 +11:00
Tobin C. Harding 7e4da3c0ab
Move taproot keys to the keys module
We have a keys module, taproot keys should live in there.
2023-02-20 12:58:05 +11:00
Tobin C. Harding c5fe315a93
Move sighash to crypto module
There is never any use for the `sighash` module unless one is signing,
which requires the `crypto` module. The `sighash` module should
therefore live in the `crypto` module. This is not an API breaking
change because we reexport it at the crate root.
2023-02-20 12:56:34 +11:00
Martin Habovstiak bcd95fa036 Add a newtype for script-pushable slice
The code previously contained undocumented panic when trying to push
slice. This change solves it by adding a newtype that guarantees limited
length.
2023-02-18 16:35:25 +01:00
Martin Habovstiak 8fedbcbf13 Add `ecdsa::SerializedSignature`
`Signature` only supported serialization into `Vec` which required a
heap allocation as well as prevented statically proving maximum length.

Adding a specialized type that holds a byte array and size solves this.
The solution is very similar to `secp256k1::ecdsa::SerializedSignature`.
The difference is that serialized signature in this crate contains
sighash bytes flag while in `secp256k1` it doesn't.
2023-02-18 12:31:07 +01:00
Martin Habovstiak 26fc4152ec Use `PushDataLenLen` to improve confidence
Script parsing is composed of several functions which implicitly rely on
various properties. Adding a type that restricts the valid values makes
local review easier.
2023-02-18 12:24:36 +01:00
Martin Habovstiak bb2c7ec790 Introduce `hex_lit` crate
So far we deserialized hex into `Vec<u8>` at run time. This was mainly
in tests where it had negligible performance cost. However moving the
computation to compile time has a few benefits: it allows proving the
length of the decoded bytes and identifies potential typos before the
code goes through LLVM and other compilation machinery which makes
feedback faster.

This change uses the `hex_lit` crate to move computation to compile
time. It is implemented as `const` declarative macro which doesn't blow
up compilation time.
2023-02-18 12:03:08 +01:00
Andrew Poelstra 562400a7bc
Merge rust-bitcoin/rust-bitcoin#1593: hashes: Implement AsRef for fixed size arrays
a121e19e94 hashes: Implement AsRef for fixed size arrays (Tobin C. Harding)

Pull request description:

  Implement `AsRef<[u8; X]>` for hash types including wrapped hash types. Doing so means at times the compiler can no longer infer the type because we have `AsRef<[u8]` implemented also but we can use `into_inner` and `as_inner` to get the inner array if needed.

  Fix: #1462

  ## Note

  This touches code that will likely be changed by #1577 and when we do #1491 but I believe its a step forward.

ACKs for top commit:
  arturomf94:
    ACK [`a121e19`](a121e19e94)
  apoelstra:
    ACK a121e19e94
  Kixunil:
    ACK a121e19e94

Tree-SHA512: 257c44826c7649db25bb3a6f023f68b2f17b70c546a056afad044bc8a16bf61f654c3846222505aaf5e6f9a0ad1d2113272d61317b407d0ac83702e41060a1ee
2023-02-17 13:24:57 +00:00
Andrew Poelstra e4e7449562
Merge rust-bitcoin/rust-bitcoin#1647: Fix absolute lock time examples and tests
c3cc9e52ab Fix absolute lock time examples and tests (Tobin C. Harding)

Pull request description:

  An absolute lock time of 100 is nonsensical because we are well past block 100. This value was used because it makes sense for _relative_ locktimes but for absolute lock times it makes the examples and tests slightly confusing.

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

Tree-SHA512: f490ef111bce0989c4ce8300c507c21b454448af4a91b9ef7a2fc05407411ca8721c9caa3dd1f0e8c0c133c4892c5c512f2d881af2cc67ae843d87eacae76ef1
2023-02-16 00:11:00 +00:00
Andrew Poelstra b3221b0949
Merge rust-bitcoin/rust-bitcoin#1605: `psbt` cleanup
4a03e2e721 psbt: Remove unused error variant (Tobin C. Harding)

Pull request description:

  Remove an unused error variant for PSBT code (API breaking because the error type is public).

  Woops, somehow I managed to get what was patch 1 of this series merged yesterday, I thought I left it out. Anyways, this is just the remove unused error variant now. No changes to that patch from previous versions of the PR.

ACKs for top commit:
  apoelstra:
    ACK 4a03e2e721
  Kixunil:
    ACK 4a03e2e721

Tree-SHA512: 228c661b97c6656db5a2bcc9ceb494ea485363b7f7262a97c677ee1639b5209c92ec3715ff48fdb108c95c828bfc83b6c475aa66f0ce8c5b0f286bfa7cc19554
2023-02-15 18:08:23 +00:00
Tobin C. Harding c3cc9e52ab
Fix absolute lock time examples and tests
An absolute lock time of 100 is nonsensical because we are well past
block 100. This value was used because it makes sense for _relative_
locktimes but for absolute lock times it makes the examples and tests
slightly confusing.
2023-02-15 13:58:50 +11:00
Andrew Poelstra 7930a9ba5c
Merge rust-bitcoin/rust-bitcoin#1641: Move deny lint checks to script
a1c3082319 Move deny lint checks to script (Harshil Jani)

Pull request description:

  Closes #1551
  Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>

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

Tree-SHA512: 68632fcff175fa7f035ea10346fc36c1d593ba797e18955b01b8f38932e10327dbb36d9cbf95f65c29f68c5106e8b3364708b75ec3fd94c41cee6c994300eca7
2023-02-14 19:05:45 +00:00
Andrew Poelstra fefaedc755
Merge rust-bitcoin/rust-bitcoin#1643: pow: Remove Mul/Div by arbitrary integer types
dd316e4d14 pow: Remove Mul/Div by arbitrary integer types (Tobin C. Harding)

Pull request description:

  When we added `Target` and `Work` types we implemented multiplication and division by anything `Into<u64>`, this is not typically done in the Rust stdlib and also is semantically incorrect for the types.

  Remove `Mul` and `Div` impls from `Target` and `Work`. Also remove `Mul<T>` for `T: Into<u64>` from the private `U256` type.

  Fix #1632

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

Tree-SHA512: ede53555844adab321ff344535b7b8bab3c5c73855823dfc3ad728b077ae199451b7e22a1d203ef73a076073b7f0cbf9637cefa5fe82fc78ab454d02fa0b62b9
2023-02-14 18:50:16 +00:00
Harshil Jani a1c3082319 Move deny lint checks to script
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
2023-02-14 10:48:24 +05:30
Tobin C. Harding dd316e4d14
pow: Remove Mul/Div by arbitrary integer types
When we added `Target` and `Work` types we implemented multiplication
and division by anything `Into<u64>`, this is not typically done in the
Rust stdlib and also is semantically incorrect for the types.

Remove `Mul` and `Div` impls from `Target` and `Work`. Also remove
`Mul<T>` for `T: Into<u64>` from the private `U256` type.
2023-02-14 11:50:46 +11:00
Tobin C. Harding a819cf99d6
Remove FromStr impl from ScriptBuf
`FromStr` impls should roundtrip with `Display` imlps but currently our
`ScriptBuf` displays using instructions but parses hex.
2023-02-14 10:37:56 +11:00
Andrew Poelstra 5fed454949
Merge rust-bitcoin/rust-bitcoin#1644: Flatten the types directory
272cdbcf7c Flatten the types directory (Tobin C. Harding)

Pull request description:

  We recently created a `types` subdirectory under `script` to keep all the `Script` and `ScriptBuf` impls together. Turns out this additional level of subdirectory is a bit annoying and we can achieve the same grouping by just using `script/mod.rs`.

  Move code from `types/mod.rs` to `script/mod.rs`, move the two submodules up a level, remove the `types` directory.

  Fix: #1640

ACKs for top commit:
  Kixunil:
    ACK 272cdbcf7c
  apoelstra:
    ACK 272cdbcf7c

Tree-SHA512: 91fd78084829fa24f3b6420602d7d5094670647fff43e6e193d6de3126f1657132873ea133540d87db7d0d4dfc4cb9666489e39c861377085ce0254da81fd564
2023-02-13 23:20:09 +00:00
Andrew Poelstra f00b6362a0
Merge rust-bitcoin/rust-bitcoin#1636: Weight prediction
ae2aaaa436 Add `script_pubkey_lens` method (Martin Habovstiak)
cf068d16b0 Implement transaction weight prediction (Martin Habovstiak)

Pull request description:

  When creating a transaction one must know the the fee beforehand to set
  appropriate amounts for outputs and to know the fee, weight is required.
  So far we only had a method on an already-constructed transaction. This
  method clearly wasn't helpful when constructing the transaction except
  for hacks like temporarily adding an all-zeroes signature.

  This change adds a function that can compute the transaction weight
  without knowing individual bytes of the scripts, witnesses and other
  elements. It only needs to know their sizes.

  To make the API less error-prone a special, trivial, type is also added
  for computing the lengths of witnesses.

  Based on #1627

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

Tree-SHA512: 55376601c2c2826bb0909cc25ff5b65816f0b1a2d57fb2cd8831f3db5382de0f4a364d518b312f0528bb5f44c30f3f74f8d254145eed2bfd65e2332b7c4d7c8b
2023-02-13 22:40:42 +00:00
Andrew Poelstra 1451370660
Merge rust-bitcoin/rust-bitcoin#1642: Add `minimal_non_dust` to `TxOut`
6be89bf94f Add `minimal_non_dust` to `TxOut` (Martin Habovstiak)

Pull request description:

  In some scenarios it's useful to create outputs with minimal relayable value. E.g. outputs designated for fee bumping using CPFP. A method for this is useful.

  This implements a constructor of `TxOut` that computes the minimal non-dust value from the passed script.

  Closes #1459

  This one is quite easy, so if we could get it in 0.30, that'd be great.

ACKs for top commit:
  apoelstra:
    ACK 6be89bf94f
  tcharding:
    ACK 6be89bf94f

Tree-SHA512: f31ae5f649fbba95ccaabf465cb814df193e7ef89c6e0de7b316a2a484e172beada0da8851da96b195a69a4da1b0991741d4c119f9b0c94fff34150e4f033bd5
2023-02-13 20:53:04 +00:00
Tobin C. Harding 272cdbcf7c
Flatten the types directory
We recently created a `types` subdirectory under `script` to keep all
the `Script` and `ScriptBuf` impls together. Turns out this additional
level of subdirectory is a bit annoying and we can achieve the same
grouping by just using `script/mod.rs`.

Move code from `types/mod.rs` to `script/mod.rs`, move the two
submodules up a level, remove the `types` directory.
2023-02-14 06:48:10 +11:00
Martin Habovstiak ae2aaaa436 Add `script_pubkey_lens` method
In some cases people construct the transaction with a dummy fee output
value before calculating the weight. A method to create the iterator
over `script_pubkey` lengths is useful in such cases.
2023-02-13 11:16:31 +01:00
Andrew Poelstra f71da4e91a
Merge rust-bitcoin/rust-bitcoin#1579: Fix license on bip158 module
097e4e9c7f Fix license on bip158 module (Tobin C. Harding)

Pull request description:

  When we introduced the SPDX license blurb in [0] we incorrectly gave attribution to Andrew when the original file author had the attribution as "the rust-bitcoin developers". The original author [1] was Tamas Blummer and he copied this code from code he wrote and explicitly re-licenses it. In order to make the re-licensing comment a little clearer and fix the mis-attribution use Tamas' name in the attribution.

  [0] commit: `91ff2f628ce7db732d234a812e29fa8508f501a1 Introduce SPDX license identifiers`
  [1] commit: `c93a70487f81a93c7d479ae046c75590d9fb7733 Add client side block filter (BIP158) (#281)`

ACKs for top commit:
  apoelstra:
    ACK 097e4e9c7f
  Kixunil:
    ACK 097e4e9c7f

Tree-SHA512: cb80d32c739ad562b2d657a34355bb28b1dd5c477b03018fbfbb14de40e03b806663aee89b578bcd8c681b067aa8d02611d4cde36e6fb9a8fa84ad4baf2e290e
2023-02-12 21:33:47 +00:00
Andrew Poelstra f3ceed91b3
Merge rust-bitcoin/rust-bitcoin#1581: Use ignore to stop rustdoc code from being built
6d99d3c061 Use ignore to stop rustdoc code from being built (Tobin C. Harding)

Pull request description:

  Currently we have an attempted tag ```compile_fail that seems to be aiming at allowing code that does not build to exist in rustdoc. This is causing an error when running tests.

  No clue how this made it through CI.

  Use ```ignore to prevent rustdoc code from being built.

ACKs for top commit:
  apoelstra:
    ACK 6d99d3c061
  Kixunil:
    ACK 6d99d3c061

Tree-SHA512: 6c4b076000ba29377ac8cf942df66e849ff6421da6f9214664d487550cf45889e163b4de652079010bae327019163b63a1962ff8e6a04d918db63ffb0285ccd1
2023-02-12 21:21:34 +00:00
Andrew Poelstra c4e78661fd
Merge rust-bitcoin/rust-bitcoin#1592: Add `From<Address>` for `ScriptBuf`
5f86b3091c Add From<Address> for ScriptBuf (Tobin C. Harding)

Pull request description:

  Add an implementation of `From<Address> for ScriptBuf` that calls through to `address.script_pubkey` (which calls
  `address.payload.script_pubkey()`).

  Fix: #1457

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

Tree-SHA512: 8a45f292578765b345863946b276607d561b9bc75f6b9bb97f48b32d503143e234aedb658997db802c87289576361ec9ee6cb31fe3bbccfc06cc2fdabc7c41bb
2023-02-12 20:48:00 +00:00
Martin Habovstiak 6be89bf94f Add `minimal_non_dust` to `TxOut`
In some scenarios it's useful to create outputs with minimal relayable
value. E.g. outputs designated for fee bumping using CPFP. A method for
this is useful.

This implements a constructor of `TxOut` that computes the minimal
non-dust value from the passed script.

Closes #1459
2023-02-11 17:14:48 +01:00
Martin Habovstiak cf068d16b0 Implement transaction weight prediction
When creating a transaction one must know the the fee beforehand to set
appropriate amounts for outputs and to know the fee, weight is required.
So far we only had a method on an already-constructed transaction. This
method clearly wasn't helpful when constructing the transaction except
for hacks like temporarily adding an all-zeroes signature.

This change adds a function that can compute the transaction weight
without knowing individual bytes of the scripts, witnesses and other
elements. It only needs to know their sizes.

To make the API less error-prone a special, trivial, type is also added
for computing the lengths of witnesses.
2023-02-11 12:57:37 +01:00
Andrew Poelstra 9615dd12b8
Merge rust-bitcoin/rust-bitcoin#1505: Improve test coverage for docs build
41f2dcf6ae Improve test coverage for docs build (Tobin C. Harding)
b4c14a4b7c hashes: Use automatic link (Tobin C. Harding)
96e8a080d1 ci: Remove redundant || exit (Tobin C. Harding)

Pull request description:

  Currently the docs build commands in `hashes` and `bitcoin` differ, they should be the same.

  Add a command `cargo doc` to improve coverage e.g., recently we botched the feature guarding but since CI only runs `cargo rustdoc` with custom compiler conditional set we didn't catch it.

  Done after seeing: https://github.com/rust-bitcoin/rust-bitcoin/pull/1504 and CI should fail on this PR until 1504 is in.

ACKs for top commit:
  apoelstra:
    ACK 41f2dcf6ae
  Kixunil:
    ACK 41f2dcf6ae

Tree-SHA512: 7cde68292cfc6f32b75d066e188e7c418ee251f9a5abc57fbd642ba33e9cd5bd8ef7c5ba7cffd206acae6ddec2f8c3db38c8c911a4319e979158666b8225953d
2023-02-10 23:20:57 +00:00
Andrew Poelstra 4fdbf076bf
Merge rust-bitcoin/rust-bitcoin#1559: Deprecate `script::read_uint`
a7117bf8f1 Document source of logic fro read_scriptint (Tobin C. Harding)
2eb2420b40 Add comment on rountripping read/write scripint (Tobin C. Harding)
657dd51e8b Use OP_0 to better mimic bitcoin core code (Tobin C. Harding)
31d254a6a8 Fix push operators URL (Tobin C. Harding)
84cd4ca964 Deprecate script::read_uint (Tobin C. Harding)

Pull request description:

  Patch one does the deprecation, the rest of the PR is made up of tiny improvements to the code around reading/writing 'scriptint's (conceptually `CScriptNum`s). I did all this while trying to decipher the discussion on #1547.

  ### Note Please

  There are many more changes in the pipeline for all this read/write "script int" stuff. This PR was done ages ago and I believe it stall adds value.

  I re-did the whole PR manually because of the recent `script` module changes. I hope no one else has to do that - if you do please feel free to holla and I'll "rebase" your PR for you.

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

Tree-SHA512: 5e8ee7fa8d1393a1a50e4241dd947b837cc0ddd15ff1239a49e4839489459fb95d184d6773f73633d55c436310bfab0c73f806d492ed4a4215f924c6c0993936
2023-02-10 20:02:12 +00:00
Andrew Poelstra 1514205e5f
Merge rust-bitcoin/rust-bitcoin#1629: Add methods for pushing locktimes
1e0e712bb0 Add push_* methods for lock times (Tobin C. Harding)

Pull request description:

  Lock times are `u32` and can require encoding using 5 bytes.

  Add methods `push_lock_time` and `push_sequence` for pushing absolute lock times and sequence numbers. We do not push relative locktimes because they are only 16 bits from the original sequence number.

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

Tree-SHA512: 4b511679270e7ef73937259ccf7d1b9b4b7512b2464f302310519a6e02d55c9cc24e3559302aeb671156e68130478258c1c565f474880e8be708b0ee234e67ff
2023-02-10 19:21:51 +00:00
Andrew Poelstra c8e256718b
Merge rust-bitcoin/rust-bitcoin#1612: Clean up the manifest files of top level crates
8596e402f2 Fix docs.rs to use all features (Tobin C. Harding)
89086d094d hashes: Use angle braces to make hyperlinks (Tobin C. Harding)
9b5c2ad7af hashes: Clean up optional dependencies (Tobin C. Harding)
5b4f19c01f hashes: Improve std/alloc features (Tobin C. Harding)
132d2f90b6 bitcoin: Enable alloc feature in features list (Tobin C. Harding)
aa62ca224a hashes: Do not enable core2/alloc feature (Tobin C. Harding)
c15f8dee29 Improve manifest package section (Tobin C. Harding)
12f5e37ed9 Add excludes to manifests (Tobin C. Harding)

Pull request description:

  Do a complete overhaul of the manifest of the top level crates (i.e., not `embedded`, `fuzzing` ect.).

  Many of the problems being fixed here were introduced over the last year by my poor understanding of exactly what was going on with _every_ line of code in the manifests, after this PR I hope that is no longer a problem.

  I'm closing #1571 because it is now done more fully at the end of this PR.

  During review please be liberal with any questions so we can ensure everything is spot on now - as we add more crates there are going to be a proliferation of manifest files, best get it right now.

ACKs for top commit:
  apoelstra:
    ACK 8596e402f2
  Kixunil:
    ACK 8596e402f2

Tree-SHA512: 9e4ae21221cd5b185c04b6d1af73983d324e6d4e09abf94763f6eabcff420d9a3b2ec62a88cd20844fda518756862b0e64a85be54187166f3b1b2b206b82cb08
2023-02-10 17:38:35 +00:00
Andrew Poelstra 6340c8e1bb
Merge rust-bitcoin/rust-bitcoin#1388: Refactor `merkle_tree::block`
861fdd6ab1 Put the `MerkleBlock` struct at the top of the file (Tobin C. Harding)
f0d968197a Put error at the bottom of the file (Tobin C. Harding)
19e094788f Use self for Error variant imports (Tobin C. Harding)
83c2a552db Put helper function below where its called (Tobin C. Harding)
5076579fb9 Fix indentation in pmt_tests macro (Tobin C. Harding)
a7edbfb52e Move hex data to tests/data (Tobin C. Harding)

Pull request description:

  PR 2 in the `merkle_tree::block` series, used to be on top of the now merged #1374.

  Do a bunch of refactorings in preparation for more invasive changes. This is a separate PR because, other than the first patch which moves hex strings to `tests/data/` the other patches are refactoring only patches, no logic changes. However the last patch is big and will be annoying to review - sorry about that. If you really oppose this basically stylistic patch putting important things first, the opposite of C code, please say and I'll try to stop doing it.

ACKs for top commit:
  Kixunil:
    ACK 861fdd6ab1
  apoelstra:
    ACK 861fdd6ab1

Tree-SHA512: 3da0a600898f490b602ab05a396061587d86ffef55697877885a8c611eff96e7382a2d816fe9594c100d378dc56fe7fdc88009a0343bc602b7f4c180836adbd3
2023-02-10 14:30:28 +00:00
Tobin C. Harding 090dad770f
Improve string parsing
Currently we implement string parsing for height/time from the
`absolute` module but not the `relative` module.

Improve the macros used to implement string parsing and use the new
versions to implement string parsing for the height and time types in
`relative`.
2023-02-10 12:28:25 +11:00
Tobin C. Harding 1e0e712bb0
Add push_* methods for lock times
Lock times are u32 and can necessitate encoding using 5 bytes. As such
they are "special".

Add methods `push_lock_time` and `push_sequence` for pushing absolute
lock times and sequence numbers. We do not push relative locktimes
because they are only 16 bits from the original sequence number.
2023-02-10 12:23:15 +11:00
Tobin C. Harding a7117bf8f1
Document source of logic fro read_scriptint
Our `script::read_scriptint` function is based on the constructor
code (incl. call to `set_vch`) code from Bitcoin Core. Add rustdoc
comment saying so, emit a link because there are already multiple links
to `script.h` in this file (one just right below the added comment).
2023-02-10 12:02:32 +11:00
Tobin C. Harding 2eb2420b40
Add comment on rountripping read/write scripint
We only support reads of upto 4 bytes where as Bitcoin Core allows
reading a `CScriptNum` with more bytes than that. Add a rustdoc
comment (incl. link to Bitcoin Core) mentioning that.
2023-02-10 12:02:00 +11:00
Tobin C. Harding 657dd51e8b
Use OP_0 to better mimic bitcoin core code
Our `Builder::push_int` method is the same as Bitcoin Core `CScript`
`push_int64` method. We currently use `OP_FALSE` (equivalent to `OP_0`)
but recently we added `OP_0`, lets use it to make our code better mimic
Core (also saves devs checking that `OP_FALSE` is the same as `OP_0`).
2023-02-10 12:01:23 +11:00
Tobin C. Harding 31d254a6a8
Fix push operators URL
The URL is wrong (section `#Push_operators` should be
`#push-operators`), also should use angle brackets not back ticks.
2023-02-10 11:59:37 +11:00
Tobin C. Harding 84cd4ca964
Deprecate script::read_uint
There is no current usage for reading an unsigned script integer, seems
like this is kruft from days gone past.
2023-02-10 11:58:25 +11:00
Tobin C. Harding 861fdd6ab1
Put the `MerkleBlock` struct at the top of the file
The `MerkleBlock` struct is the main type in this file, put it at the
top of the file. This leaves the next most important type,
`PartialMerkleTree` below that.

Refactor only, no logic changes.
2023-02-10 11:53:05 +11:00
Tobin C. Harding f0d968197a
Put error at the bottom of the file
The `Error` is not interesting code, put it at the bottom of the file.

Refactor only, no logic changes.
2023-02-10 11:53:05 +11:00
Tobin C. Harding 19e094788f
Use self for Error variant imports
Use `self` to import the error variants to make it more explicit.
2023-02-10 11:53:05 +11:00
Tobin C. Harding 83c2a552db
Put helper function below where its called
Reading the code is arguably easier if we have seen the call site before
seeing the function, saves having to think what the function does.
2023-02-10 11:53:04 +11:00
Tobin C. Harding 5076579fb9
Fix indentation in pmt_tests macro
The macro has unusual indentation, fix to to be more regular.
2023-02-10 11:53:03 +11:00
Tobin C. Harding a7edbfb52e
Move hex data to tests/data
We have a test directory for holding test data, use it to for the hex
used for testing the `MerkleBlock`.
2023-02-10 11:53:02 +11:00
Andrew Poelstra b6387db47f
Merge rust-bitcoin/rust-bitcoin#1627: Add `Weight` and `FeeRate` newtypes
70cf4515db Add `Weight` and `FeeRate` newtypes (Martin Habovstiak)

Pull request description:

  Use of general-purpose integers is often error-prone and annoying. We're working towards improving it by introducing newtypes.

  This adds newtypes for weight and fee rate to make fee computation easier and more readable. Note however that this dosn't change the type for individual parts of the transaction since computing the total weight is not as simple as summing them up and we want to avoid such confusion.

  Part of #630
  Replaces #1607 (I want to get this in quickly and don't want to be blocked on DanGould's availability.)

ACKs for top commit:
  apoelstra:
    ACK 70cf4515db
  tcharding:
    ACK 70cf4515db

Tree-SHA512: ab9cc9f554a52ab0109ff23565b3e2cb2d3f609b557457b4afd8763e3e1b418aecbb3d22733e33304e858ecf900904a1af6e6fdc16dc21483b9ef84f56f103b2
2023-02-10 00:33:56 +00:00
Andrew Poelstra 2290e90b71
Merge rust-bitcoin/rust-bitcoin#1600: Refactor script module
a9108d3939 Refactor script module (Tobin C. Harding)

Pull request description:

  The `script` module is large and unwieldy.

  Refactor the `script` module, splitting it up into a tree of modules. Here are a few of the changes and their stated benefits

  - Split the two script types out into separate files: Readers of the methods can then tell immediately from the file name which type they are reading.
  - Put all the impls for the two script types together: Makes parsing the API easier because one can more quickly see which traits are implemented on what i.e., all the `AsRef` imlps are grouped together.
  - Put the impls for the two script types in order, first `Script` then `ScriptBuf`: Makes it easier for us to see if we missed something.
  - Put the `Builder` and `Instruction` (and associated) types in their own modules: Some devs find long files hard to navigate, so far there hasn't been too much push back against short files.
  - Put tests in a separate file: This idea was recently discussed.

  This is only moving code and fixing import statements etc. No other changes to the code.

  ## Note to reviewers

  This PR is impossible to review from the diff because it moves so much code. Perhaps better to look at the resulting `src/blockdata/script/` directory and see if you like it.

  #### Motivation

  While adding script tagging I was having difficulty navigating the script module.

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

Tree-SHA512: 19123c8cfbdce6c42b322fa75a74073a0114b0ed21bd06ca5727981b3573b74cf05075723b774b92ae2b497e20644fca6e2fac14e30cc44f2802dde5aa567f66
2023-02-09 23:26:58 +00:00
Tobin C. Harding 8596e402f2
Fix docs.rs to use all features
Many moon ago we were unable to build with `--all-features`, this is no
longer the case.

Instruct docs.rs to build the docs with `--all-features`.
2023-02-10 08:04:11 +11:00
Martin Habovstiak 70cf4515db Add `Weight` and `FeeRate` newtypes
Use of general-purpose integers is often error-prone and annoying. We're
working towards improving it by introducing newtypes.

This adds newtypes for weight and fee rate to make fee computation
easier and more readable. Note however that this dosn't change the type
for individual parts of the transaction since computing the total weight
is not as simple as summing them up and we want to avoid such confusion.

Part of #630
2023-02-08 23:17:30 +01:00
Tobin C. Harding 132d2f90b6
bitcoin: Enable alloc feature in features list
In `bitcoin` when we use the `core2` dependency we always need the
"alloc" feature. Enabling "alloc" when enabling "core2" in the "no-std"
feature is confusing because it makes it seem that we don't always need
it.

Set usage of the "alloc" feature of `core2` in the `features` list.
2023-02-08 08:24:50 +11:00
Tobin C. Harding aa62ca224a
hashes: Do not enable core2/alloc feature
`core2` is for Read/Write, nothing to do with allocation and we do not
use the "alloc" feature of `core2` in `hashes`.

Fix core2 dependency/features by doing:

- Explicitly enable "bitcoin_hashes/core2" in `bitcoin`.
- Do not enable "core2/alloc" in `hashes`
2023-02-08 08:24:49 +11:00
Tobin C. Harding c15f8dee29
Improve manifest package section
Improve all manifest package sections by doing:

- Order the list of options uniformly
- Remove unnecessary homepage option (currently same as repo)
- Add categories section
2023-02-08 08:24:49 +11:00
Tobin C. Harding 12f5e37ed9
Add excludes to manifests
We can check which files are included in the packaged release with
 `cargo package --list `.

Add an `exclude` section to each manifest that excludes `tests/` and
`contrib/`. Not all crates have a `tests/` directory yet but they should
so add the exclude anyway to future proof the crates.
2023-02-08 08:24:49 +11:00
Andrew Poelstra cc3b5a080b
Merge rust-bitcoin/rust-bitcoin#1621: Rename `from_slice` methods to `decode`
32d2d62e0f Rename from_slice methods to decode (Tobin C. Harding)

Pull request description:

  The `TaprootMerkleBranch` and `ControlBlock` both have methods on them called `from_slice` but these methods do more that just basic copy from a slice. `decode` is a more descriptive name.

  Deprecate the `from_slice` methods and implement `decode`, on other changes to the logic.

  cc sanket1729

ACKs for top commit:
  apoelstra:
    ACK 32d2d62e0f
  Kixunil:
    ACK 32d2d62e0f

Tree-SHA512: e8c089545411a214ef9393f65d3990be46983000bd045182cc27dd70b62273bf48ac97adaf89d1e7fc807c72964a01eef176c7685684e8f87a01c219746d6d3d
2023-02-07 16:49:55 +00:00
Andrew Poelstra a58460bc3c
Merge rust-bitcoin/rust-bitcoin#1611: Instruct devs to use nightly for embedded
55d17f2c18 Instruct devs to use nightly for embedded (Tobin C. Harding)

Pull request description:

  The embedded test crate requires usage of the nightly toolchain, fix the docs to show this.

ACKs for top commit:
  apoelstra:
    ACK 55d17f2c18
  Kixunil:
    ACK 55d17f2c18

Tree-SHA512: 5d3d611ff4331d8475f77d260ebaa3da3ae71960b709eb4603056d7034885306b8bcc39be488f3391697d47a1074a695979fb50b6cb31af414f873da8e82bdbd
2023-02-07 15:24:38 +00:00
Andrew Poelstra 6db85c1d7e
Merge rust-bitcoin/rust-bitcoin#1601: Add '_ back into the BitStreamWriter
86f372774b Add '_ back into the BitStreamWriter (Tobin C. Harding)

Pull request description:

  Recently we merged `commit 53d4fe66b57c255086def2b5e47afaddee776b75` to fix CI even though a better approach is to use `'_` because it assists reading the code (shows that the bit stream writer is not writing from a reference since its writing a `Copy` type `n`).

  Add back in the `'_` (I forget what its called).

ACKs for top commit:
  apoelstra:
    ACK 86f372774b
  Kixunil:
    ACK 86f372774b

Tree-SHA512: 2a9989164562dbe7bf133e3aeb090fbff7831bfeefb0ac8431e75b17d57184c4d60ac206578c6ebbcff903a3832502a162027ed9f37e5ed87e42a6bf61efa594
2023-02-07 14:34:41 +00:00
Tobin C. Harding a9108d3939
Refactor script module
The `script` module is large and unwieldy.

Refactor the `script` module, splitting it up into a tree of modules.
Here are a few of the changes and their stated benefits

- Split the two script types out into separate files: Readers of the
methods can then tell immediately from the file name which type they are
reading.
- Put all the impls for the two script types together: Makes parsing the
API easier because one can more quickly see which traits are implemented
on what i.e., all the `AsRef` imlps are grouped together.
- Put the impls for the two script types in order, first `Script` then
`ScriptBuf`: Makes it easier for us to see if we missed something.
- Put the `Builder` and `Instruction` (and associated) types in their
own modules: Some devs find long files hard to navigate, so far there
hasn't been too much push back against short files.
- Put tests in a separate file: This idea was recently discussed.

This is only moving code and fixing import statements etc. No other
changes to the code.
2023-02-07 16:07:54 +11:00
Tobin C. Harding 32d2d62e0f
Rename from_slice methods to decode
The `TaprootMerkleBranch` and `ControlBlock` both have methods on them
called `from_slice` but these methods do more that just basic copy from
a slice. `decode` is a more descriptive name.

Deprecate the `from_slice` methods and implement `decode`, on other
changes to the logic.
2023-02-07 14:54:08 +11:00
Andrew Poelstra 611772ca0e
Merge rust-bitcoin/rust-bitcoin#1624: Improve `sighash` module documentation
75b266a129 Improve `sighash` module documentation (Martin Habovstiak)

Pull request description:

  "Sighash" is a technical term that newbies in Bitcoin may not know and could get lost when trying to find how to sign a transaction. This change attempts to make it more obvious that this module is needed for signing.

  Closes #1463

ACKs for top commit:
  tcharding:
    ACK 75b266a129
  apoelstra:
    ACK 75b266a129

Tree-SHA512: 7157566c1639c63ce0fba2832e8e5e846e689d89e24077ed7769b721c5db4613cd7fd8d91464992eb78de74b42912ca877e7182a9c3c9c8848bf94d89767b8cc
2023-02-07 01:21:51 +00:00
Andrew Poelstra 0aba8e56f6
Merge rust-bitcoin/rust-bitcoin#1625: Improve `SighashCache` API
b3188bbac3 Add `Transaction` accessors to `SighashCache` (Martin Habovstiak)
7c6854fe02 Use `Borrow` instead of `Deref` in `SighashCache` (Martin Habovstiak)

Pull request description:

  This changes the bound from `Deref<Target = Transaction>` to `Borrow<Transaction>` (with respective `mut` changes) and adds accessors.

  Closes #1423 (PSBT stuff will be separate issue).

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

Tree-SHA512: 9db2c5890b26e9eefd483d697b42e84b1d7d3b8676fc39b4f39075c149e12697aa538828a757f9187578a958d72a592bb913f8f5788c93feb273db5370979d99
2023-02-07 01:02:09 +00:00
Andrew Poelstra 44ec22f396
Merge rust-bitcoin/rust-bitcoin#1613: Implement from arrays for `TaprootMerkleBranch`
118a593c89 Implement from arrays for TaprootMerkleBranch (Tobin C. Harding)

Pull request description:

  The `TaprootMerkleBranch` contains a vector of `TapNodeHash`s, as such it can trivially be constructed from an array of the same type.

  Implement `From` for all array sizes 1 - 128 inclusive.

  Fix: #1469

ACKs for top commit:
  Kixunil:
    ACK 118a593c89
  apoelstra:
    ACK 118a593c89

Tree-SHA512: dd497abd9143ea8b43485133beaccac9049fb915a95a3422d41c1f99961b59ec95df93efe759aa02f62ba1cf3e1afc4597671f1202ff0fa78eeee8b305d21305
2023-02-07 00:41:43 +00:00
Tobin C. Harding 118a593c89
Implement from arrays for TaprootMerkleBranch
The `TaprootMerkleBranch` contains a vector of `TapNodeHash`s, as such
it can trivially be constructed from an array of the same type.

Implement `From` for all array sizes 1 - 128 inclusive.
2023-02-07 08:10:59 +11:00
Martin Habovstiak 75b266a129 Improve `sighash` module documentation
"Sighash" is a technical term that newbies in Bitcoin may not know and
could get lost when trying to find how to sign a transaction. This
change attempts to make it more obvious that this module is needed for
signing.

Closes #1463
2023-02-06 22:07:21 +01:00
Tobin C. Harding 69688b6487
Merge rust-bitcoin/rust-bitcoin#1610: Add KeyPair import to rustdoc example
277e8e96bd Add KeyPair import to rustdoc example (Tobin C. Harding)

Pull request description:

  Recently, and bizarrely, a PR merged that broke `cargo test --doc`.

  Add an import for `KeyPair` to the `schnorr` rustdoc example.

ACKs for top commit:
  apoelstra:
    ACK 277e8e96bd
  Kixunil:
    ACK 277e8e96bd

Tree-SHA512: ad214b668827b35848cc7b260cbd2104a916a82a5a6d242bdc498c62edc9a0e864f4bdb4abcade42924dbaf951223ae80feacbe68d8a4ccb4562d8ead50b23a9
2023-02-07 08:05:35 +11:00
Andrew Poelstra 12298ddc14
Merge rust-bitcoin/rust-bitcoin#1608: Set `rustv_1_53` in build script
bb612fdafa Set rustv_1_53 in build script (Tobin C. Harding)

Pull request description:

  The rust version is supposed to be set by the build script so that users automagically get features matching the toolchain in use. Currently we have a feature in the manifest for `rustv_1_53` instead setting a compiler conditional configuration option in the build script. This causes `cargo +1.41.1 --all-features check` to fail.

  ## Note

  I don't see `rustv_1_46` used anywhere, do we need that still?

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

Tree-SHA512: f74195d4ee5a5bc5f209e99d30789df3552cef10aee5ea8b61a5a701b753999c34d04be9fe0321ccee7a8ec14fa5a05e0b454b9dc5f8deddd7b5b8d4f3d7e744
2023-02-06 14:11:01 +00:00
Martin Habovstiak b3188bbac3 Add `Transaction` accessors to `SighashCache`
It may be useful to access the transaction stored in `SighashCache`
during signing or afterwards, especially when the transaction is stored
without indirection (to enable long-lived storage).

This change adds the appropriate accessors.
2023-02-06 12:14:30 +01:00
Martin Habovstiak 7c6854fe02 Use `Borrow` instead of `Deref` in `SighashCache`
The requirement for a type dereferencing to `Transaction` prevented
storing the cache in long-lived data without resorting to silly
wrappers. Since `Borrow` is implemented both for `T` and for smart
pointers it's a more flexible bound which this change implements.

While this is technically breaking, all usual non-generic code will
continue to work beause smart pointers generally have `Borrow`
implemented.
2023-02-06 12:14:25 +01:00
Tobin C. Harding aae03999a5
Do not export unusual hash types at crate root
Currently we use a wildcard to export all the hash types in
`hash_types`. We are moving to a world were we only export
normal/standard types from the crate root.

Remove the reexport of the following hash types:

- `FilterHash`
- `FilterHeader`
- `TxMerkleNode`
- `WitnessCommitment`
- `WitnessMerkleNode`
- `XpubIdentifier`
- `Sighash`

Fix: #1541
2023-02-04 13:34:20 +11:00
Andrew Poelstra 732dd038ff
Merge rust-bitcoin/rust-bitcoin#1618: Add newline in rustdoc
f0e4e38844 Add newline in rustdoc (Tobin C. Harding)

Pull request description:

  Docs created with the `sha256t_hash_newtype` macro are missing a newline between the doc heading and doc main section.

  Note that the strings used span multiple lines and therefor the subsequent lines must be aligned with the start of the line (not indented).

  Fix: #1540

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

Tree-SHA512: 240c68864da63688c400498903d5cc345bee224dcd3235df0127dcf391c66ee08c487d31fe59f890009c674574810b689d9a53628d07d8cdd46b79bc0ac3eb2b
2023-02-03 20:08:02 +00:00
Tobin C. Harding f0e4e38844
Add newline in rustdoc
Docs created with the `sha256t_hash_newtype` macro are missing a newline
between the doc heading and doc main section.

Note that the strings used span multiple lines and therefor the
subsequent lines must be aligned with the start of the line (not
indented).

Fix: #1540
2023-02-03 14:11:53 +11:00
Tobin C. Harding 55d17f2c18
Instruct devs to use nightly for embedded
The embedded test crate requires usage of the nightly toolchain, fix the
docs to show this.
2023-02-03 08:44:47 +11:00
DanGould 0ffd928a7d
Carry ConsensusEncoding(encode::Error)
When psbt::Error was Eq, it could not have associated dyn error types.
2023-02-02 13:05:59 -05:00
DanGould 126cbb00ef
Associate io::Error with psbt::Error
In order to associate the error, psbt::Error must not derive so many
traits. Tests are also adjusted for the new error type.
2023-02-02 13:02:33 -05:00
Tobin C. Harding 277e8e96bd
Add KeyPair import to rustdoc example
Recently, and bizarrely, a PR merged that broke `cargo test --doc`.

Add an import for `KeyPair` to the `schnorr` rustdoc example.
2023-02-02 12:22:47 +11:00
Tobin C. Harding bb612fdafa
Set rustv_1_53 in build script
The rust version is supposed to be set by the build script so that users
automagically get features matching the toolchain in use. Currently we
have a feature in the manifest for `rustv_1_53` instead setting a
compiler conditional configuration option in the build script. This
causes `cargo +1.41.1 --all-features check` to fail.
2023-02-02 10:12:16 +11:00
Tobin C. Harding 4a03e2e721
psbt: Remove unused error variant
This error variant is never used, remove it.
2023-02-02 08:10:55 +11:00