Skip to content

Conversation

rustaceanrob
Copy link
Collaborator

We only bring in rand explicitly for the Rng trait, coming from RngCore. The Rng trait is a nightmare to implement, and we only use a single call to .fill. If we export a far simpler trait that represents filling a 32 byte slice, then users can have a far easier time implementing this trait. This has come up in the past with this project: alfred-hodler/pushtx#3

This also removes the need for rand as a dependency at all, and it may be brought in through bitcoin (or later secp256k1)

AFICT this can be merged now.

@rustaceanrob rustaceanrob changed the title protocol: Remove explicit rand dependency Remove explicit rand dependency Aug 14, 2025
@rustaceanrob rustaceanrob force-pushed the 8-14-rand branch 2 times, most recently from fa89b0e to 82e7fe1 Compare August 14, 2025 13:04
We only bring in `rand` explicitly for the `Rng` trait, coming from
`RngCore`. The `Rng` trait is a nightmare to implement, and we only use
a single call to `.fill`. If we export a far simpler trait that
represents filling a 32 byte slice, then users can have a far easier
time implementing this trait. This has come up in the past with this
project: https://github.com/issues/recent?issue=alfred-hodler%7Cpushtx%7C3

This also removes the need for `rand` as a dependency at all, and it may
be brought in through `bitcoin` (or later `secp256k1`)
}

#[cfg(feature = "std")]
macro_rules! impl_fill_bytes {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see macros:

image

But this one seems good since small and contained.

Copy link
Collaborator

@nyonson nyonson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3c24a68

Dropping the dep seems worth it, although it does open the caller up to a doing something silly and filling static bytes. But they will probably be using the default path anyways.

@rustaceanrob rustaceanrob merged commit db5ece0 into rust-bitcoin:main Aug 14, 2025
8 checks passed
@rustaceanrob rustaceanrob deleted the 8-14-rand branch August 14, 2025 14:41
@rustaceanrob rustaceanrob mentioned this pull request Aug 14, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants