Commit Graph

2718 Commits

Author SHA1 Message Date
Tobin C. Harding bef7992ce5
Update readme to mention pin for 1.47
We now require pinning for `serde` and `syn` if building with toolchain
1.47. Document this in the README.
2023-03-19 12:19:40 +11:00
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
Andrew Poelstra 51251557ad
Merge rust-bitcoin/rust-bitcoin#1711: Add README docs for proper use of std and no-std features
33ee7a58af Add README build docs for std and no-std (Steve Myers)

Pull request description:

  Building this crate requires the `std` and/or `no-std` features be enabled. This PR documents this build constraint in the README ~~and gives an error is anyone tries to build without enabling one or both of these features~~.

  See discussion in rust-bitcoin/rust-miniscript#533.

ACKs for top commit:
  tcharding:
    ACK 33ee7a58af
  Kixunil:
    ACK 33ee7a58af
  apoelstra:
    ACK 33ee7a58af

Tree-SHA512: 4c0f46681ee09a1d63d269c84ec69bd12944129c94a62f62f78694ae428566f3dfee9a36ac2742e02502b184c4ec0d6aec60a0c0760df3d75587700cb8a76ad2
2023-03-17 15:02:33 +00:00
Andrew Poelstra e658d34934
Merge rust-bitcoin/rust-bitcoin#1705: Avoid usage of atomic types if not supported by the target arch
2961c0c589 Exclude usage of atomic types if not supported for the target (Salvatore Ingala)

Pull request description:

  Hi! I'm still a beginner with both Rust and cross-compilation, so please take the rest with a few grains of salt!

  I'm setting up a project targeting `riscv32i-unknown-none-elf`, which seems not to support atomic types. Even with `--no-default-features` and `no-std`, I would get this error:

  ```
  error[E0432]: unresolved import `alloc::sync`
    --> rust-bitcoin/bitcoin/src/blockdata/script/mod.rs:52:12
     |
  52 | use alloc::sync::Arc;
     |            ^^^^ could not find `sync` in `alloc`

  error[E0432]: unresolved import `alloc::sync`
     --> rust-bitcoin/bitcoin/src/lib.rs:163:114
      |
  163 |     pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, Cow, ToOwned}, slice, rc, sync};
      |                                                                                                                  ^^^^ no `sync` in the root
      |
      = help: consider importing one of these items instead:
              bitcoin_hashes::_export::_core::sync
              core::sync
  ```

  This PR gates the usage of `Arc` so that it's only enabled with the `std` feature.

ACKs for top commit:
  apoelstra:
    ACK 2961c0c589
  Kixunil:
    ACK 2961c0c589

Tree-SHA512: c864fb8363fca6a020472b3bdfe488bc2f33d52df98d88f0bc90ebdaa2e9f58b91cc6578eb4fc36f434ff1c50ff9c222a752bd3a72f6b9351244ad5827061e8f
2023-03-17 14:14:34 +00:00
Steve Myers 33ee7a58af
Add README build docs for std and no-std 2023-03-16 19:01:02 -05: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
Andrew Poelstra 2982681d59
Merge rust-bitcoin/rust-bitcoin#1709: Improve QR code formatting documentation
a6188a90c0 Improve QR code formatting documentation (Martin Habovstiak)

Pull request description:

  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.

  BTW why do we prefix upper case `BITCOIN` only in case of bech32? Proper BIP21 should support it for all addresses. (And yest, it still does save space.)

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

Tree-SHA512: b62b17664f12d4ce05296131cde9f307311b8114c457970f8e3f1beb4d6fd397981045c61c44e1da573623842b74b73d088f757f9ff063eb783ab69145102cd7
2023-03-16 03:01:49 +00: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 c1612fa105
Merge rust-bitcoin/rust-bitcoin#1708: Fix CI builds where default features are added accidentally
9dd4c54a74 Fix CI builds where default features are added accidentally (Steven Roose)

Pull request description:

ACKs for top commit:
  Kixunil:
    ACK 9dd4c54a74
  tcharding:
    ACK 9dd4c54a74
  apoelstra:
    ACK 9dd4c54a74

Tree-SHA512: 7c63b33c2cc7aa988194150e6fb3dacec894f7aeccb90992a9255fcde2312793f4e2556b00d600241e481399445c0434009dd06207783ee592acd5d96452063f
2023-03-13 16:09:00 +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
Andrew Poelstra fa2f27ca03
Merge rust-bitcoin/rust-bitcoin#1704: Add tests to Weight type
f0a3aad5b8 Add tests to Weight type (yancy)

Pull request description:

  Add tests for Weight type

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

Tree-SHA512: 12875cd774762743c53b55f1c56494cd4c3995fc481dd5653810efb363627dfa770bd1e147dacd452a6a61d3906910dc974c979a4a3c41655f8a32a4b4a14ef4
2023-03-10 16:46:28 +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 10d61f1c97
Merge rust-bitcoin/rust-bitcoin#1701: Fix weight subtract bug
b311e96603 Fix weight subtract bug (yancy)

Pull request description:

  Fix subtraction bug

ACKs for top commit:
  apoelstra:
    ACK b311e96603
  tcharding:
    ACK b311e96603
  sanket1729:
    utACK b311e96603

Tree-SHA512: 517b18432f88b501b17e8d8c9e11f6cfde76fc2c8cd7aba0afda79a4eea4a662154f4e09bb303386bcc93582921160b59642969514b6d9dce6cab62263b66b62
2023-03-09 00:45:52 +00: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 be02045561
update internals CHANGELOG for release 2023-03-08 02:39:15 +00: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
Andrew Poelstra e074ee4316
Merge rust-bitcoin/rust-bitcoin#1111: Run cargo fmt in CI
2d6467f980 Add cargo fmt to pre-commit githook (Tobin C. Harding)
55312f2972 Update contributing docs re cargo fmt (Tobin C. Harding)
c1360067e9 Enable formatting in CI (Tobin C. Harding)
61c560baba Improve the DO_BENCH error message (Tobin C. Harding)
a11cf07501 Run the formatter (Tobin C. Harding)
21d716b313 Use new fn_params_layout option (Tobin C. Harding)

Pull request description:

  Run the formatter in CI so we stop continually introducing formatting problems in the code that is currently supposed to be formatted.

ACKs for top commit:
  apoelstra:
    ACK 2d6467f980
  sanket1729:
    ACK 2d6467f980

Tree-SHA512: 0dbe12bb853b0ec6102066118a9272462bf9ebf2dc53b1394c294185b9d4a824ba0cca478f500fcc44088e4bc54a61153402a6911f285435b68bc9a306f9f11f
2023-03-07 13:25:39 +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 2d6467f980
Add cargo fmt to pre-commit githook
To save devs getting frustrated by CI; add a call to `cargo +nightly
fmt` to our git pre-commit hook.
2023-03-07 08:58:13 +11:00
Tobin C. Harding 55312f2972
Update contributing docs re cargo fmt
Now that we use `cargo fmt`, update the section in the contributing
documentation.
2023-03-07 08:58:13 +11: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
Tobin C. Harding 21d716b313
Use new fn_params_layout option
The `fn_args_layout` rustfmt option was recently changed to
`fn_params_layout`, use the new name.
2023-03-06 10:21:29 +11:00
Andrew Poelstra 4a2f11cc49
fix clippy lint 2023-03-05 17:19:03 +00:00
Andrew Poelstra bfd401c96e
bitcoin_hashes: add CHANgELOG 2023-03-05 13:53:45 +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