Merge rust-bitcoin/rust-bitcoin#4201: Make `hex` in `internals` optional

d1d483491f Make `hex` in `internals` optional (Martin Habovstiak)

Pull request description:

  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.

ACKs for top commit:
  tcharding:
    ACK d1d483491f
  apoelstra:
    ACK d1d483491f5f0181e60778e557fadd99b44b5d30; successfully ran local tests; nice

Tree-SHA512: c20091e6febb49b9114273c280580ddcdafc91893f3c73288b374f51990f09f035a044806dd26777148f2e4341ad082ab05f1b49f8ceb3bcd24eb210ffa5fd5f
This commit is contained in:
merge-script 2025-03-06 16:50:12 +00:00
commit a27a6b9592
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
4 changed files with 7 additions and 5 deletions

View File

@ -29,7 +29,7 @@ base58 = { package = "base58ck", version = "0.2.0", default-features = false, fe
bech32 = { version = "0.11.0", default-features = false, features = ["alloc"] }
hashes = { package = "bitcoin_hashes", version = "0.16.0", default-features = false, features = ["alloc", "hex"] }
hex = { package = "hex-conservative", version = "0.3.0", default-features = false, features = ["alloc"] }
internals = { package = "bitcoin-internals", version = "0.4.0", features = ["alloc"] }
internals = { package = "bitcoin-internals", version = "0.4.0", features = ["alloc", "hex"] }
io = { package = "bitcoin-io", version = "0.2.0", default-features = false, features = ["alloc", "hashes"] }
primitives = { package = "bitcoin-primitives", version = "0.101.0", default-features = false, features = ["alloc"] }
secp256k1 = { version = "0.30.0", default-features = false, features = ["hashes", "alloc", "rand"] }

View File

@ -15,13 +15,13 @@ exclude = ["tests", "contrib"]
[features]
default = []
std = ["alloc", "hex/std"]
alloc = ["hex/alloc"]
std = ["alloc", "hex?/std"]
alloc = ["hex?/alloc"]
test-serde = ["serde", "serde_json", "bincode"]
[dependencies]
hex = { package = "hex-conservative", version = "0.3.0", default-features = false }
hex = { package = "hex-conservative", version = "0.3.0", default-features = false, optional = true }
serde = { version = "1.0.103", default-features = false, optional = true }
# Don't enable these directly, use `test-serde` feature instead.

View File

@ -310,9 +310,11 @@ macro_rules! serde_round_trip (
})
);
#[cfg(feature = "hex")]
/// Serializes a byte slice using the `hex` crate.
pub struct SerializeBytesAsHex<'a>(pub &'a [u8]);
#[cfg(feature = "hex")]
impl serde::Serialize for SerializeBytesAsHex<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where

View File

@ -24,7 +24,7 @@ arbitrary = ["dep:arbitrary", "units/arbitrary"]
[dependencies]
hashes = { package = "bitcoin_hashes", version = "0.16.0", default-features = false, features = ["hex"] }
hex = { package = "hex-conservative", version = "0.3.0", default-features = false }
internals = { package = "bitcoin-internals", version = "0.4.0" }
internals = { package = "bitcoin-internals", version = "0.4.0", features = ["hex"] }
units = { package = "bitcoin-units", version = "0.2.0", default-features = false }
arbitrary = { version = "1.4", optional = true }