Commit Graph

3357 Commits

Author SHA1 Message Date
Andrew Poelstra 57fff47408
Merge rust-bitcoin/rust-bitcoin#994: Add a `LockTime` type
0ed78e543b Add lock time types (Tobin C. Harding)
1390ee12ec Add a max scriptnum constant (Tobin C. Harding)

Pull request description:

  Implement a `LockTime` type that adds support for lock time values based on nLockTime and OP_CHECKLOCKTIMEVERIFY.

  For example usage in `rust-miniscript` please see https://github.com/rust-bitcoin/rust-miniscript/pull/408.

  ### Notes:

  I probably should have opened a new PR, this is a total re-write and very different from what is being discussed below, sorry, my bad.

  This is just half of the 'timelock' story, its the easier half. The reason I switched terminology from timelock to locktime is that we have to compare two u32s so it does not make sense to call them _both_ timelocks.

  If I have missed, or apparently ignored, anything you said reviewers please accept my apology in advance, it was not intentional. The thread of discussion is long and this topic is complex. Please do restate your views liberally :)

  Here is a useful blog post I used while touching up on timelock specifics: https://medium.com/summa-technology/bitcoins-time-locks-27e0c362d7a1. It links to all the relevant bips too.

ACKs for top commit:
  Kixunil:
    ACK 0ed78e543b
  apoelstra:
    ACK 0ed78e543b

Tree-SHA512: 486fcce859b38fa1e8e6b11cd2f494462d6d7d1d9030d096ce6b260f6c9d0342b8952afe35152bdf3afe323a234a8165ac3d6c946304afcc13406d7a0489d75a
2022-07-27 16:15:01 +00:00
Tobin C. Harding c67f74bb81 Upgrade bech32 to version 0.9.0
Recently `rust-bech32` v0.9.0 was released, this release included
updating the MSRV to 1.41.1.
2022-07-27 12:03:48 +10:00
Tobin C. Harding 0ed78e543b Add lock time types
Add a `LockTime` type to hold the nLockTime `u32` value. Use it in
`Transaction` for `lock_time` instead of a `u32`. Make it public so this
new type can be used by rust-miniscript and other downstream projects.

Add a `PackedLockTime` type that wraps a raw `u32` and derives `Ord`,
this type is for wrapping a consensus lock time value for nesting in
types that would like to derive `Ord`.
2022-07-27 08:39:19 +10:00
Tobin C. Harding 1390ee12ec Add a max scriptnum constant
Integers within Script can have a maximum value of 2^31 (i.e., they are
signed) but we (miniscript) often uses unsigned ints, to facilitate
checking the unsigned type is the correct size to fit in a signed int
add a const `MAX_SCRIPTNUM_VALUE`.
2022-07-27 08:36:14 +10:00
Andrew Poelstra 7a346970d0
Merge rust-bitcoin/rust-bitcoin#1126: Remove stale MSRV docs
fe840f0b42 Fix stale toolchain docs (Tobin C. Harding)
73b506e149 Remove stale MSRV docs (Tobin C. Harding)

Pull request description:

  We have stale docs referring to the old MSRV. We do not need MSRV docs
  in `CONTRIBUTING` because we have them in the README already.

  Fix stale docs by doing:
  - Remove the MSRV docs from readme in favour of `CONTRIBUTING.md`.
  - Add a sentence to the redame pointing readers towards `CONTRIBUTING.md`.
  - Point readers towards `RUSTUP_TOOLCHAIN`

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

Tree-SHA512: 6d3006db7a460e5d7146b73ff4b99dc322d396e65da39f5ea47c4904aa387c8a36e4a8ae707653dbab90096e692bf69918e6c19c4d3d989c85b22dba4dcba904
2022-07-26 14:18:35 +00:00
Andrew Poelstra 92b6211696
Merge rust-bitcoin/rust-bitcoin#1079: Run clippy from the test script
74f3a5aeda Run clippy from the test script (Tobin C. Harding)
aa8109a791 Use struct field short form (Tobin C. Harding)
d1a05401f4 Remove redundant calls to clone (Tobin C. Harding)
196492554d Use assert instead of assert_eq (Tobin C. Harding)
3173ef9dbb Remove unnecessary explicit reference (Tobin C. Harding)

Pull request description:

  Currently we run clippy in CI using a github action. The invocation has a couple of shortcomings

  1. it does not lint the tests (this requires `--all-targets`)
  2. it does not lint the examples

  I could not find a way to lint the examples without explicitly linting each example by name.

  **This PR does the following:**

  - Fix clippy issues (patch 1-4)
  - Move the clippy control to `test.sh`
  - Add an env var `DO_LINT` to control it
  - Remove the separate CI job
  - Run the linter during the `Test` job using the stable toolchain.
  - Run clippy with ` --all-features` AND `--all-targets` (only recently made possible).
  - Run each example explicitly

  Thanks to dunxen for noticing all the errors in my psbt example on review and prompting me to work out why clippy was not running :)

ACKs for top commit:
  apoelstra:
    ACK 74f3a5aeda
  Kixunil:
    ACK 74f3a5aeda

Tree-SHA512: 56dc6262144f4caa5efa6fdc46aeecf7bddc050ef134a639b31a34d4c5e01abcdeda18a00f4ded443866bbdfc982b4e5b67b0089639e0c253e207f0b54777f57
2022-07-26 14:04:36 +00:00
Tobin C. Harding b7eea6cb26 Update docs on rustfmt
We have introduced `rustfmt` but forgot to update the docs section about
it. Since a large portion of the codebase is currently ignored by our
`rustfmt` configuration, point out that `rusntfmt` is work in progress.
2022-07-26 17:20:00 +10:00
Tobin C. Harding fe840f0b42 Fix stale toolchain docs
We have docs that use an env var `BITCOIN_MSRV` that no longer exists.
Point readers towards `RUSTUP_TOOLCHAIN`.

(Note that we still use `TOOLCHAIN` in the script but it is being phased
out, `RUSTUP_TOOLCHAIN` works today.)
2022-07-26 11:09:47 +10:00
Tobin C. Harding 73b506e149 Remove stale MSRV docs
We have stale docs referring to the old MSRV. We do not need MSRV docs
in `CONTRIBUTING` because we have them in the README already.

Fix stale docs by doing:
- Remove the MSRV docs from readme in favour of `CONTRIBUTING.md`.
- Add a sentence to the redame pointing readers towards `CONTRIBUTING.md`.
2022-07-26 11:04:45 +10:00
Tobin C. Harding 74f3a5aeda Run clippy from the test script
Currently we run clippy in CI using a github action. The invocation has
a couple of shortcomings

1. it does not lint the tests (this requires `--all-targets`)
2. it does not lint the examples

I could not find a way to lint the examples without explicitly linting
each example by name.

Move the clippy control to `test.sh` and add an env var `DO_LINT` to
control it. Remove the explicit CI job and run the linter during the
`Test` job using the stable toolchain.
2022-07-26 08:48:15 +10:00
Tobin C. Harding aa8109a791 Use struct field short form
Clippy emits two warnings of form:

  warning: redundant field names in struct initialization

Remove the redundant field names and use struct short initialization
form.
2022-07-26 08:48:09 +10:00
Tobin C. Harding d1a05401f4 Remove redundant calls to clone
Clippy emits various warnings of form:

  warning: redundant clone

As suggested, remove the redundant calls to `clone`.
2022-07-26 08:47:53 +10:00
Tobin C. Harding 196492554d Use assert instead of assert_eq
Clippy emits:

  warning: used `assert_eq!` with a literal bool

As suggested, use `assert` instead of `assert_eq`.
2022-07-26 08:47:45 +10:00
Tobin C. Harding 3173ef9dbb Remove unnecessary explicit reference
Clippy emits various warnings of type:

  warning: this expression creates a reference which is immediately
  dereferenced by the compiler

As suggested, remove the unnecessary explicit reference.
2022-07-26 08:46:59 +10:00
Andrew Poelstra 5b707069e5
Merge rust-bitcoin/rust-bitcoin#1088: Add BIP152 (Compact Blocks) structures
ee29910911 BIP152: Test net msg ser/der and diff encoding (0xb10c)
cd1aaaf344 BIP152: Add Compact Block unit test based on Elements (Steven Roose)
d4d92a838e BIP152: Add Compact Blocks network messages (Steven Roose)
f2fcdc86e6 BIP152: Add basic Compact Block structures (Steven Roose)
a9a39c4b08 blockdata: Derive PartialOrd, Ord and Hash for BlockHeader (Steven Roose)

Pull request description:

  > Adds the basic structures for BIP152 and a method to create a compact block from a full block.

  This is a rebase of #249 by stevenroose (see https://github.com/rust-bitcoin/rust-bitcoin/pull/249#issuecomment-1170562141) with a milestone for 29.0. I've added deserialization and serialization tests for the network messages and fixed an off-by-one bug in the deserialization of the differentially encoded varints in the `getblocktxn` message (see https://github.com/rust-bitcoin/rust-bitcoin/pull/249#discussion_r914989521).

  Closes #249.

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

Tree-SHA512: 462a91576281f5a2ffdc2610769ea93970b60dac75a150c827966c48daec7cf93f526f9f202e7ba1dbb1410b49148579880260a3c3df298b98330c0d891a4cca
2022-07-25 17:35:09 +00:00
Andrew Poelstra cf8c5819c2
Merge rust-bitcoin/rust-bitcoin#1120: Use `u16::to_be_bytes`
3c2869465b Use to_be_bytes (Tobin C. Harding)

Pull request description:

  Now that MSRV is > 1.32 we can use `u16::to_be_bytes` to ensure network byte order when encoding the port number of a `AddrV2Message`.

  Remove the TODO and use `to_be_bytes` as suggested.

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

Tree-SHA512: b5dd9b0f43257f84defb9e9ecf9d02469f1959669367c5ad02cfb43003b780cf07ea344579b52a75c424fd85f8fa02dee3713b967c9b3a33eec6b7aa914763cd
2022-07-25 15:26:10 +00:00
Andrew Poelstra 7953764d78
Merge rust-bitcoin/rust-bitcoin#1122: Add docs re Rust 1.51.1
7f498ee2a2 Add docs re Rust 1.51.1 (Tobin C. Harding)

Pull request description:

  After auditing the code base for 'msrv' the only remaining mention (excl. md files) is on `unsigned_abs`.

  Add docs to save the next guy looking up what version of Rust introduced `unsigned_abs`. (I also added an item to the [msrv tracking issue](https://github.com/rust-bitcoin/rust-bitcoin/issues/1060).)

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

Tree-SHA512: 9b4bdca09d3f7ac1c0584f4eb5207983a064cfe81ed26952d00396b2e0019ef40eee192b7f09d36c68b8c4e1f8de9cac2d1f3ee0946626bae089b46fe38704ab
2022-07-25 13:41:33 +00:00
Tobin C. Harding 3c2869465b Use to_be_bytes
Now that MSRV is > 1.32 we can use `u16::to_be_bytes` to ensure network
byte order when encoding the port number of a `AddrV2Message`.

Remove the TODO and use `to_be_bytes` as suggested.
2022-07-25 13:40:04 +10:00
Andrew Poelstra 9f0ff6f0a4
Merge rust-bitcoin/rust-bitcoin#1121: Use `u8::try_from`
517059e148 Use u8::try_from (Tobin C. Harding)

Pull request description:

  Currently we use a cast to get the `u8` depth, as suggested by the TODO in the code we can now use `TryFrom` since we bumped the MSRV.

  Use `u8::try_from.expect("")` since depth (node count) is guarded by `TAPROOT_CONTROL_MAX_NODE_COUNT`.

ACKs for top commit:
  Kixunil:
    ACK 517059e148
  apoelstra:
    ACK 517059e148

Tree-SHA512: 98e58617247a05025ec13ad3d00a464cb2351c98c6d871be43b252d3982e291b7187e25780e7fe367f5a3a64fa20f3b328876a8901af4da09e675f50727a26cf
2022-07-24 22:30:02 +00:00
0xb10c ee29910911
BIP152: Test net msg ser/der and diff encoding
This adds tests for serialization of BIP152 network messages and
tests specifically for the differential encoding of the transaction
indicies of 'getblocktx'. Previously, this code contained an
off-by-one error.
2022-07-24 13:21:14 +02:00
Steven Roose cd1aaaf344
BIP152: Add Compact Block unit test based on Elements 2022-07-24 13:21:12 +02:00
Steven Roose d4d92a838e
BIP152: Add Compact Blocks network messages 2022-07-24 13:21:11 +02:00
Steven Roose f2fcdc86e6
BIP152: Add basic Compact Block structures 2022-07-24 13:21:08 +02:00
Steven Roose a9a39c4b08
blockdata: Derive PartialOrd, Ord and Hash for BlockHeader 2022-07-24 10:32:53 +02:00
Tobin C. Harding 517059e148 Use u8::try_from
Currently we use a cast to get the `u8` depth, as suggested by the TODO
in the code we can now use `TryFrom` since we bumped the MSRV.

Use `u8::try_from.expect("")` since, assuming the code comment is
correct, the depth is guaranteed to be less that 127.
2022-07-24 06:41:30 +10:00
Tobin C. Harding 7f498ee2a2 Add docs re Rust 1.51.1 2022-07-24 05:53:41 +10:00
Andrew Poelstra c7b8d4cae8
Merge rust-bitcoin/rust-bitcoin#1114: Add ci check for duplicate dependencies
cda097dda8 Add ci check for duplicate dependencies (Tobin C. Harding)

Pull request description:

  Add a call to `cargo tree --duplicates` in the ci script to ensure that we do not have any duplicated dependencies.

  Kudos to Kixunil  for the idea (over in: https://github.com/rust-bitcoin/rust-bitcoin/pull/1104)

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

Tree-SHA512: 77f07dd5c6794b5a59293bd62bda0fe61384a30cf8258e79aca9ce32090f869f0a13929b6a7a4c35e10fc653968b12ddd4c291df9ecd0962632017f59c81d025
2022-07-22 20:45:11 +00:00
Andrew Poelstra 0469838648
Merge rust-bitcoin/rust-bitcoin#1119: Use `listener.accept()`
b1faf63e82 Use listener.accept() (Tobin C. Harding)

Pull request description:

  During test network simulation we only accept a single connection, we can simplify the code by using `accept`.

  Done as a follow up to review suggestion:

  https://github.com/rust-bitcoin/rust-bitcoin/pull/1042#discussion_r898013799

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

Tree-SHA512: b2ead15d3108db3e01d9faab5e3521403dad6a0f4c3cf505f88fefd020110c520a89b9406484c10b04c9a34073c8abc465941577b17b5a193b54502c23b14c61
2022-07-22 20:35:41 +00:00
Tobin C. Harding b1faf63e82 Use listener.accept()
During test network simulation we only accept a single connection, we
can simplify the code by using `accept`.

Done as a follow up to review suggestion:

https://github.com/rust-bitcoin/rust-bitcoin/pull/1042#discussion_r898013799
2022-07-22 13:29:05 +10:00
Tobin C. Harding cda097dda8 Add ci check for duplicate dependencies
Add a call to `cargo tree --duplicates` in the ci script to ensure that
we do not have any duplicated dependencies.

Kudos to Martin for the idea.
2022-07-22 09:25:21 +10:00
Andrew Poelstra f6e2d959cc
Merge rust-bitcoin/rust-bitcoin#1118: Use infallible conversions: `Hash` -> `secp256k1::Message`
aeede12604 Infallible conversions: `Hash` -> `Message` (Arturo Marquez)

Pull request description:

  Replaces all instances of `secp256k1::Message::from_slice(_).expect(_)` with `secp256k1::Message::from(_)`. This also implements `ThirtyTwoByteHash` for `TapSighashHash`.

  Closes https://github.com/rust-bitcoin/rust-bitcoin/issues/824

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

Tree-SHA512: cd392f0e93e2560680c579a889a46f7e4484380058b2d8d03b6ecec351d880efa9beea5e3be128158e9e26243b7dfcef1f48a448028d9155958a5af62bcc9ec2
2022-07-21 22:37:39 +00:00
Arturo Marquez aeede12604
Infallible conversions: `Hash` -> `Message`
Replace all instances of
`secp256k1::Message::from_slice(_).expect(_)` with
`secp256k1::Message::from(_)`.

Also adds an implementation of ThirtyTwoByteHash for
TapSighashHash.

Solves https://github.com/rust-bitcoin/rust-bitcoin/issues/824
2022-07-21 11:26:53 -05:00
Andrew Poelstra 2256d4634c
Merge rust-bitcoin/rust-bitcoin#1041: Remove extern crates
21a1cc791c Use pub(crate) for macros instead of macro_use (Tobin C. Harding)
23ee0930c7 Remove extern crate (Tobin C. Harding)
da8b1b5439 Remove unused extern crate test (Tobin C. Harding)
01a8cc6848 Remove extern crate bitcoin_hashes (Tobin C. Harding)

Pull request description:

  Do some clean up of `extern crate` statements now we have edition 2018.

  4 separate but very similar patches, separated to ease review.

ACKs for top commit:
  sanket1729:
    utACK 21a1cc791c
  apoelstra:
    ACK 21a1cc791c

Tree-SHA512: fba33ed8fd261cc756dad8dd94f186a5b38aaf20cf31c3a83ad7633e7bb60a390681c39ebfd913e9e242fffed3b502491d067250d72ebfe666b4d03e93c8b945
2022-07-20 17:31:01 +00:00
Andrew Poelstra 148b56a370
Merge rust-bitcoin/rust-bitcoin#1110: Upgrade to secp v0.24.0
df73576515 Upgrade to secp v0.24.0 (Tobin C. Harding)

Pull request description:

  We just released a new version of `rust-secp256k1`, lets use it.

  This also fixes a bug where we upgraded our `bitcoin_hashes` dependency
  before secp had done theirs.

ACKs for top commit:
  sanket1729:
    utACK df73576515
  apoelstra:
    ACK df73576515

Tree-SHA512: 614eb096203753a6581e444aa11d41c7060342afd7ad103f6118c64bccf604850819ec2852730d1ac83fdea193770fe7600ea70c082a19afaef7ad3e8016d0e4
2022-07-20 17:18:08 +00:00
Andrew Poelstra e8b58fbcb1
Merge rust-bitcoin/rust-bitcoin#1107: Run the formatter
c1d74a3eae Run the formatter (Tobin C. Harding)

Pull request description:

  We recently merged a PR that enables the formatter on the `examples/` directory, at the same time we merged `examples/ecdsa-psbt.rs` but it had formatting issues under the new formatter config.

  Run `cargo +nightly fmt` to format the `examples/` directory.

ACKs for top commit:
  sanket1729:
    utACK c1d74a3eae
  apoelstra:
    ACK c1d74a3eae

Tree-SHA512: 645bf01c7cbb21e2eec23e6fa9c2f5d26e03566059d906e1985af5a9c0186470ef8a0c295f7be0a5226e2f948e2a94aa336de4b3704a31fd8715764f1625737d
2022-07-20 16:23:50 +00:00
Tobin C. Harding df73576515 Upgrade to secp v0.24.0
We just released a new version of `rust-secp256k1`, lets use it.

This also fixes a bug where we upgraded our `bitcoin_hashes` dependency
before secp had done theirs.
2022-07-20 15:44:19 +10:00
Tobin C. Harding c1d74a3eae Run the formatter
We recently merged a PR that enables the formatter on the `examples/`
directory, at the same time we merged `examples/ecdsa-psbt.rs` but CI
had already run so the formatter was not run.

Run `cargo +nightly fmt` to format the `examples/` directory.
2022-07-20 11:32:54 +10:00
Tobin C. Harding 21a1cc791c Use pub(crate) for macros instead of macro_use
For internal macros used only in this crate we do not need to use
`macro_use` and pollute the top level namespace now that we have edition
2018. We can add a `pub(crate) use` statement to each and then path
imports work for the macros like normal types.
2022-07-20 11:25:54 +10:00
Tobin C. Harding 23ee0930c7 Remove extern crate
Now we have edition 2018 we do not need to use `macro_use` or `extern
crate`; `pub use` works with macros. Notable exceptions are `alloc` and
`test`. Also leave the serde rename because touching it opens a can of
worms.
2022-07-20 11:25:54 +10:00
Tobin C. Harding da8b1b5439 Remove unused extern crate test
Recently we removed the "unstable" feature, I missed the duplicate
`extern crate test` when doing so :(

Since we no longer have the "unstable" feature this line of code is
never compiled in.

Remove the unused ``extern crate test`, we have the correct line further
up the file `#[cfg(bench)] extern crate test;`.
2022-07-20 11:24:33 +10:00
Tobin C. Harding 01a8cc6848 Remove extern crate bitcoin_hashes
Now we have edition 2018 we do not need to use `macro_use` or `extern
crate`; `pub use` works with macros.

Remove the extern crate statement and replace it with a pub use
statement. Requires fixing up various imports statements and also
requires importing `sha256t_hash_newtype` macro directly instead of
using a qualified path to it.
2022-07-20 11:23:59 +10:00
sanket1729 e2b038bf3d
Merge rust-bitcoin/rust-bitcoin#1098: Add cargo crev reminder to readme
ded1a32a59 Add cargo crev reminder to readme (Tobin C. Harding)

Pull request description:

  As suggested by the `cargo-crev` project; add a comment to the readme reminding people to use `cargo-crev` to check their dependencies.

  ### Notes

  Today I explored `cargo-crev`, it was new to me before today. I completed proofs for `bech32`, `rust-bitcoinconsenus`, `bitcoin_hashes`, `rust-secp256k1`, and `rust-bitcoin`. I published the proofs to https://github.com/tcharding/crev-proofs.

  If I'm understanding correctly proofs are only useful if the author is connected to a web of trust. So far I only found @dpc within the active rust-bitcoin devs with a `crev-proofs` repo (that includes an ID). Since he wrote `cargo-crev` its not surprising he has one :) Two other devs have `crev-proofs` repos but they are both incomplete (no ID) so I was unable to climb onto their web, so to speak. I am not a particularly well know dev so I imagine it would be more useful if some of you more well know fellas publish proofs as well.

  If we can get a web of trust between all the regular hackers here then we can start doing reviews/proofs of our dependencies and publishing them.

ACKs for top commit:
  Kixunil:
    ACK ded1a32a59
  apoelstra:
    ACK ded1a32a59
  sanket1729:
    ACK ded1a32a59

Tree-SHA512: c2d3b195a522095fcabcf51bb956b339f3a421541652f646f8e56286ebf850aa106d4acbf4defd344b5b0f57dd9626d1dbafe50c9d54b1436fd9e2c8b434fc07
2022-07-19 14:47:04 -07:00
sanket1729 e5acc07789
Merge rust-bitcoin/rust-bitcoin#1040: Introduce rustfmt in a non-invasive manner
ee9a3ec6a1 Enable formatter for "src" (Tobin C. Harding)
743b197124 Add use for Unexpected (Tobin C. Harding)
fd217e72c3 Use f instead of formatter (Tobin C. Harding)
7b50a96ade Do not format prelude module (Tobin C. Harding)
01471f7e65 Shield hash_newtypes from rustfmt (Tobin C. Harding)
65d19d9044 Refactor compile_error message (Tobin C. Harding)
6461e2db8d Run formatter on examples/ (Tobin C. Harding)
fd1c6589ba Add a rustfmt configuration file with explicit ignores (Tobin C. Harding)

Pull request description:

  Looks like we are getting to a place that rustfmt _might_ be able to be used. In an effort to introduce `rustfmt` without requiring devs to do excessively mundane reviews introduce `rustfmt` in a non-invasive manner. What this means is

  - Add a fully fleshed out `rustfmt` config file that explicitly ignores all the source files
  - Enable sections of code one by one so review is easier (including preparatory patches before doing each section).

  This PR currently does `examples` and all the source files at the root level of the crate (i.e. excludes all directories in `src/`). The other directories can then be done one at a time.

  Please see discussion on: https://github.com/rust-bitcoin/rust-bitcoin/pull/959 for more context.

ACKs for top commit:
  sanket1729:
    ACK ee9a3ec6a1
  apoelstra:
    ACK ee9a3ec6a1

Tree-SHA512: f4ff3c031b5d685777e09bac2df59ed8217576b807da7699f44fe00aa509d0b7fe47617a8b3eff00d3125aeece3e010b8f9dd8733d315ccb2adc0e9a7d7f07e3
2022-07-19 13:38:28 -07:00
sanket1729 d6d5415ae4
Merge rust-bitcoin/rust-bitcoin#940: Add psbt watch-only/cold-storage example
cd2369b4f9 Run ecdsa-psbt example in test script (Tobin C. Harding)
6967c0ed6f Add psbt example (Tobin Harding)

Pull request description:

  Add an example PSBT workflow. The workflow we simulate is that of a setup using a watch-only online wallet (contains only public keys) and a cold-storage wallet (contains the private keys).

  We create and update a PSBT using the watch-only wallet then pass the PSBT to the cold-storage wallet to sign.

  Partially resolves #892 (more done in #935).

  ## Note

  This PR includes a sub-module in `examples/psbt.rs` that implements ECDSA signing. This will hopefully eventually be merged into the main crate by way of https://github.com/rust-bitcoin/rust-bitcoin/pull/957.  We have three PRs that add examples/tests of PSBTs that need to do signing, in order to help us design a good AP in #957 I think it would be beneficial to complete and merge these three PRs.

  1. This PR (PSBT ECDSA example)
  2. PBST ECDSA integration test: https://github.com/rust-bitcoin/rust-bitcoin/pull/935
  3. PSBT taproot example: https://github.com/rust-bitcoin/rust-bitcoin/pull/999

  Note to self, this will need a change to `test.sh` if #1079 merges.

ACKs for top commit:
  apoelstra:
    ACK cd2369b4f9
  sanket1729:
    ACK cd2369b4f9. The example is clean, you can address the comments in followups.

Tree-SHA512: c4fb8ec631bf8bfc30534e8974b1f6c4bb7cc6def165a4ee2bb7aa73f5aa7fdc11d2000ca25792a4b534b2c5bf1592efe542ada14a9d702c7dfacbaa808f3aea
2022-07-19 11:50:15 -07:00
Tobin C. Harding ee9a3ec6a1 Enable formatter for "src"
Remove the ignore for the "src" directory, this enables the formatter
for all source files in the `src/` directory.
2022-07-19 13:43:12 +10:00
Tobin C. Harding 743b197124 Add use for Unexpected
In preparation for running the formatter on `src/` and a function local
use statement for `$crate::serde:🇩🇪:Unexpected`, this shortens the
line of code that uses this type preventing the formatter for later
munging that line.
2022-07-19 13:43:12 +10:00
Tobin C. Harding fd217e72c3 Use f instead of formatter
The local variable `formatter` can be shortened to `f` with no loss of
clarity since it is so common.

Done in preparation for running `rustfmt` on `src`.
2022-07-19 13:43:12 +10:00
Tobin C. Harding 7b50a96ade Do not format prelude module
In preparation for running the formatter on all source files at the root
of the crate; skip formatting `prelude` module because we use
unconventional import statements so they to save writing a million
compiler attributes.
2022-07-19 13:43:12 +10:00
Tobin C. Harding 01471f7e65 Shield hash_newtypes from rustfmt
In preparation for running the formatter on root level modules and a
submodule that holds all the macro calls in `hash_types` so we can
configure rustfmt to skip formatting them.
2022-07-19 13:43:12 +10:00
Tobin C. Harding 65d19d9044 Refactor compile_error message
In preparation for enabling rustfmt on `lib.rs` refactor the
`compile_error` call so that the formatter does not touch it.
2022-07-19 13:43:12 +10:00