There is no need no nest the `bitcoinconsensus::Error` type within the
`script::Error`, it is the only error type returned by the verify
functions so just return it directly.
Not totally necessary but since I went to the trouble of working out the
last working version add it to the docs so the next guy can grep for
`cargo update` to find them.
To help folk work out how to run the `hashes/embedded` test crate copy
over the `script` directory and an updated version of the `README` from
`embedded/bitcoin`.
In order to keep the embedded and schemacs test crates building when we
update their local transient dependencies we need to use a `patch`
section.
- For `bitcoin/embedded` add `patch` section for `internals`, `hashes`
already has an entry.
- For `hashes/embedded` add `patch` section for `internals`.
- For `hashes/extendend_tests/schemars` add `patch` section for
`internals`.
FTR for direct local dependencies we use a `path` field when specifying
the dependency.
We use two different methods for specifying local dependencies, `patch`
and also `path`. There does not seem to be a reason why we use both,
lets be uniform. Elect to use `patch` for all local crates.
I have managed to burn out or bore our reviewers/maintainers. Getting
two acks is becoming increasingly difficult. I've pestered everyone to
the limit that I feel socially comfortable doing so am requesting a
carve out to the 2-ACK before merge rule.
The primary justification is that I feel we should have a bit more of
BDFL and a bit less total consensus if we are to push forwards.
92749d29e4 Rename PartiallySignedTransaction to Psbt (Tobin C. Harding)
Pull request description:
Last release we added a type alias for `Psbt`, now lets just rename the type and be done with it.
Includes re-export at the crate root because `bitcoin::Psbt` is clear and obvious.
ACKs for top commit:
sanket1729:
ACK 92749d29e4.
apoelstra:
ACK 92749d29e4
Tree-SHA512: 2ded728409829709a46acd2a83ce9a91839bce222264b2fca122b346ec4f45a52c3f970eb05001794e2f355ce9391df1a184b57baf24589e8a5c3f77f72f6ec7
8813a63ec9 internals: Bump version to 0.2.0 (Tobin C. Harding)
Pull request description:
In preparation for release bump the version and add a changelog entry. Includes updating the dependency in `bitcoin` and `hashes`.
ACKs for top commit:
apoelstra:
ACK 8813a63ec9
sanket1729:
utACK 8813a63ec9
Tree-SHA512: a9bd9d4d69cba21329f3f63a9948afe566bb97c8c65f5d46c329a696a814e9eb31372d378de1ecf0f43f0cb42f11d53dc51bc467223b34629e61315d48b39a29
Last release we added a type alias for `Psbt`, now lets just rename the
type and be done with it.
Includes re-export at the crate root because `bitcoin::Psbt` is clear
and obvious.
The previous code seems to have been rebased/iterated on too many times,
and had room for significant simplification. By inlining the indentation
logic we can eliminate 40 LOC and also clean up the output by removing
trailing spaces.
71c0043127 Remove docsrs attributes (Tobin C. Harding)
Pull request description:
Somehow when we started using `doc_auto_cfg` we forgot to remove a bunch of docsrs attributes.
ACKs for top commit:
apoelstra:
ACK 71c0043127
sanket1729:
utACK 71c0043127
Tree-SHA512: 16ff8eec0f6cd392d496f8f07cc0773bbda28f7c71022ae6b5e2c47a98d40c94a9169c60c0d8fa5a819f07910593d65a47b69bdc748d64cda0aac3323e9599a6
81a42536f9 Use hex_lit::hex in benches (Tobin C. Harding)
Pull request description:
Currently the test `hex` macro is only available when the `test` compiler configuration option is set but we are using it in benches code, this works for use because `cargo bench` sets `test` for the current crate, however it breaks downstream crates.
Fix: #1830
ACKs for top commit:
RCasatta:
ACK 81a42536f9
apoelstra:
ACK 81a42536f9
Tree-SHA512: 429d38093cf42c50464ce5389313fde7c7d2644423ef11ed8f0a3eed1d55f2d2e4b66b7c2dc6e59e4c2cb96128b09d45a1b48369b404ac5eaecf845d2098f467
Currently the test `hex` macro is only available when the `test`
compiler configuration option is set but we are using it in benches
code, this works for use because `cargo bench` sets `test` for the
current crate, however it breaks downstream crates.
Fix: #1830
In preparation for release bump the version and add a changelog entry.
Includes updating the dependency in `bitcoin` and `hashes` as well as
the minimal/recent lock files.
d45dbef3e7 Manually implement Debug on Witness (Tobin C. Harding)
Pull request description:
The current derived debug implementation on `Witness` prints the content field as an array of integers. We can do better than this by manually implementing `Debug`.
With this applied `Witness` is printed as follows: (first line is `{:?}` and the next is `{:#?}`):
Using `{:?}`:
```
Witness: { indices: 3, indices_start: 8, witnesses: [[0x00], [0x02, 0x03], [0x04, 0x05]] }
```
Using `{:#?}`:
```
Witness: {
indices: 3,
indices_start: 8,
witnesses: [
[0x00],
[0x02, 0x03],
[0x04, 0x05],
],
}
```
ACKs for top commit:
sanket1729:
tested ACK d45dbef3e7. This would be helpful for debugging downstream.
apoelstra:
ACK d45dbef3e7
Tree-SHA512: eacf4fa8e3f38c4e9ddc45de78afb8eab5b5b196b77a6612f61860e0e4e7ba96de2e7f434b92816e0b00532e73c05378cafc046ec9c34108e9d9216fb36c524a
552f19abe3 Add more rustdocs to WitnessProgram (Tobin C. Harding)
89303c1464 Move witness types to the script module (Tobin C. Harding)
Pull request description:
This is done as part of an ongoing effort to improve the `address` module and `Address` type.
- Patch 1: Move `WitnessVersion` and `WitnessProgram` to their own modules within `script` - this is code move only except for the variant changes to the `address::Error` enum (see note below on `rustfmt` acting up).
- Patch 2: Improves documentation on the `WitnessProgram`
-
### Note on `rustfmt`
There are a bunch of formatting changes that shouldn't be in here, I stashed and re-ran the formatter a bunch of times but for some reason `rustfmt` wouldn't change `address` as it is but after I patched it `rustfmt` made a bunch of changes.
ACKs for top commit:
sanket1729:
ACK 552f19abe3
apoelstra:
ACK 552f19abe3
Tree-SHA512: 6c33124e1fd4fd7dcc51af4df0584579da8ed8451f4243dc3392babe3e3385d68a7beab9d052cd3f08342032dce7add4c892c6d0187133d64622115bef9fa872
Add rustdocs to `WitnessProgram` commenting on why we carry the witness
version number around with the witness program. This is mainly a dev
comment but it helps document the invariants so make it a rustdoc
comment.
From BIP 141:
> A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that
> consists of a 1-byte push opcode (for 0 to 16) followed by a data push
> between 2 and 40 bytes gets a new special meaning. The value of the
> first push is called the "version byte". The following byte vector
> pushed is called the "witness program".
`WitnessVersion` and `WitnessProgram` are scriptPubkey concerns and
scriptPubkey is basically synonymous with address so in one way it makes
sense that these types are in `address` however we are in the process of
overhauling the `Address` (and `AddressInner`) types so lets move the
witness stuff to `script` and put it in individual sub-modules.
This move helps simplify the address error type also.
Note please, there are a bunch of formatting changes in here in the
error type that I cannot explain and could not remove.
c3a99c62ad CI: Pin serde_json for MSRV build (Tobin C. Harding)
Pull request description:
Recent release of `serde_json` depends on `serde` 1.0.66 but we pin to 1.0.56
Pin `serde_json` for MSRV build to v1.0.99
ACKs for top commit:
apoelstra:
ACK c3a99c62ad
sanket1729:
ACK c3a99c62ad
Tree-SHA512: f9c4e679c9b7f827132f4172056d48fd7428330d8acdb390b022825cfcf20d96610dd7a5cd77c2e833efb8ad52f0d0a5895a7657758a0af01da47db7a881a797
The current derived debug implementation on `Witness` prints the content
field as an array of integers. We can do better than this by manually
implementing `Debug`.
With this applied `Witness` is printed as follows: (first line is `{:?}`
and the next is `{:#?}`):
Using `{:?}`:
```
Witness: { indices: 3, indices_start: 8, witnesses: [[0x00], [0x02, 0x03], [0x04, 0x05]] }
```
Using `{:#?}`:
```
Witness: {
indices: 3,
indices_start: 8,
witnesses: [
[0x00],
[0x02, 0x03],
[0x04, 0x05],
],
}
```
The `empty` constructor is mis-named for the following reasons:
- Non-uniform with `ScriptBuf::new`
- Non-standard with respect to stdlib which uses `Path::new` and
`PathBuf::new` (on which we based the `Scritp`/`ScriptBuf`)
Rename the function to `new`, put it at the top of the impl block while
we are at it.
c958112824 update proc-macro to 1.0.56 to 1.0.63 (Andrew Poelstra)
Pull request description:
1.0.56 does not compile on Rust nightly anymore.
ACKs for top commit:
yancyribbens:
ACK c958112824
tcharding:
But ACK c958112824
adoerr:
ACK c958112824
sanket1729:
ACK c958112824
Tree-SHA512: bdab34d9a7ba74e18489f0cacd9aa5c65cd1f09d269fdba92dfa2ad16e19bd2de346e7378be23e79a893a10b71db1fb465edd74fb73f6e28e476415826226ea8
fc167097aa Added examples for sighash computations (Alec Matusis)
Pull request description:
So far computed sighashes and verified signatures for:
- P2WPKH
- P2MS 2of3
- P2SH 2of2 multisig
- P2SH 2of3 multisig
- P2WSH 2of2 multisig.
TODOs:
- Add P2TR script-path multisig and key-path examples
- Are there mutisig transactions where flags are different for diff signatures within an input?
- Maybe switch to segwit_signature_hash()?
- Consider also verifying script hash if we go for full P2(W)SH transactions verifications?
ACKs for top commit:
tcharding:
ACK fc167097aa
apoelstra:
ACK fc167097aa
Tree-SHA512: 67750b614592391d8252fc270be8676f8aef61eb842c49816386396e7afaa472921c21df40d13291ee80e653f3a0ec367f7b941920f1777f086815bf222e8e62
96784b9cfa Make sha512::HashEngine fields private (Tobin C. Harding)
Pull request description:
Recently we made the hash engine fields pub crate so that `sha512_256` could construct a hash engine with different constants. We can make the code slightly cleaner by adding a pub crate constructor and making the fields private again.
Idea from Kixunil:
https://github.com/rust-bitcoin/rust-bitcoin/pull/1413#pullrequestreview-1197207593
This is a follow up to #1413, cc kcalvinalvin as the author of that one.
ACKs for top commit:
apoelstra:
ACK 96784b9cfa
Kixunil:
ACK 96784b9cfa
Tree-SHA512: 40faa969b2227e46ea66a4ce887f17d9a48a0bc18846fb6bb1a51dd117a4e49cc031196846e913e03c39597cacd30a61a55bd1ccde600be72583965d2faf090a
6881080f8e Fix incorrect comment in ci script (Tobin C. Harding)
Pull request description:
MSRV build breaks because of edition _2021_ not 2018.
ACKs for top commit:
yancyribbens:
I feel like this comment isn't very helpful and worth maintaining. However ACK 6881080f8e to correct it.
Kixunil:
ACK 6881080f8e
apoelstra:
ACK 6881080f8e
Tree-SHA512: c909e986fa96e68211177fa4eed4e9645fb4c918c062d3be40df8f3615f877b0a89932fd39bf95475c2ee4a1557174c09c3a5b4e9853680ed74d9116a48703c9
Recently we made the hash engine fields pub crate so that `sha512_256`
could construct a hash engine with different constants. We can make the
code slightly cleaner by adding a pub crate constructor and making the
fields private again.
Idea from Kixunil:
https://github.com/rust-bitcoin/rust-bitcoin/pull/1413#pullrequestreview-1197207593
Expose signature verification functionality for ECDSA signatures on the
`PublicKey` type.
We should have an identical function on `XOnlyPublicKey` but this will
have to be done in `secp2561`.
aa7b3a7d0c ci: Remove stal DO_ALLOC_TESTS variable (Tobin C. Harding)
Pull request description:
We never enable the `DO_ALLOC_TESTS` variable, and hence never test the "alloc" feature in `hashes`.
Remove the `DO_ALLOC_TESTS` variable and add "alloc" to the `FEATURES` array.
ACKs for top commit:
yancyribbens:
ACK aa7b3a7d0c
apoelstra:
ACK aa7b3a7d0c
sanket1729:
utACK aa7b3a7d0c
Tree-SHA512: 461735242ec94786624a3653c3ea108d1a8712d5a77943f2ce54b44298624f6d4a43c98a0079782211e9a4b61ac87fbadd9c98608ca0ad82574c4a63b921776f
7cdc90565f Mutate mul_u64 with mutagen (Tobin C. Harding)
Pull request description:
Add the `mutate` attribute to mutate `mul_u64`. Add non-doc comments listing the two false positives. These are identical but we list them twice so when devs grep for `mutagen false pos` the same number of lines for each function is displayed as is displayed by the `mutagen` run. This coding false positives thing is also introduced in PR #1655.
ACKs for top commit:
apoelstra:
ACK 7cdc90565f
sanket1729:
utACK 7cdc90565f
Tree-SHA512: d066beb2f9ba198f5af36258ba15cfbd2c7c9ce7596f6340ed1fe2f62a2b0b5296eeb2cb4be30146d019671f1858521c29db917936895b5b3fd36bdb0bd07e57
4dfaec952c hashes: Remove stale status badge (Tobin C. Harding)
Pull request description:
We do not use travis in our CI pipeline anymore, remove the stale badge.
ACKs for top commit:
yancyribbens:
ACK 4dfaec952c
apoelstra:
ACK 4dfaec952c
sanket1729:
utACK 4dfaec952c
Tree-SHA512: 6865c8cc51f90161ea643922df3bbf890811777e3dcbff9e464d6092f0d79a6ae2798d593f6a27e7f18b05ba66a765c871d4d01086e18b8480916573288afc0e
9f7449b572 Use from_int_btc function for const context (yancy)
f93e67977a Add from_int_btc function to Amount (yancy)
Pull request description:
Followup PR from https://github.com/rust-bitcoin/rust-bitcoin/pull/1811
Added a `const` associated function `from_int_btc()` for Amount. `panic()` in const context is only available after 1.57+ so a work around is provided.
ACKs for top commit:
tcharding:
ACK 9f7449b572
apoelstra:
ACK 9f7449b572
Tree-SHA512: 7755234f2e573577d754f0224083cb7acc059e58833790fe344b0d9bad0acd89b0f74054d9efcba2133576222c7e9ab8dc3d81ddc10fbdcd4f83638d697118c4
654f58da17 This library is not solely dependent on Rust (roy9495)
Pull request description:
Fix: #1867
Docs claim this library is pure rust but it depends on libsecp256k1 (and optionally libbitcoinconsensus)
So, I changed the lib.rs file accordingly.
ACKs for top commit:
Kixunil:
ACK 654f58da17
apoelstra:
ACK 654f58da17
Tree-SHA512: 139a921ead8e96472adb8019a0b43bcde728578699092c69322459d865be0de69ca48d073cc4c16739257627f2b6dea4e77332f2d32894812ae5b91935257782