Commit Graph

6202 Commits

Author SHA1 Message Date
Bruno Garcia 08e0d4f0e5 fuzz: cover minimal_non_dust_custom for Script 2025-03-04 11:13:55 -03:00
Bruno Garcia 66fee1ef87 fuzz: add consume_u64 2025-03-04 11:13:51 -03:00
Jamil Lambert, PhD 2dad19a20f
Bump GitHub Actions Artifacts to v4
v3 is deprecated and causes an automatic fail of fuzz workflow.

Bump the version of `actions/upload-artifact` and
`actions/download-artifact` to v4.
2025-03-04 11:37:58 +00:00
Martin Habovstiak d1d483491f Make `hex` in `internals` optional
The `hex` crate is not always desirable - e.g. when the consumer wants
to work with raw data only. We already had this optional in `hashes` but
if `hashes` is going to depend on `internals` it would break this
property.

This change makes `hash` optional, since it's easy: there's just one
struct that depends on it.
2025-03-04 12:33:04 +01:00
Tobin C. Harding 852bcf6017
bitcoin: Remove hash type re-exports
The `{W}PubkeyHash` and `{W}ScriptHash` types are not likely to be used
directly by consumers of the library because we have other function that
return them and are more ergonomic to use. There is therefor no good
reason to re-export them from the crate root.
2025-03-04 08:15:04 +11:00
Jamil Lambert, PhD 8007840676
Add a test for remainder
A remainder operation has been implemented for `Weight`.

Test the functionality of remainder with both a `Weight` and `u64`
2025-03-03 20:47:01 +00:00
Jamil Lambert, PhD 4787aa1f89
Implement Rem for Weight
`Weight` implements `Div` but not `Rem`

Add `Rem` impl for `Weight`
2025-03-03 20:43:21 +00:00
merge-script 6483244280
Merge rust-bitcoin/rust-bitcoin#4170: Improve crate docs headings
83d071e54b chacha20: Add whitespace (Tobin C. Harding)
4451724d31 chacha20: Add a docs heading (Tobin C. Harding)
d4417f9666 io: Improve crate docs heading (Tobin C. Harding)
c466554948 hashes: Improve crate docs heading (Tobin C. Harding)
6f4eb60936 Improve docs crate headings (Tobin C. Harding)

Pull request description:

  Make them all uniform after taking 2 minutes online to try find a nice format.

ACKs for top commit:
  apoelstra:
    ACK 83d071e54be0bc4ebd760a490a3ca887c0bf90a8; successfully ran local tests; lgtm

Tree-SHA512: 6f08c6cda91a7a870f1080b497f89607ac3d6b3c0234cbd2ba2da8710d46816398acac0bca2a49a3bc9466b814ae446842d3d304a3735df9f983e3ff5df005db
2025-03-03 20:05:29 +00:00
merge-script 5bc08b1d9a
Merge rust-bitcoin/rust-bitcoin#4154: update secp256k1 to 0.30.0
f80cf2cb2a update secp256k1 to 0.30.0 (19年梦醒)

Pull request description:

ACKs for top commit:
  apoelstra:
    ACK f80cf2cb2aa318978da3a6c5df49d82c49344763; successfully ran local tests
  tcharding:
    ACK f80cf2cb2a

Tree-SHA512: 83b8bb72372025c4a4b81c2b7973a7808a4a1d9d6450adef8b60a890e128b2559b55832159c25fa91daac1856049b070cd910d87313fed2851ced9e72ae5ddf5
2025-03-03 19:04:09 +00:00
merge-script 43814eb9e5
Merge rust-bitcoin/rust-bitcoin#4134: chore: fix some typos in comments
ce19d40a80 chore: fix some typos in comments (looklose)

Pull request description:

  fix some typos in comments

ACKs for top commit:
  apoelstra:
    ACK ce19d40a805e2b67f6199cce61a73c6592019b5c; successfully ran local tests
  tcharding:
    ACK ce19d40a80

Tree-SHA512: 4bf5d339e4e73a6f1378881ad62b17f78796e6000f24eea6b3a381d3e03f4fd8b9775710a7eb5a087bfe0d557d1ab1a8291dcc7b86a2c9ded3318774cf2e5b68
2025-03-03 17:33:28 +00:00
Jamil Lambert, PhD fe685b824f
Fix the release script that checks for TBD
`release.sh` is missing `units`.

Add `units` to the list of crates to check.
Reorder the crates alphabetically.
2025-03-03 17:25:34 +00:00
Bruno Garcia 35e7027a08 fuzz: move consume_random_bytes to a util file 2025-03-03 13:47:52 -03:00
merge-script f0e12574aa
Merge rust-bitcoin/rust-bitcoin#4175: Use uniform return statement in docs
85612908af Use uniform return statement in docs (Tobin C. Harding)

Pull request description:

  We have a bunch of 'Returns [`None`] if .. ' statements. Make the whole module uniform.

ACKs for top commit:
  apoelstra:
    ACK 85612908af936c7f0866227e24a3359115991ca2; successfully ran local tests; lgtm

Tree-SHA512: 431b6ced433578c13bfc6134609d11084380310a2fbb66899387ac6982a6c4d63559faf9be460104e120c109cbd352b240886d4aa6b6d92cd5063d7b4ec5e04c
2025-03-03 16:35:41 +00:00
Bruno Garcia eb8ecd5e3c fuzz: cover minimal_non_dust for Script 2025-03-03 12:24:15 -03:00
merge-script b6548931b5
Merge rust-bitcoin/rust-bitcoin#4142: Typo fix in: README.md
539d45420a Typo fix in: README.md (leonarddt05)

Pull request description:

  Hi,

  I suggest some typo fix' for this doc:

  1- "since these are needed to display hashes anway."  Should be "since these are needed to display hashes anyway." (spelling error).

  2- "bench mark" and "bench marks" Should be "benchmark" and "benchmarks" (incorrect spacing; "benchmark" is a single word).

  Thanks.

ACKs for top commit:
  apoelstra:
    ACK 539d45420a4540e13099a61996db87aeb3887002; successfully ran local tests
  tcharding:
    ACK 539d45420a

Tree-SHA512: 36fe65a9ea4d8d2fce90fb91e7966bc41ab5ab1cf9b5ea39efe88b1756d46724428d5dccfb1e7718721747e032ee3c52d848908652d82816f7f990f527c47485
2025-03-03 15:22:33 +00:00
Bruno Garcia cab8a6134f fuzz: cover count_sigops{_legacy} for Script 2025-03-03 12:06:55 -03:00
Jamil Lambert, PhD b656d7a16c
Inline small functions
Functions that just delegate or do trivial operations should be inline.

Add `#[inline]` to all functions in `primitives` that fit the criteria.
2025-03-03 12:26:52 +00:00
Tobin C. Harding a4b9c196b1
Manually update nightly version
While trying to use the `macro_use_imports` lint I found that there is a
bug in last weeks nightly. It has been fixed already so lets update.

Update to todays nightly compiler. Doing so causes some new linter
warnings, for now we just allow them.
2025-03-03 15:05:55 +11:00
Tobin C. Harding 85612908af
Use uniform return statement in docs
We have a bunch of 'Returns [`None`] if .. ' statements. Make the whole
module uniform.
2025-03-03 14:06:01 +11:00
Tobin C. Harding 2434afc40d
Make Weigth::from_kwu const
The other two `Weight` constructors are const already.
2025-03-03 13:46:42 +11:00
Tobin C. Harding 1fe984552e
Improve Weight rustdocs
Do trivial improvement to rustdocs for the `Weight` type.
2025-03-03 13:44:14 +11:00
Tobin C. Harding 83d071e54b
chacha20: Add whitespace
Mirror the other crates. Whitespace only.
2025-03-03 13:33:19 +11:00
Tobin C. Harding 4451724d31
chacha20: Add a docs heading
Like we do for the other crates add a heading to the crate docs.
2025-03-03 13:33:11 +11:00
Tobin C. Harding d4417f9666
io: Improve crate docs heading
Use the same format as the other crates.
2025-03-03 13:30:52 +11:00
Tobin C. Harding c466554948
hashes: Improve crate docs heading
Use same for as the other crates and emphasise that this is a Bitcoin
hashes crate.
2025-03-03 13:30:40 +11:00
Tobin C. Harding 6f4eb60936
Improve docs crate headings
I took a look at the rendered HMTL of `bitcoin`, `primitives`, `units`,
`serde`, and `tokio` and picked a header style that I thought looked
good.

Use it for `primitives` and `units`.
2025-03-03 13:28:01 +11:00
Tobin C. Harding 3ae21d5111
Use impl_add/sub_assign for block interval
We have a macro for implementing `AddAssign` and `SubAssign`.

Use the macro, gets us an additional ref impl for both.
2025-03-03 13:16:10 +11:00
Tobin C. Harding 9d55922952
Use impl_op_for_references for block height/interval
We have a new macro for implementing ops with a bunch of reference
combos. Lets use it for block `Height` and `Interval`.

This patch is strictly additive.
2025-03-03 13:11:19 +11:00
Tobin C. Harding f5e17914b6
Move Assign impls together
Next patch will move all the impls of `Add` and `Sub` into a macro call.
In order to make that patch smaller move the assign impls to be together
below the add/sub impls.

Code move only, no logic change.
2025-03-03 13:09:10 +11:00
Tobin C. Harding cc66838e80
units: Remove unnecessary code comments
These comments to not add much value - remove them.
2025-03-03 13:05:35 +11:00
Tobin C. Harding a74393324b
Move opcodes back to bitcoin
Duplicate `opcodes` in `bitcoin` and hide it in `primitives` so we do
not have to commit to the API.

We use opcodes in `impl fmt::Display for Script`.

Close: #4144
2025-03-03 11:51:28 +11:00
Tobin C. Harding fb29aadc47
Remove bip158 types from crate root
BIP-158 (Compact Block Filters for Light Clients) is not so common as to
require re-exorting its types at the crate root - remove them.
2025-03-03 11:24:37 +11:00
merge-script 72823df014
Merge rust-bitcoin/rust-bitcoin#4152: Automated daily update to rustc (to nightly-2025-02-28)
c810a0ad58 Automated update to Github CI to rustc nightly-2025-02-28 (Update Nightly Rustc Bot)

Pull request description:

  Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

ACKs for top commit:
  tcharding:
    ACK c810a0ad58

Tree-SHA512: 446fc7f0a5d190c5ff874900d2b29b4051d91928948fa10bdcf5ba8db52ccd8ff51228f9832290836067f6ebf66f66517afffede14489e9c0f2313eed51bd523
2025-03-03 11:12:22 +11:00
Tobin C. Harding 5da506b506
Add additional re-exports
As we do for other types add two new alias' at the crate root of
`primitives` and mirror it in `bitcoin`:

- `BlockVersion`
- `TransactionVersion`
2025-03-03 08:25:58 +11:00
Tobin C. Harding 0a9f14f7b0
Implement Div by amount for amount types
It is semantically valid to divide an amount by another amount. The
result of the operation is an integer.

Note that we cannot implement `Div` by `NumOpResult` because there is no
way to show the div by invalid case.

Implement `Div` by amount for both amount types.
2025-03-03 08:12:41 +11:00
Tobin C. Harding b57bfb9bc5
Add missing Mul impls for amount types
Add and test missing `Mul` impls for both amount types.
2025-03-03 08:12:41 +11:00
Tobin C. Harding 501c9ab89e
Test amount ops that involve an integer
From the amount types `Div`, `Mul`, and `Rem` can have an integer on one
side. Test them - includes commented out test for one missing combo.
2025-03-03 08:12:41 +11:00
Tobin C. Harding 851080d3b1
Add more add/sub tests
Add units tests for various values including negative values.
2025-03-03 08:12:40 +11:00
Tobin C. Harding 47923957b1
Improve add/sub tests for amount types
Add a few macros to test `Add` and `Sub` impls for both amount types,
all combos of type and res (eg `Amount` and `NumOpResult<Amount>`), and
all combos of references.
2025-03-03 07:26:00 +11:00
Tobin C. Harding 8bb9ce3e47
Add tests for amount op int
We aim to support three ops on amount types that use an integer for the
right hand size. Prove that implement them.
2025-03-03 05:20:38 +11:00
merge-script 58baee62ca
Merge rust-bitcoin/rust-bitcoin#4155: Automated nightly rustfmt (2025-03-02)
166e37161a 2025-03-02 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 166e37161a2412c716e82f7046da304d4788a3c9; successfully ran local tests

Tree-SHA512: 630978ca16f514379e0851254f2b7137f2612e98d8614e9d2c1170bda805ece5936371a2b1fb4b846f3ec906c5c72c9dc1bf9a4239cc6c3336e8f456108a826f
2025-03-02 17:27:48 +00:00
merge-script 22cecce99d
Merge rust-bitcoin/rust-bitcoin#4149: Fix typos in code comments and documentation
bb8f833ca0 Update instruction.rs (kilavvy)
0ce622e668 Update message.rs (kilavvy)
f61941bbe6 Update serialized_signature.rs (kilavvy)
1d2de62e01 Update mod.rs (kilavvy)

Pull request description:

  This PR fixes several typos in comments across multiple files:

  - Fixed typo `interpretted` -> `interpreted` in `blockdata/script/instruction.rs`
  - Fixed typo `neccessity` -> `necessity` in `p2p/message.rs`
  - Fixed typo `underlflow` -> `underflow` in `taproot/serialized_signature.rs`
  - Fixed typo `ambigous` -> `ambiguous"` in `units/src/amount/mod.rs`

  These changes only affect comments and documentation, no functional code changes.

ACKs for top commit:
  apoelstra:
    ACK bb8f833ca01688eaae75e0fa322f698d34243185; successfully ran local tests; though all these commits could be squashed IMO

Tree-SHA512: d73dc2a86b20de87c0c5efb3e5042e3901c846236670e3a6501f4c93fd54328fef08bfeca276b93642e7b51d04cb8b9c8e1af558f3aabc3c924d60a61e58b031
2025-03-02 15:42:57 +00:00
19年梦醒 f80cf2cb2a
update secp256k1 to 0.30.0 2025-03-02 23:31:48 +08:00
Fmt Bot 166e37161a 2025-03-02 automated rustfmt nightly 2025-03-02 01:22:29 +00:00
merge-script c2741c8eee
Merge rust-bitcoin/rust-bitcoin#4138: units: Improve code comment on macros
8787304425 units: Improve code comment on macros (Tobin C. Harding)

Pull request description:

  We have two macros that are hidden because they are code de-duplication tools. However the output they produce is, and has to be, stable so that we can use them in `units` and `primitives` without inadvertently breaking semver in `primitives`.

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

Tree-SHA512: 564bb27dcb608f391be8e50cbf2da02d2f339ddf575e5b5fd432a93df96233b50541616167c7c84a134ed31455a64149c822aea72e61c042fb1aeb8fab20d4ce
2025-03-01 19:46:31 +00:00
merge-script 217099a7b7
Merge rust-bitcoin/rust-bitcoin#4123: hashes: Remove Clone trait bound from Tag
25707da14a hashes: Remove Clone trait bound from Tag (ndungudedan)

Pull request description:

  Resolves #4016 which was suggested here: https://github.com/rust-bitcoin/rust-bitcoin/pull/4010#discussion_r1942359979

ACKs for top commit:
  Kixunil:
    ACK 25707da14a
  tcharding:
    ACK 25707da14a

Tree-SHA512: 1f1a5da4e3f40ba9ee0cd9e5dfa3924bfbb46e1f44e1d857e295bf768dff3407196211041e2a1d06c582d1dac6d7adb5c5aa0285300337504655ee72f2d0b9ec
2025-03-01 18:52:51 +00:00
merge-script ef9a24eadf
Merge rust-bitcoin/rust-bitcoin#4091: primitives: Hide error internals
43ae9d7516 primitives: Hide script error internals (Tobin C. Harding)
2d8227f091 Hide relative locktime error internals (Tobin C. Harding)

Pull request description:

  Make the struct fields private and add getters.

ACKs for top commit:
  apoelstra:
    ACK 43ae9d751622c7bef548a469466d74cf01284129; successfully ran local tests; nice! Way easier to understand these types with the new incompatible / expected names

Tree-SHA512: cfe67d60ea61a2a4c27b09071a6b11739ca281bf0b4a655121f90215ce38c3a637acf53a6e01aa2ef26fa80004cd919bf3b3334dbd9566ee2f594cab7750b563
2025-03-01 04:44:01 +00:00
merge-script ea56619df5
Merge rust-bitcoin/rust-bitcoin#4114: Policy: Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65
2fe3687899 Policy: Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65 (jrakibi)

Pull request description:

  Align with Bitcoin Core's policy by reducing the minimum non-witness transaction size from 82 to 65 bytes.
  This will allow for more minimal transaction cases (eg: 1 input with 1 OP_RETURN output) while maintaining protection against CVE-2017-12842.

  The 65-byte minimum consists of:
  - 60 bytes: minimal tx (10B skeleton + 41B input + 9B output)
  ```
  # Tx Skeleton: 4 [Version] + 1 [InCount] + 1 [OutCount] + 4 [LockTime] = 10 bytes
  # Blank Input: 32 [PrevTxHash] + 4 [Index] + 1 [scriptSigLen] + 4 [SeqNo] = 41 bytes
  # Output:      8 [Amount] + 1 [scriptPubKeyLen] = 9 bytes
  ```

  - 5 bytes: minimum `scriptPubKey`

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

ACKs for top commit:
  tcharding:
    ACK 2fe3687899
  Kixunil:
    ACK 2fe3687899

Tree-SHA512: d98fae7ebde5060c7ad8a3555df094e8ed93486c371b1bd43302bbd1b6b2d86c442803dcbcc5b30f3692224a888abc4e49b7b5414d9852317730628a139fbd40
2025-03-01 03:35:47 +00:00
Update Nightly Rustc Bot c810a0ad58 Automated update to Github CI to rustc nightly-2025-02-28 2025-03-01 01:50:11 +00:00
merge-script 65181257bc
Merge rust-bitcoin/rust-bitcoin#4111: Add support for pay to anchor outputs
f7ea6e50b5 Add support for pay to anchor outputs (Erik De Smedt)

Pull request description:

  Add support for the newly created Pay2Anchor output-type which was introduced in bitcoin 28.0

  See https://github.com/bitcoin/bitcoin/pull/30352

ACKs for top commit:
  Kixunil:
    ACK f7ea6e50b5
  apoelstra:
    ACK f7ea6e50b578238b0a7ff421d18d7c7f71d43278; successfully ran local tests

Tree-SHA512: cd3da860e81bd25e6fef72a9118b43d647af2339e9d226c124fa221f63d9c3149189480d40368d38900a999bf59a23fd5302025751ea1bebfea059b4fab21c0b
2025-02-28 20:40:25 +00:00