Commit Graph

144 Commits

Author SHA1 Message Date
Tobin C. Harding 3af3239ad0
script: Re-order functions
We want our code to be easy to read and our APIs discoverable, for those
of us who read source files the layout matters.

Put the constructors and getters at the top of the impl block.

Code move only, no logic changes.
2024-11-01 07:09:59 +11:00
Tobin C. Harding db40297f87
script: deprecate to_bytes
Deprecate the `Script::to_bytes` function in favour of `to_vec` as we
are doing elsewhere.

Note that `ScriptBuf` has `into_bytes` because it does not copy.
Potentially this should be deprecated in favour of `into_vec`?

Note that in regards to the `to_` prefix this naming as valid according
to convention because the `Script` type is borrowed and `to_vec` copies
the underlying bytes.
2024-11-01 07:09:53 +11:00
Tobin C. Harding c5cd0db493
Revert the change to to_bytes
During this release cycle we deprecated `to_vec` in favour of
`to_bytes`, we have since reversed our position on the name.

Remove the deprecation of `to_bytes` from the three types that had it
and use `to_vec`.
2024-11-01 07:09:11 +11:00
Tobin C. Harding 0bf1910980
Remove wildcard from script self re-exports
In the `script` module remove the wildcards and re-export stuff from
`self` explicitly in both `primitives` and `bitcoin`.

Internal change only, everything is re-exported.
2024-10-31 15:52:54 +11:00
Leo Nash 7f289a9fdf Bump hex-conservative to 0.3.0 2024-10-31 03:36:22 +00:00
Tobin C. Harding bafe11d7e4
Correctly feature gate impl_to_hex_from_lower_hex
Currently we feature gate code within the `impl_to_hex_from_lower_hex`
 macro on "alloc" but `bitcoin` does not have the "alloc" feature so
 this code is never built in. This can be seen by the lack of a
 `to_hex` function on `LeafVersion`.

Remove the feature gate from the macro and put it on the individual
call sites as needed.
2024-10-31 13:43:47 +11:00
Tobin C. Harding 57769f5f28
Fix ugly rustfmt
Fix some ugly formatting introduced by the fmt bot recently.

Whitespace only, no logic changes.
2024-10-31 13:38:27 +11:00
Tobin C. Harding f8f846bb9e
Move Transaction type to primitives
Needs no explanation - lets go!
2024-10-30 12:28:53 +11:00
Tobin C. Harding e84346644e
Run the formatter
Run `just fmt` - no other changes.
2024-10-30 11:30:24 +11:00
merge-script 1f578fc929
Merge rust-bitcoin/rust-bitcoin#3518: Automated nightly rustfmt (2024-10-27)
39f46a16bc 2024-10-27 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK 39f46a16bc
  apoelstra:
    ACK 39f46a16bc0da356f495166ccd5829627af3749b; successfully ran local tests

Tree-SHA512: 6c27714b18ad6957104246145a2d4243f8e43e378d63f3d946ba05ecaf859432f2fe363fe3e7a29a33c41297216fd1176c165ac55deb109f636813c637ff6c43
2024-10-28 21:34:59 +00:00
merge-script 6c54a1d2f2
Merge rust-bitcoin/rust-bitcoin#3497: Explicitly re-export stuff from crates down the stack
66da2266e2 Explicitly re-export stuff from crates down the stack (Tobin C. Harding)

Pull request description:

  Up until recently we were using wildcard re-exports for types moved to `units` and `primitives`. We have decided against doing so in favour of explicit re-exports.

  Audit `units` and `primitives` using `git grep 'pub enum'` (and `struct`) and explicitly re-export all types.

  Remove all wildcards except for the re-exports from `opcodes`, there are too many opcodes, explicitly re-exporting them does not aid clarity.

ACKs for top commit:
  apoelstra:
    ACK 66da2266e26dfe53947c4606e9d18620931e93cf; successfully ran local tests

Tree-SHA512: 74717f8b127e975e3d131aab884bdfe78e699d88b7ee1db7731ad117437d37684285264001cf6b2182eb1e565171167695e00c4b6aef28a3e26b69d9cebfbb74
2024-10-28 19:20:23 +00:00
Tobin C. Harding 3e2c43b19e
Elide more lifetimes
clippy found some more lifetimes to elide.
2024-10-28 15:22:13 +11:00
Fmt Bot 39f46a16bc 2024-10-27 automated rustfmt nightly 2024-10-27 01:21:24 +00:00
Tobin C. Harding 66da2266e2
Explicitly re-export stuff from crates down the stack
Up until recently we were using wildcard re-exports for types moved to
`units` and `primitives`. We have decided against doing so in favour of
explicit re-exports.

Audit `units` and `primitives` using `git grep 'pub enum'` (and
`struct`) and explicitly re-export all types.

Remove all wildcards except for the re-exports from `opcodes`, there are
too many opcodes, explicitly re-exporting them does not aid clarity.
2024-10-27 06:45:58 +11:00
Tobin C. Harding 003dc9cf4d
Move TxOut to primitives
The `TxOut` has all public fields; move the `TxOut` to `primitives`.
2024-10-24 09:04:12 +11:00
Tobin C. Harding 4d37d7efc6
Move TxIn to primitives
The `TxIn` has all public fields; move the `TxIn` to `primitives`.
2024-10-24 09:04:12 +11:00
Tobin C. Harding 1b521dce99
Move taproot hash types to primitives
Move the three `taproot` hash types and their associated tags over to
the `primitives` crate.
2024-10-22 13:50:44 +11:00
merge-script 7e5911923f
Merge rust-bitcoin/rust-bitcoin#3284: Add a few unit tests for Sequence
4a8e2c3704 Add tests for sequence (Shing Him Ng)

Pull request description:

  Add a few unit tests for Sequence

ACKs for top commit:
  apoelstra:
    ACK 4a8e2c3704 successfully ran local tests; sure
  tcharding:
    ACK 4a8e2c3704

Tree-SHA512: fb793a6a94a9d3f1522357f98a73a87618ba70776875b3ce051631970ca6c15998401dece47e426f7040770b8d24ee1b72f206d3164b7ca76492e12e86116677
2024-10-21 23:58:55 +00:00
Fmt Bot 2a08b29232 2024-10-20 automated rustfmt nightly 2024-10-20 01:21:52 +00:00
merge-script 51d503730d
Merge rust-bitcoin/rust-bitcoin#3406: Move `Witness` to `primitives`
c1eccfde25 Move Witness to primitives (Tobin C. Harding)
6ce76cd7c8 Add unstable constructor to Witness (Tobin C. Harding)

Pull request description:

  Patch 1 introduces a new policy to the codebase, we use `foo__unstable` for public unstable functions and there are zero semver guarantees if you call these functions.

  Patch 2 does the move.

  Close #3406

ACKs for top commit:
  apoelstra:
    ACK c1eccfde25fd4c2b19e7ec6759352b46ac246113; successfully ran local tests

Tree-SHA512: 2388066be2b6bb2cf3d6757c8f6334beeda6115ef1ce7c537955d32aa5e466add5162d0d2adee27f416fe622fc93c4e94bd848326463ee55e08d1c0f4e03719c
2024-10-18 16:35:15 +00:00
Tobin C. Harding c1eccfde25
Move Witness to primitives
Move the `Witness` over to `primitives` leaving behind any method that
takes or returns a `Script` or a signature.

Includes addition of a feature gate to unit test.
2024-10-18 14:02:03 +11:00
merge-script 7af9e33f2b
Merge rust-bitcoin/rust-bitcoin#3468: Move `block::Header` to `primitives`
ff64fa3c46 Move block::Header to primitives (Tobin C. Harding)
65925117a0 Manually implement block::Header::block_hash (Tobin C. Harding)
b02ab25342 Add regression test for block_hash function (Tobin C. Harding)
5614694b69 block: Remove wildcard re-export (Tobin C. Harding)

Pull request description:

  - Patch 1: Trivial preparation.
  - Patch 2 and 3: Reduce the API surface in a disappointing way due to the orphan rule.
  - Patch 4: Do the move.

ACKs for top commit:
  apoelstra:
    ACK ff64fa3c46 successfully ran local tests; nice!

Tree-SHA512: 8d93de4a12c9f71f9dfbdc023fd8defb78f7d3da995490af8f83a927c2ca6338dd236bc08691311dc7345183fb6d0be61eedce3e4424d4060be2de934facd60a
2024-10-17 13:12:06 +00:00
Jamil Lambert, PhD 88b53a471e
Unify deprecated note field format
All the deprecated note fields have been changed to be lower case and in
the format "use `a` instead".
2024-10-15 15:16:01 +01:00
Shing Him Ng 4a8e2c3704 Add tests for sequence 2024-10-14 22:41:23 -05:00
Tobin C. Harding ff64fa3c46
Move block::Header to primitives
Introduce an extension trait and move the `block::Header` type to
`primitives`.

Nothing surprising here.
2024-10-15 11:04:00 +11:00
Tobin C. Harding e68da281ff
Warn on future deprecations
We use `TBD` in our `deprecated` string and it was discovered that there
is an exception on this string so as not to warn because it is used
internally by the Rust language. However there is a special lint to
enable warnings, lets use it.

Add `#![warn(deprecated_in_future)]` to the coding conventions section
of all crates except `fuzz`.
2024-10-15 07:56:06 +11:00
Shing Him Ng 0e0192c025 Add tests for block version 2024-10-13 22:07:31 -05:00
merge-script 1b23d1c66c
Merge rust-bitcoin/rust-bitcoin#3431: Move script types to `primitives`
d649c06238 Move script types to primitives (Tobin C. Harding)
ec4635904b Inline bytes_to_asm_fmt into Script::Display impl (Tobin C. Harding)

Pull request description:

  First patch removes `bytes_to_asm_fmt` as requested by Kix here: https://github.com/rust-bitcoin/rust-bitcoin/pull/3194#discussion_r1756557768

  Second patch does the move. The move is minimal but there is quite a bit of code moved in `script/mod.rs` - I believe it is as minimal as required as well.

ACKs for top commit:
  apoelstra:
    ACK d649c06238 successfully ran local tests

Tree-SHA512: 329a23948ac5617402a724b734d81cde8ab1f57ddd4860f858880618e260ea8b5cc89315de1fd93ae32787d5e8508fd604a41f003b1f5772a773b5b1648d382c
2024-10-14 00:31:38 +00:00
Tobin C. Harding d649c06238
Move script types to primitives
Move the `Script` and `ScriptBuf` types to `primitives`, nothing else.
2024-10-14 09:02:39 +11:00
merge-script cc5b46bfc7
Merge rust-bitcoin/rust-bitcoin#3462: Automated nightly rustfmt (2024-10-13)
f1733309e0 2024-10-13 automated rustfmt nightly (Fmt Bot)

Pull request description:

  Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  apoelstra:
    ACK f1733309e0 successfully ran local tests

Tree-SHA512: 465336b92d9b8a61afbc8e8d0560f3b41a732e3245d764447cc2a5429f693e29172bebeca756a91b5a1f3a16d42728960a526111bbd92316f72b46b420373641
2024-10-13 16:40:17 +00:00
merge-script 4717f4d1af
Merge rust-bitcoin/rust-bitcoin#3459: feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF
3565f70df9 feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF (ChrisCho-H)

Pull request description:

  follow up https://github.com/rust-bitcoin/rust-bitcoin/pull/3455.
  Replace all `ENABLE_RBF_NO_LOCKTIME`(deprecated) with `ENABLE_LOCKTIME_AND_RBF`

ACKs for top commit:
  apoelstra:
    ACK 3565f70df9 successfully ran local tests
  tcharding:
    ACK 3565f70df9

Tree-SHA512: 4c6c6ad9ac89efe042cf239ce68594e715dbc827c1ae430819e2f16d2191f82d81f1e55b348f8176fc21454cf9d25fc9da1a414982cd3483d5f9f39834441f6c
2024-10-13 14:09:42 +00:00
Fmt Bot f1733309e0 2024-10-13 automated rustfmt nightly 2024-10-13 01:20:28 +00:00
merge-script 65e290a0ce
Merge rust-bitcoin/rust-bitcoin#3450: Add version three variant to transaction version
9e6b8faf84 feat: add version three variant to transaction version (Rob N)

Pull request description:

  Topologically restricted transactions are now considered standard as of Bitcoin 28.0.

ACKs for top commit:
  apoelstra:
    ACK 9e6b8faf84 successfully ran local tests
  tcharding:
    ACK 9e6b8faf84

Tree-SHA512: 289b986304e206802f04cee6607087167f6d91d8a81d4fc49ed01c430f4f6ad00b44646fbefdd000148fc5bfe2d257f92b386bfaf4405c482e4e438d830ab586
2024-10-12 17:55:21 +00:00
merge-script ae2358610d
Merge rust-bitcoin/rust-bitcoin#3457: Fix unused import
a250c8eee4 Fix unused imports (Shing Him Ng)

Pull request description:

  Found some unused imports while working on something unrelated

ACKs for top commit:
  apoelstra:
    ACK a250c8eee4 successfully ran local tests
  tcharding:
    ACK a250c8eee4

Tree-SHA512: ffa4fcddb91c849df7885a6d734405ab704e0353293fa3462a981e179ea49091990df4482eee2324e7b5ef250a0890b2e8983d53ec288ca6e8ada77e30c102dc
2024-10-12 14:56:48 +00:00
Andrew Poelstra 76f022d380 Merge rust-bitcoin/rust-bitcoin#3438: Implement Arbitrary for Block
0c824c9c68 Implement Arbitrary for Block (Shing Him Ng)

Pull request description:

  Implementing `Arbitrary` for `Block` and its child types

ACKs for top commit:
  apoelstra:
    ACK 0c824c9c68 successfully ran local tests
  tcharding:
    ACK 0c824c9c68

Tree-SHA512: 407acd4155ca7496bf7c59af19f103b22b4c74dd013c2e2c42aae690ba7264ecd42ed034355cf8895f2532f8cef77dfdbeac250301a6973afd5f3920be7e4310
2024-10-12 14:15:28 +00:00
ChrisCho-H 3565f70df9 feat: replace ENABLE_RBF_NO_LOCKTIME with ENABLE_LOCKTIME_AND_RBF 2024-10-12 12:42:43 +09:00
Rob N 9e6b8faf84
feat: add version three variant to transaction version 2024-10-11 06:38:58 -10:00
merge-script 0f887707ea
Merge rust-bitcoin/rust-bitcoin#3455: Use new Sequence::ENABLE_RBF_AND_LOCKTIME
5e0a07e74f Use new Sequence::ENABLE_RBF_AND_LOCKTIME (Tobin C. Harding)

Pull request description:

  We just renamed this and forgot to use the new name. This should have been caught by CI.

ACKs for top commit:
  apoelstra:
    ACK 5e0a07e74f successfully ran local tests

Tree-SHA512: 0830184f3afa7b42d53460444637d16bace98438fac14a53e3c6f2fdb5b801847f3864d104be2e5311131b2db432e7ef8dd20ad833420ea05303fc93bd4dc68c
2024-10-11 14:59:57 +00:00
merge-script 03715872cd
Merge rust-bitcoin/rust-bitcoin#3432: fmt: Use style_edition = 2021
323e706113 Add rustfmt config option style_edition (Tobin C. Harding)
2e4179ed0f Run the formatter (Tobin C. Harding)
2c40b4f4ec Configure formmater to skip read_compact_size (Tobin C. Harding)

Pull request description:

  `rustfmt` is emitting:

   Warning: the `version` option is deprecated. Use `style_edition` instead.

  As suggested add a config option and set it to 2021.

  - Patch 1: Manually configure rustfmt to skip some code
  - Patch 2: Run the formmater with current configuration
  - Patch 3: Add the new config option (remove old one), introduces no new formatting requirements

ACKs for top commit:
  apoelstra:
    ACK 323e706113 successfully ran local tests

Tree-SHA512: 7f80cc89f86d2d50936e51704344955fa00532424c29c0ee3fae1a6836e24030f909b770d28da13e1c5efde3d49ad7d52c6d909d120fb09c33abf1755f62cd38
2024-10-11 12:48:50 +00:00
Shing Him Ng a250c8eee4 Fix unused imports 2024-10-10 23:42:51 -05:00
Shing Him Ng 0c824c9c68 Implement Arbitrary for Block 2024-10-10 23:30:39 -05:00
Tobin C. Harding 5e0a07e74f
Use new Sequence::ENABLE_RBF_AND_LOCKTIME
We just renamed this and forgot to use the new name. This should have
been caught by CI.
2024-10-11 11:46:34 +11:00
merge-script fe62d94ff7
Merge rust-bitcoin/rust-bitcoin#3296: Remove the `SliceIndex` implementation from hash types
3b7ba4f977 Remove the SliceIndex implementation from hash types (Tobin C. Harding)

Pull request description:

  If folk really want to index into a hash they can us `as_byte_array` then index that.

  Includes a bump to the version number of `hashes` to `v0.15.0` - this is because otherwise `secp` won't build since we are breaking an API that is used in the current release of secp.

  Fix: #3115

ACKs for top commit:
  apoelstra:
    ACK 3b7ba4f977 successfully ran local tests

Tree-SHA512: 0ba93268cd8133fe683183c5e39ab8b3bf25c15bfa5767d2934d67a5f6a0d2f65f6c9304952315fe8a33abfce488d810a8d28400a28facfb658879ed06acca63
2024-10-10 22:39:21 +00:00
merge-script d5ebb19543
Merge rust-bitcoin/rust-bitcoin#3437: Move `block::Version` to primitives
70264bfcec Move block::Version to primitives (Tobin C. Harding)
819d8d72e8 Stop using private Version constructor (Tobin C. Harding)

Pull request description:

  This is a straight up move of the whole type because there are only three methods, a getter, a setter, and `is_signalling_soft_fork`.

  If we use an extension trait for `is_signalling_soft_fork` then we have to make the two private associated consts public which is in my opinion worse.

  Patch 1 is preparation, use getter/setter, patch 2 does the move.

ACKs for top commit:
  apoelstra:
    ACK 70264bfcec successfully ran local tests

Tree-SHA512: b61e853b4b96cb1cc56c7bfb67cc6c3ba7c631cb9e540393eb780dcf63bd2d934058794f2ac0145b4b5404a6a68887c3a1d225b2d87b57415474c05d3ef2811f
2024-10-10 21:28:44 +00:00
Tobin C. Harding 2e4179ed0f
Run the formatter
Run `just fmt`, no other manual changes.
2024-10-10 10:39:53 +11:00
merge-script 0a83e5336d
Merge rust-bitcoin/rust-bitcoin#3439: sequence: clarify sequence constant name and add FINAL
4499b5c95b feat: rename ENABLE_RBF_NO_LOCKTIME to ENABLE_LOCKTIME_AND_RBF (ChrisCho-H)
861d97de36 feat: add FINAL constant to disable all (ChrisCho-H)

Pull request description:

  c24630e7b13312ea34f0f54ed832783ced8dde3f
  - `LOCKTIME` is used for both absolute and relative one without clear classification, which is confusing and could lead to an unexpected bug. Although it's API breaking change, current constant is so ambiguous unless understand the details of `LOCKTIME` semantic.

  9cc5dfeef178f03ea4d0786cfbaa3b8709fed644
  - Add constant `ENABLE_ALL` and `DISABLE_ALL`, which is useful for those who want to enable(disable) rbf, absolute/relative locktime.

ACKs for top commit:
  tcharding:
    ACK 4499b5c95b
  apoelstra:
    ACK 4499b5c95b successfully ran local tests

Tree-SHA512: dbea5ae911556d53025078e7193f0972d5e8ba354f69692091b2b05cc441e270f25eafa55b144a6970de42d8f596a2b0103cdee463c3126d5d9986cee88ce8fc
2024-10-08 02:46:11 +00:00
ChrisCho-H 4499b5c95b feat: rename ENABLE_RBF_NO_LOCKTIME to ENABLE_LOCKTIME_AND_RBF 2024-10-05 18:39:26 +09:00
ChrisCho-H 861d97de36 feat: add FINAL constant to disable all 2024-10-03 22:51:49 +09:00
Tobin C. Harding 3b7ba4f977
Remove the SliceIndex implementation from hash types
If folk really want to index into a hash they can us `as_byte_array`
then index that.

Includes a bump to the version number of `hashes` to `v0.15.0` - this
is because otherwise `secp` won't build since we are breaking an API
that is used in the current release of secp.

Fix: #3115
2024-10-02 10:18:45 +10:00
Tobin C. Harding fed94f8899
Bump version of bitcoin-io to 0.2.0
In preparation for releasing `io v0.2.0` bump the version number,
add a changelog entry, update the lock files, and depend on the new
version in all crates that depend on `io`.
2024-10-02 09:47:10 +10:00
Tobin C. Harding 70264bfcec
Move block::Version to primitives
This is a straight up move of the whole type because there are only
three methods, a getter, a setter, and `is_signalling_soft_fork`.

If we use an extension trait for `is_signalling_soft_fork` then we
have to make the two private associated consts public which is in my
opinion worse.
2024-10-02 09:35:23 +10:00
merge-script e8a3c1f01b
Merge rust-bitcoin/rust-bitcoin#3117: Release tracking PR: `bitcoin-units 0.2.0`
07a529a132 Bump version of bitcoin-units to 0.2.0 (Tobin C. Harding)
148711a4c6 units: Use double ## in changelog entries (Tobin C. Harding)
80e600ba0c units: Copy 0.1.2 release notes (Tobin C. Harding)

Pull request description:

  In preparation for releasing `units v0.2.0` bump the version number, add a changelog entry, update the lock files, and depend on the new version in all crates that depend on `units`.

  Close: #3095

ACKs for top commit:
  apoelstra:
    ACK 07a529a132 successfully ran local tests

Tree-SHA512: 98a75d485ded6225551a5fc4b4a14d8efecc76911a720f959044cdd62781024a8787f258f171ed297705f5ab470f9a88a81ad5d255c9e03c1e22857615ad2e6d
2024-10-01 22:51:05 +00:00
merge-script 12e4671810
Merge rust-bitcoin/rust-bitcoin#3388: Move `OutPoint` to `primitives`
da0795e590 primitives: Use doc links for OutPoint (Tobin C. Harding)
b079cbafee Move OutPoint to primitives (Tobin C. Harding)
f5c46cd411 Introduce OutPoint extension traits (Tobin C. Harding)
7e5bd5048d Remove docs on deprecated is_null function (Tobin C. Harding)
97b20a2316 Add additional impl block to OutPoint (Tobin C. Harding)

Pull request description:

  Just the minimal move of `OutPoint` to `primitives`.

  The last patch closes #3347

ACKs for top commit:
  apoelstra:
    ACK da0795e590 successfully ran local tests

Tree-SHA512: dced5a6d6bc6af0ce8b4ae4e52c04b45c85eb77a24bb25762ba8ab7deeab1e6b392cc4b258bb14218e8a2af999715dfed45ba94599cb16963a843995a7475917
2024-09-30 21:32:14 +00:00
merge-script 0b5e0bac31
Merge rust-bitcoin/rust-bitcoin#3401: Move the `block` hash types over to `primitives`
2d8c613340 Move the block hash types to primitives (Tobin C. Harding)
6b9429ac7b Remove BlockHash::all_zeros (Tobin C. Harding)
20d8dbd586 Add missing line of whitespace (Tobin C. Harding)

Pull request description:

  As an initial step in moving the `block` module, just move over the hash types `BlockHash` and `WitnessCommitment`.

  Patch 2 introduces an associated const `BlockHash::GENESIS_PREV_BLOCKHASH` and removes `all_zeros`.

ACKs for top commit:
  apoelstra:
    ACK 2d8c613340 successfully ran local tests

Tree-SHA512: 64aa0ae81e1c8ab1b5d4cd8cd28e6ef04ed01bf79175dc5b1fd607a6f0967e06b0aaf4c10ad368e2b327edcad3705187b6643d5ca8647716319424f19a838ba1
2024-09-30 19:40:15 +00:00
merge-script 08eaab2ecf
Merge rust-bitcoin/rust-bitcoin#3400: Move `merkle_tree` hash types to `primitives`
9ded58fc99 Move merkle_tree hash types to primitives (Tobin C. Harding)

Pull request description:

  In preparation for moving the `block::Header` struct over to `primitives` move the `merkle_tree` hash types.

ACKs for top commit:
  apoelstra:
    ACK 9ded58fc99 successfully ran local tests

Tree-SHA512: 98017cf0403871f01a6efeda22e8f319cc8104b9bc2f3a9bae2d6a31f6df8172307466c6486a9259204166933137fa03e565e08a0c156c278cfeb72cdae09b89
2024-09-30 18:29:56 +00:00
Fmt Bot a65d2a0ee4 2024-09-29 automated rustfmt nightly 2024-09-29 01:21:14 +00:00
yancy d39334e651 Refactor Arbitrary for Sequence 2024-09-27 11:26:33 -05:00
Tobin C. Harding da0795e590
primitives: Use doc links for OutPoint
Now that `OutPoint` is in `primitives` we can use a rustdoc link. While
we are at it link from the error type docs too.

Close: #3347
2024-09-27 12:43:13 +10:00
Tobin C. Harding b079cbafee
Move OutPoint to primitives
Move the `OutPoint` type and associated code over to `primitives`. Take
the opportunity to re-order the code so the file reads like a story,
things are implemented below where they are called.
2024-09-27 12:43:13 +10:00
Shing Him Ng 9d9872711f Refine Sequence and Version Arbitrary impls 2024-09-26 14:31:29 -05:00
Tobin C. Harding 07a529a132
Bump version of bitcoin-units to 0.2.0
In preparation for releasing `units v0.2.0` bump the version number,
add a changelog entry, update the lock files, and depend on the new
version in all crates that depend on `units`.
2024-09-25 10:58:31 +10:00
Tobin C. Harding 2d8c613340
Move the block hash types to primitives
Move the `BlockHash` and `WitnessCommitment` hash types over to
`primitives`.
2024-09-25 06:58:55 +10:00
Tobin C. Harding 9ded58fc99
Move merkle_tree hash types to primitives
In preparation for moving the `block::Header` struct over to
`primitives` move the `merkle_tree` hash types.
2024-09-25 06:56:24 +10:00
merge-script 6338f7c973
Merge rust-bitcoin/rust-bitcoin#3375: Release tracking PR: `bitcoin-internals 0.4.0`
18110a51f2 Bump version of internals to 0.4.0 (Tobin C. Harding)

Pull request description:

  In preparation for releasing `internals v0.4.0` bump the version number, add a changelog entry, update the lock files, and depend on the new version in all crates that depend on `internals`.

ACKs for top commit:
  apoelstra:
    ACK 18110a51f2 successfully ran local tests; lots of nice stuff here

Tree-SHA512: a4d3d5279b7d7fa993cbc3b7b34fc6dc4024dd54c0bfa1ecd0f0d5f09b984871f156c3695092a1f6c44b7571f8b2051699040f5f77636d44d4cae6c972ab597f
2024-09-23 18:32:23 +00:00
merge-script 387f94ce16
Merge rust-bitcoin/rust-bitcoin#3383: primitives: Move optional dependency to correct place
184dfbcdb6 primitives: Move optional dependency to correct place (Tobin C. Harding)

Pull request description:

  We keep optional deps in a separate group to non-optional deps, move the new `arbitrary` dependency.

  Internal change only.

ACKs for top commit:
  shinghim:
    ACK 184dfbcdb6
  apoelstra:
    ACK 184dfbcdb6 successfully ran local tests

Tree-SHA512: 8540ee9ce9663d60d1a8d08e94738c7a3e3341b640ec6cbc04c304cb12daa4c95ae6cd1e4ad9fde361065510b2e34c65f6f08db1ae305976fce4525aa98756a3
2024-09-23 17:37:31 +00:00
Fmt Bot 2009763ae5 2024-09-22 automated rustfmt nightly 2024-09-22 01:20:08 +00:00
merge-script 855c4bb754
Merge rust-bitcoin/rust-bitcoin#3364: Remove unused inports, and fix unused variables and methods in docs
f6abdcc001 Allow unused in `macros.rs` docs (Jamil Lambert, PhD)
fd89ddf401 Remove or fix unused variables and methods in docs (Jamil Lambert, PhD)
ff6b1d4f19 Remove unused variables and methods from docs (Jamil Lambert, PhD)
e58cda6f92 Remove `unused_imports` in docs (Jamil Lambert, PhD)

Pull request description:

  As mentioned in #3362 examples in documentation are not linted in the same way as other code, but should still contain correctly written code.

  #![doc(test(attr(warn(unused))))] has been added to all lib.rs files

  In the docs throughout all crates:

  - Unused imports have been removed.

  - Unused variables, structs and enums have been used e.g. with an `assert_eq!` or prefixed with `_`

  - Unused methods have been called in the example code.

ACKs for top commit:
  tcharding:
    ACK f6abdcc001
  apoelstra:
    ACK f6abdcc001 successfully ran local tests

Tree-SHA512: c3de1775ecde6971056e9fed2c9fa1621785787a6a6ccbf3a6dbd11e18d42d4956949f3f8adfc75d94fd25db998b04adb1c346cc2c2ba47f4dc37402e1388277
2024-09-20 02:10:51 +00:00
Tobin C. Harding 184dfbcdb6
primitives: Move optional dependency to correct place
We keep optional deps in a separate group to non-optional deps, move the
new `arbitrary` dependency.

Internal change only.
2024-09-19 08:36:20 +10:00
Jamil Lambert, PhD fd89ddf401
Remove or fix unused variables and methods in docs
Examples in documentation are not linted in the same way as other code,
but should still contain correctly written code.

Throughout all of the crates except internals (another commit) unused
variables have been prefixed with `_`, unused imports have been removed,
and a warn attribute added to all of the `lib.rs` files.
2024-09-18 16:37:47 +01:00
Tobin C. Harding 18110a51f2
Bump version of internals to 0.4.0
In preparation for releasing `internals v0.4.0` bump the version number,
add a changelog entry, update the lock files, and depend on the new
version in all crates that depend on `internals`.
2024-09-18 12:22:59 +10:00
Shing Him Ng 5b4e81b379 Implement Arbitrary for Transaction 2024-09-16 22:02:46 -05:00
merge-script 60e15b8007
Merge rust-bitcoin/rust-bitcoin#3194: priority: Prepare moving script types to `primitives`
8f2f4cbb3c Re-order optional dependencies (Tobin C. Harding)
95f2a8dab6 Do not access ScriptBuf inner from builder (Tobin C. Harding)
900af453ff Stop accessing inner ScriptBuf field when encoding (Tobin C. Harding)
8b82363d97 Use Script::as_bytes instead of inner when indexing (Tobin C. Harding)
b0675a4a4f Use Script::len instead of inner field (Tobin C. Harding)
374c6118dc Deprecate Script::fmt_asm and to_asm_str (Tobin C. Harding)

Pull request description:

  Move the `Script` and `ScriptBuf` types to `primitives`. There were still a few preparations required, things we had missed while creating the extension traits.

  Note also please, in the last patch, we enable `hex` from the `serder` feature. This is not the final state we want but like we did for `alloc` it is a step to reduce the size of the diff.

ACKs for top commit:
  Kixunil:
    ACK 8f2f4cbb3c
  apoelstra:
    ACK 8f2f4cbb3c successfully ran local tests

Tree-SHA512: 62a5f3c253ecb54d95c37fdc7eb955f3952909dc3bca20444b85c44665f54d5a0c48daf729bed0dd60ff3e9571b41deed039984c8b757b075ac6e136cacd17d7
2024-09-13 16:58:59 +00:00
Tobin C. Harding 0403e52ce3
Move the transaction hash types over to primitives
Move the `Txid` and `Wtxid` hash wrapper types over to `primitives`.
This introduces to `primitves` an unconditional dependency on
`hashes`.
2024-09-11 11:02:32 +10:00
Tobin C. Harding 8f2f4cbb3c
Re-order optional dependencies
The optional dependencies are ordered and separated by whitspace in a
manner that may not be obvious (or even have a reason).

Some of this is because since use of `?` deps changed name.

Put all the optional deps together in alphabetic order.
2024-09-11 10:50:18 +10:00
Fmt Bot 9a5ba9b6df 2024-09-08 automated rustfmt nightly 2024-09-08 01:17:12 +00:00
merge-script f6287fb445
Merge rust-bitcoin/rust-bitcoin#3287: Move `transaction::Version` to `primitives`
c48d9d6523 Move transaction::Version to primitives (Tobin C. Harding)
f490222068 Introduce the VersionExt trait (Tobin C. Harding)
fb89974b82 Run the formatter (Tobin C. Harding)
bb3a3ecbaa Introduce temporary module for Version (Tobin C. Harding)
1fde868f51 Separate Version impl blocks (Tobin C. Harding)

Pull request description:

  As per title, in tiny small chunks, move the `transaction::Version` over to `primitives`. Only the type, its associated consts, and its `Display` impl are moved. The two methods are left in an extension trait.

  Was originally attempted in #3253

ACKs for top commit:
  Kixunil:
    ACK c48d9d6523
  apoelstra:
    ACK c48d9d6523 successfully ran local tests

Tree-SHA512: 83415cf0762dca5c263deb743734fc7abede804a6daac31df3d0101b51c6261e6d54452eb744727ae680cacce9e4ef726a6fa253d86c4e7a5d8ec789b137566c
2024-09-04 01:21:43 +00:00
Tobin C. Harding c48d9d6523
Move transaction::Version to primitives
We would like to move the `Transaction` type to `primitives`, as a step
towards this move the `transaction::Version` and its trait imps (just
`Display`) over there.
2024-09-03 11:01:29 +10:00
Shing Him Ng 30bb93c676 Implement impl_to_hex_from_lower_hex macro for types that implement fmt::LowerHex 2024-08-31 22:41:40 -05:00
Tobin C. Harding e1e0230827
primitives: Enable alloc from serde
Currently the `serde` feature requires an allocator, this is a hang over
from code being written for the `bitcoin` crate.

This was not found because we are not testing `primitives` correctly in
CI (there is the `fuzz` bug and also `primitives` is not even in the
CRATES list).
2024-08-22 16:51:24 +00:00
Tobin C. Harding ce36a37d68
primitives: Test ordered feature
We forgot to add the `ordered` feature to `test_vars.sh`.
2024-08-22 16:51:24 +00:00
Fmt Bot ce3851d241 2024-08-18 automated rustfmt nightly 2024-08-18 01:12:19 +00:00
Tobin C. Harding 2ec901fd63
Move the CompactTarget type to primitives
Potentially the whole `pow` module will move to `primitives` but this
is not possible easily right now. However, we would like to be able to
move the `BlockHash` and `block::Header` types over to `primitives`
and doing so requires the `CompactTarget` to be there.

Move the `CompactTarget` type to `primitives` and re-export it from the
`primitives` crate root.

Note also, we re-export the type publicly from `bitcoin::pow`.
2024-08-13 05:29:22 +10:00
Tobin C. Harding 3d85ee3a02
primitives: Fix alloc feature
We have an `alloc` feature but we are unconditionally using
`extern crate alloc`, this is broken - clearly we need to add a `no-std`
build for `primitives` in CI.

Feature gate the `alloc` crate.

While we are at it just pull types in from `alloc` in the `prelude` - I
have no idea why we do not do this in `bitcoin`?
2024-08-13 05:23:10 +10:00
merge-script 15b87606bf
Merge rust-bitcoin/rust-bitcoin#3100: Bump MSRV to 1.63
c72069e921 Bump MSRV to 1.63 (Martin Habovstiak)

Pull request description:

  The version 1.63 satisfies our requirements for MSRV and provides significant benefits so this commit bumps it. This commit also starts using some advantages of the new MSRV, namely namespaced features, weak dependencies and the ability to use trait bounds in `const` context.

  This however does not yet migrade the `rand-std` feature because that requires a release of `secp256k1` with the same kind of change - bumping MSRV to 1.63 and removing `rand-std` in favor of weak dependency. (Accompanying PR to secp256k1: https://github.com/rust-bitcoin/rust-secp256k1/pull/709 )

  Suggested plan:

  * merge both PRs
  * at some point release `hashes` and `secp256k`
  * remove `rand-std` from `bitcoin`
  * release the rest of the crates

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

Tree-SHA512: 0b301ef8145f01967318d3ed1c738d33e6cf9e44f835f3762122b460a536f926916dbd6ea39d6f80b4f95402cd845e924401e75427dbb0731ca5b12b4fa6915e
2024-07-28 21:11:28 +00:00
Shing Him Ng 14fdffeb5a Fix typo in primitives Cargo.toml 2024-07-27 16:29:09 -05:00
Martin Habovstiak c72069e921 Bump MSRV to 1.63
The version 1.63 satisfies our requirements for MSRV and provides
significant benefits so this commit bumps it. This commit also starts
using some advantages of the new MSRV, namely namespaced features, weak
dependencies and the ability to use trait bounds in `const` context.

This however does not yet migrade the `rand-std` feature because that
requires a release of `secp256k1` with the same kind of change - bumping
MSRV to 1.63 and removing `rand-std` in favor of weak dependency.
2024-07-27 07:24:32 +02:00
Tobin C. Harding 991c73cdf9
primitives: Re-export everything from units
We recently decided to make everything in `units` available at the same
path as in `primitives` and not re-export the actual `units` crate.

Re-export everything from the `units` crate root at the `primitives`
crate root using a wildcard.
2024-07-23 02:04:11 -05:00
Tobin C. Harding 7a44908aee
primitives: Use wildard re-export in locktimes
We recently decided to use wildcard re-exports when re-exporting things
from an identically named module in a sub crate, ie. to mirror the
directory structure structure ala core/std.

In the `primitives::locktime` modules re-export everything from the
`units::locktime` modules using a wildcard.
2024-07-23 01:50:44 -05:00
Tobin C. Harding d1c876eda5
Remove rustfmt attribute
There are no other use statements so we do not need to keep the public
ones separate with a `rustfmt` attribute.

Remove the attribute and run the formatter.
2024-07-23 01:48:20 -05:00
Shing Him Ng 86f82b487d Remove unused variable from LockTime example 2024-07-15 17:03:12 -05:00
Tobin C. Harding 64c31cfb97
Move locktimes and Sequence to primitives
The `absolute` and `relative` locktimes as well as the `Sequence` are
all primitive bitcoin types.

Move the `Sequence`, and `locktime` stuff over to `primitives`.

There is nothing surprising here, the consensus encoding stuff stays in
`bitcoin` and we re-export everything from `blockdata`.
2024-07-15 08:53:51 +10:00
Tobin C. Harding dc96475f58
Add/fix alloc features
Eventually we would like all our crates other than `bitcoin` to be able
to be used without an allocator. Currently, and during crate smashing,
this is not that useful because so much of the code comes from `bitcoin`
and relies on the availability of an allocator.

As an initial step, add the `alloc` feature to `addresses` , `base58`,
and `primitives`.

In order to to keep `--no-default-features` builds working make the
crates empty if the `alloc` feature is not enabled. This is a suboptimal
solution because the error messages users will get when they forget to
enable `alloc` will be confusing (eg something like primitives does not
contain Transaction). However our CI script (`run_task.sh`) expects
`--no-default-features` to build cleanly (as do I).
2024-07-11 10:14:50 +10:00
Tobin C. Harding 9a586987d1
Move opcodes to primitives
Move the `opcodes` module to the new `primitives` crate. This is pretty
straight forward, some things to note:

- Are we ok with the public wildcard re-export from `blockdata`? I think
so because the whole `blockdata` module should, IMO, be deleted after
everything in it is moved to `primitives`.

- `decode_pushnum` becomes public.

Includes addition of a `patch` section for `primitives` in the
`bitcoin/embedded` crate.
2024-07-09 15:26:33 +10:00
Tobin C. Harding 65e9ad2fea
Introduce empty primitives crate
Introduce an empty `bitcoin-primitives` crate.

We were give the name on crates.io and previously a version
`v0.1.16-alpha` was released so we use `v0.100.0`.
2024-07-03 05:22:39 +10:00