We have all of the opcodes defined in a submodule called `all`, this
allows wildcard imports without bringing in the other types in the
`opcodes` module.
Use wildcard import `use crate::blockdata::opcodes::all::*` instead of
fully qualifying the path to opcodes.
7e39082eec Improve doc of `Script::push_verify` (Martin Habovštiak)
Pull request description:
This rewords the doc to have a reasonable summary, adds a little background explaining the opcode behavior and the effect of the function when called multiple times.
Closes#1154
ACKs for top commit:
tcharding:
ACK 7e39082eec
apoelstra:
ACK 7e39082eec
Tree-SHA512: 7f0142c9fcec8ef5b30779f1d22922219180aa103ce2f3039412b1d6b46aa7ee2522181e23a76f9ba5fd84720ef3ff3daa8233d71cf10008f5e3b805b5a5c470
7d851b42ee Move serde_string_* macros to the serde_utils module (Tobin C. Harding)
53b681b838 Move const_assert to bitcoin_internals (Tobin C. Harding)
5a8a5ff6c9 Move debug_from_display to bitcoin_internals (Tobin C. Harding)
a2f08f2bc6 Improve docs on impl_array_newtype macro (Tobin C. Harding)
771cdde282 Move impl_array_newtype to bitcoin_internals (Tobin C. Harding)
Pull request description:
Move macros out of `internal_macros`, done in an effort to work towards removing the `internal_macros` module since we have `bitcoin_internals` now.
ACKs for top commit:
apoelstra:
ACK 7d851b42ee
Kixunil:
ACK 7d851b42ee
Tree-SHA512: b31b3a5b4d18a2dbe3f358bff62ae6ca4041d432c755e9c45b0241d48903e02c95e79ec72a7478b9d2a53486ce9eef19bfe3b8905aba19036e59c0719f193ce7
This rewords the doc to have a reasonable summary, adds a little background explaining the opcode behavior and the effect of the function when called multiple times.
Closes ##1154
Done as part of flattening the `util` module. Simply move the `amount`
module out of the `util` module and to the crate root. Justified by the
fact that the `Amount` type is more-or-less a "primitive" bitcoin type.
dd8730e14f Use new PSBT signing API in example (Tobin C. Harding)
d2367fb187 Add PSBT sign functionality (Tobin C. Harding)
b80e5aeaab Re-order import statements (Tobin C. Harding)
Pull request description:
Add an API for signing inputs to the `PSBT` struct. This is work based on code in `rust-miniscript` and the API design suggestions below from @sanket1729 and @Kixunil.
Please note, this adds an `unimplemented!` call for taproot inputs. ECDSA signing is complete.
Includes a patch adding the psbt example from https://github.com/rust-bitcoin/rust-bitcoin/pull/940 updated to use this new api. Run `cargo run --example psbt --features=bitcoinconsensus` to test it out.
ACKs for top commit:
dunxen:
ACK dd8730e
apoelstra:
ACK dd8730e14f
sanket1729:
reACK dd8730e14f
Tree-SHA512: 6345571e53cd3aa4b7ad962536da47ae03ab7c0b088107dc4104676bdb64fcf892e8fa60e0b716f3ef158d88d7058938bf267046721ccf74b2d1b092e9b9aaaa
In preparation for emptying the `internal_macros` module move the
`serde_string_impl` and `serde_struct_human_string_imp` macros to the
`serde_utils` module.
Rationale: `internal_macros` stuff can go over in the `internals` crate
now that we have one. The serde macros could go over there but we have a
`serde_utils` module that holds code for implementing serde traits,
these two macros are exactly that.
`impl_array_newtype` is an internal macro, move it to a new, ever so
meaningfully named, `macros` module.
Use `#[macro_export]`, no other changes to the macro.
Signing a PSBT requires no knowledge other than what we have here in
this library and the PSBT ready to be signed.
This code was pulled out of `rust-miniscript`.
Add a `sign` method to the `PartiallySignedTransaction`.
The import statements in `psbt/mod.rs` are a bit of a mess, re-order
them in an attempt to group like things and separate out things that are
different (e.g. `pub use` from `use`).
Refactor only, no logic changes.
4057c26829 Run formmater on bip152 (Tobin C. Harding)
facd8ba556 Move bip152 module to crate root (Tobin C. Harding)
Pull request description:
We are attempting to flatten the `util` module.
Move the `bip152` module to the crate root out of `util`.
Currently `src/util/` is ignored by the formatter so this move requires `bip152` module to be formatted. Formatting is done as a separate patch so reviewers can run `cargo +nightly fmt` and compare the diffs if so desired.
ACKs for top commit:
apoelstra:
ACK 4057c26829
sanket1729:
code review ACK 4057c26829
Tree-SHA512: 889d78817f60b8d038d631059432b37940e97299b9fd3f0055b2ede61b5f87cce4824ac0be239fc3897ff6da8068749c8504aa0714aab35cc0faf519606771bf
We are attempting to flatten the `util` module; move the `bip152` module
to the crate root out of `util`.
Currently `src/util/` is ignored by the formatter so this move causes
the `bip152` module to be formatted.
d1b7dff094 return custom error from `Network::from_str` (Noah)
Pull request description:
Fix#1292
Had some time so got this out of the way.
ACKs for top commit:
apoelstra:
ACK d1b7dff094
tcharding:
ACK d1b7dff094
Tree-SHA512: f6566f4df74c697cc3d84eca4e4c45bb5da9e86fe32e5f6e257a3e8c3e22fc375f5f307c7f96edd4536a80c1d1c13535f6073a1a093911468abb015040c2888b
02a2b43b2b Remove Default impl for Target and Work (Tobin C. Harding)
cb9893c4a9 Add Target and Difficulty types (Tobin C. Harding)
Pull request description:
Ugh! 1600 lines of green and 1100 of red - my apologies.
Currently we use the `Uint256` type for proof-of-work calculations. It was observed in #1181 that providing a public 256 bit integer type like this implies that it is a general purpose integer type. We do not want to provide a general purpose integer type (see the 1000 arithmetic functions on stdlib integer types for why not :)
Add two new opaque integer types `Target` and `Work`. These are the inverse of each other, both conceptually and mathematically.
There is a lot of code in this PR, sorry about that. At a high level the PR does:
- Add a `pow` module.
- Put a modified version of `Uint256` in `pow`, making it private.
- Add two new wrapper types `Target` and `Work` that provide a very limited API specific to their use case. In particular there are methods on each to convert to the other.
- Only implement methods that we use on each type.
### Note
During development I got mixed up with the word "difficulty", I have discovered this has a very specific meaning in Bitcoin. Please see rustdocs on the `Target::difficulty` function for explanation of this term. For this reason we use the type `Work` defined as the inverse of target, and reserve "difficulty" for the Bitcoin concept.
ACKs for top commit:
apoelstra:
ACK 02a2b43b2b
Kixunil:
ACK 02a2b43b2b
Tree-SHA512: 4d701756a42b832f03b8d542f3a5278b4ca1d5983ffd7d4630577ebd4cc8f47029719f9018185e01fa459d8fb32426b5cb4d6b8d8b588ebbb7b65e4aeee94412
9eca3c58c5 Add script to launch fuzzing continuosly (Riccardo Casatta)
Pull request description:
Continuosly cycle over fuzz targets running each for 1 hour.
I use this script on a server of mine and maybe sharing the script incentives other doing the same
ACKs for top commit:
apoelstra:
ACK 9eca3c58c5
sanket1729:
ACK 9eca3c58c5. I do have the resources to actually run it, but I successfully ran it locally with 5 sec cycle for testing.
Tree-SHA512: 23f24039bc32c091ea287ada9335e13bb81ae286cd8d42ab1a2b551c3dd8ba55c6d0c0051d9032baa169354786e77d257d6471f7255981a160bfd1695300201c
13e9a133df fix test_data dir exclusion (Riccardo Casatta)
Pull request description:
I noted our released crate `0.29.1` was bigger than expected and noted with `cargo package --list` that even with our exclude the `test_data` dir was included. I am also going to backport this.
As specified in the doc:
`foo/` matches any directory with the name `foo` anywhere in the package.
ACKs for top commit:
apoelstra:
ACK 13e9a133df
sanket1729:
ACK 13e9a133df
Tree-SHA512: 298c1a50f3914dec19600529daee1978f47dc47ce288fdb5c575cd67a5c24421990dcf379b81b3637917d2d17b8585b853092e9970803959b22f36c0133e1b19
2bae74688e Add `Script::builder` convenience function (Casey Rodarmor)
Pull request description:
Add a convenience function to `Script` to create a new builder, so that `Builder` doesn't need to be imported. This is a pretty common pattern in Rust for types which have associated builders.
ACKs for top commit:
sanket1729:
reACK 2bae74688e
apoelstra:
ACK 2bae74688e
Tree-SHA512: 8ae8e6bbd2f078d2bd1727296633ee8beb0af2ebf5d333f24a1bacf6993f86a1f860cfe7f5ec91236d1b30eeb5df53719df4841f462a19ff86a63a037889f17c
A zero default value for `Target` and `Work` has no significance and/or
usecase, remove the derived `Default` implementation.
Includes making `Target::ZERO` public.
bfb4977be9 implement `AsMut<[u8]>` and `AsMut<[u8;4]>` for `Magic` (Noah)
Pull request description:
Follow up to https://github.com/rust-bitcoin/rust-bitcoin/pull/1288#discussion_r982152738
Implemented `AsMut<[u8]>` and `AsMut<[u8;4]>` for `Magic`.
ACKs for top commit:
Kixunil:
ACK bfb4977be9
apoelstra:
ACK bfb4977be9
Tree-SHA512: f1732f2b6db285e64baf07e70917eb8c0938b3a8d11f8266c0f2c846b7b2d4447cb99721b55c9db877f88c398dd74477c41bdae34679b6c3b6ade71455538241
6e5e8d80a6 add error implementations for `ParseMagicError` and `UnknownMagic` (Noah)
a79c69894a new type network magic (Noah)
Pull request description:
#1266
Added a new type `Magic` for network magic.
ACKs for top commit:
Kixunil:
ACK 6e5e8d80a6
apoelstra:
ACK 6e5e8d80a6
Tree-SHA512: a67703e497af0e317f03d5cd4efca9ed6878c252a68aefa56592bfcac2946e8f62f1ae746de8a20344d846ec5623997acffe8a04b81b4faa25e579bebcd95f90
Currently we use the `Uint256` type to represent two proof of work
integers, namely target and difficulty (work).
It would be nice to not have a public integer type that is not fully
implemented (i.e., does not implement arithmetic etc as do integer types
in stdlib). Instead of implementing all the stdlib functions we can
instead add two new wrapper types, since these are not general purpose
integers they do not need to implement anything we do not need to use.
- Add a `pow` module.
- Put a modified version of `Uint256` to `pow`.
- Add two new wrapper types `Target` and `Difficulty`.
- Only implement methods that we use on each type.
Note this patch does not remove the original `Uint256`, that will be
done as a separate patch.
f5412e2aa2 Fix clippy warnings (Tobin C. Harding)
Pull request description:
Clippy recently upgraded and a few two new warnings types popped up in our codebase, fix them both in a single patch so CI passes for all commits.
1. Remove unneeded explicit borrow
2. Use `if let Some` instead of pattern match
ACKs for top commit:
apoelstra:
ACK f5412e2aa2
Kixunil:
ACK f5412e2aa2
Tree-SHA512: 1faeb6173061e28a1acfe1a37a669982abbd832b327448e31648c447a7d043841edf30349700ff9da9dd330cfa6d497d188534daab825069e4489653e25987ca
Clippy recently upgraded and a few two new warnings types popped up in
our codebase, fix them both in a single patch so CI passes for all
commits.
1. Remove unneeded explicit borrow
2. Use `if let Some` instead of pattern match
e24c91e9ca sign_message: Run cargo fmt (Tobin C. Harding)
041d6a8097 Move and deprecate script_find_and_remove (Tobin C. Harding)
Pull request description:
Done as part of [flattening util](https://github.com/rust-bitcoin/rust-bitcoin/issues/639).
Move some code out of `misc` then re-name the module to `signature` and move it to the crate root.
- Patch 1: Move a single public function, needs review that destination module is ok. I did consider re-naming the function to remove `script_` prefix but decided to leave it as is.
- Patch 2: Re-names `misc` -> `signature` and puts it in the crate root
- Patch 3: Runs the formatter on `signature` module
All changes include deprecated re-exports.
ACKs for top commit:
apoelstra:
ACK e24c91e9ca
Kixunil:
ACK e24c91e9ca
Tree-SHA512: 37efc69595cbacd75c27f8fa6edd6bc168c04f1cdd230b49ab97f8a07e5b25ea87c00de017b315987bfe84d1b652a2c301c8f0132e4da988af1d15b687b47333
2001f44e46 Try to fix up sighash export mess (Tobin C. Harding)
Pull request description:
Recently we moved a few types from `transaction` to `sighash`, while doing so I erroneously annotated code with the `deprecated` attribute hoping it would give downstream users a gentle upgrade experience. It turns out `deprecated` only works on functions.
During that same work, we re-exported from the crate root a bunch of types from the `sighash` module that probably should not have been re-exported. We are currently trying to create a nice clean API surface, in an effort to move in the right direction we should remove the re-exports and just re-export the `sighash` module.
Try to clean up the sighash export mess by doing:
- Remove the re-exports from the `transaction` module
- Remove crate level re-exports of `sighash` module types
- Re-export `sighash` module
Note, this patch is a breaking API change, justified by the fact that there is no good way to gently lead downstream when moving types since types cannot be deprecated with the `deprecated` attribute.
ACKs for top commit:
apoelstra:
ACK 2001f44e46
Kixunil:
ACK 2001f44e46
Tree-SHA512: 42a08bc15bacd4cf7c3fec002ddb29afe5b1be3c4eb74fbd8c63a9333c0d45cbc8493027532f5db6a3930d49b1e83048826371e0ed7d4ac3dc611e5885540bce
8bed2ddffe Run formmater on bip32 (Tobin C. Harding)
34113c9558 Move bip32 module to crate root (Tobin C. Harding)
Pull request description:
We are attempting to flatten the `util` module.
Move the `bip32` module to the crate root out of `util`.
Currently `src/util/` is ignored by the formatter so this move requires `bip32` module to be formatted. Formatting is done as a separate patch so reviewers can run `cargo +nightly fmt` and compare the diffs if so desired.
ACKs for top commit:
apoelstra:
ACK 8bed2ddffe
Kixunil:
ACK 8bed2ddffe
Tree-SHA512: dadea31be0459fd10e71927bd21dc44b59428f695a6df7093052ca7257b6590d5dd5b1343a89869ac9f4d7805dbca7558b475048ea9387c36265f14246cc6852
ee19a1633d internals: Run formatter (Tobin C. Harding)
Pull request description:
Add one `rustfmt::skip` statement and run `cargo +nightly fmt`.
ACKs for top commit:
apoelstra:
ACK ee19a1633d
Kixunil:
ACK ee19a1633d
Tree-SHA512: 524ff2cda383c95a086f4b2e9da443bf0202fc21f71024e6230d64ad57098ab304402dd12c9e4d831b3ef5c153f45e916ae4c928107ac9a847fba65354365a98
8aa94bd0b2 Improve docs on is_implied_by (Tobin C. Harding)
b8721bf244 Add method relative::LockTime::is_implied_by (Tobin C. Harding)
d5492b8a25 Add absolute::LockTime::is_implied_by method (Tobin C. Harding)
98cbdb5a5c Increment lock value (Tobin C. Harding)
Pull request description:
Patch 1 is a docs improvement.
Patch 2 commit log:
When implementing the absolute lock time API we decided on _not_
supporting checking lock satisfaction with another lock, instead we
provided a pattern in the docs for doing so. Fast forward a months and
I, the primary author, then forgot to use the correct pattern when using
the API in `rust-miniscript` - this is a sure sign that the API is too
hard to use. In this time we worked on the relative lock API and came up
with a `is_satisfied_by_lock` method - this is identical to the required
use case in the absolute lock time module.
Add a method on `absolute::LockTime` for checking a lock against another
lock, add rustdoc comment explaining the methods function in filtering
prospective lock time values (how we use it in `rust-miniscript`).
ACKs for top commit:
Kixunil:
ACK 8aa94bd0b2
apoelstra:
ACK 8aa94bd0b2
Tree-SHA512: 5c7efa1727a846248783c9e6044bf8b0a7550d298ca1b5d3274ef325cf82efa33392ad14ef7e3e9aa91423ba56e8a3e7f4a38a966be38f673dccefd46465ad51
f429c22599 Remove user_enum macro (Tobin C. Harding)
ad29084582 Add Network serde roundtrip test (Tobin C. Harding)
Pull request description:
Remove the `user_enum` macro because it is only used once and is unnecessarily complicated.
Patch 1: Add a preparatory unit test to make sure patch 2 maintains the current serde logic.
Patch 2: Simplify `Network` by removing `user_enum`
ACKs for top commit:
Kixunil:
ACK f429c22599
apoelstra:
ACK f429c22599
Tree-SHA512: 770ee0aa82be711ed11bdfda338de8d13071743cdc8d7e3e1252a6759dfdfa2be6ff1d8cd286acef75dc5a5d73a6bc5f565b02cb20d4b549e0714cef5d7c1973
b79c178ea8 Add fuzz test for PrefilledTransaction (Tobin Harding)
Pull request description:
Add a simple deserialization fuzz test for `PrefilledTransaction`.
Fixes: #460 (I think, I'm not sure if any of the other types need fuzzing?)
ACKs for top commit:
apoelstra:
ACK b79c178ea8
Kixunil:
ACK b79c178ea8
Tree-SHA512: 3e5cbda6b17c36f414bce05b562b5648d82433b185853e6c8aa33ec491b58e527626eb09caca2a988120329efd92dfd3aaad60ef99746d6ac41555160efeb9d6
The `user_enum` macro is only used a single time. The macro includes
custom serde logic which can be trivially derived instead.
Remove the `user_enum` macro and just implement `Network` the old
fashioned way. Doing so simplifies the code.
We are attempting to flatten the `util` module; move the `bip32` module
to the crate root out of `util`.
Currently `src/util/` is ignored by the formatter, this patch does not
do formatting, will be done later.