Drop the hex_lit dep in favor of built in hex
What changed, and why it matters
This commit is a routine dependency cleanup. It removes the external hex_lit crate and switches test/example code to use built-in hex macros from the project's own hex-conservative crate. There is no user-facing behavior change and no security fix or vulnerability introduced.
No security action needed. Treat as normal maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change replaces dev-dependency usage of hex_lit::hex with hex-conservative-provided macros (hex::hex or hex_unstable::hex) across tests, benchmarks, and examples. Cargo manifests and lockfiles are updated accordingly. One test in bip158.rs adds an intermediate variable to satisfy lifetime requirements of the new macro. No runtime library code is modified.
Changed components
base58 testsbitcoin tests and examplesp2p testsprimitives testsbenchesCargo manifests and lockfilesInspect captured patch +25 / −48
diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock
index ef39a09a..72d32b36 100644
--- a/Cargo-minimal.lock
+++ b/Cargo-minimal.lock
@@ -20,7 +20,7 @@ version = "0.4.0"
dependencies = [
"bitcoin-internals",
"bitcoin_hashes",
- "hex_lit",
+ "hex-conservative 0.3.2",
]
[[package]]
@@ -64,7 +64,6 @@ dependencies = [
"bitcoinconsensus",
"hex-conservative 0.3.2",
"hex-conservative 1.0.0",
- "hex_lit",
"secp256k1",
"serde",
"serde_json",
@@ -153,7 +152,6 @@ dependencies = [
"bitcoin_hashes",
"hex-conservative 0.3.2",
"hex-conservative 1.0.0",
- "hex_lit",
"serde",
]
@@ -169,7 +167,6 @@ dependencies = [
"bitcoin_hashes",
"hex-conservative 0.3.2",
"hex-conservative 1.0.0",
- "hex_lit",
"serde",
"serde_json",
]
@@ -276,12 +273,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ee770c000993d17c185713463d5ebfbd1af9afae4c17cc295640104383bfbf0"
-[[package]]
-name = "hex_lit"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
-
[[package]]
name = "itoa"
version = "0.4.3"
diff --git a/Cargo-recent.lock b/Cargo-recent.lock
index 68b9b6f5..e231d26f 100644
--- a/Cargo-recent.lock
+++ b/Cargo-recent.lock
@@ -20,7 +20,7 @@ version = "0.4.0"
dependencies = [
"bitcoin-internals",
"bitcoin_hashes",
- "hex_lit",
+ "hex-conservative 0.3.2",
]
[[package]]
@@ -63,7 +63,6 @@ dependencies = [
"bitcoinconsensus",
"hex-conservative 0.3.2",
"hex-conservative 1.0.0",
- "hex_lit",
"secp256k1",
"serde",
"serde_json",
@@ -152,7 +151,6 @@ dependencies = [
"bitcoin_hashes",
"hex-conservative 0.3.2",
"hex-conservative 1.0.0",
- "hex_lit",
"serde",
]
@@ -168,7 +166,6 @@ dependencies = [
"bitcoin_hashes",
"hex-conservative 0.3.2",
"hex-conservative 1.0.0",
- "hex_lit",
"serde",
"serde_json",
]
@@ -274,12 +271,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ee770c000993d17c185713463d5ebfbd1af9afae4c17cc295640104383bfbf0"
-[[package]]
-name = "hex_lit"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
-
[[package]]
name = "itoa"
version = "1.0.11"
diff --git a/base58/Cargo.toml b/base58/Cargo.toml
index 1e0d043d..f732def0 100644
--- a/base58/Cargo.toml
+++ b/base58/Cargo.toml
@@ -22,7 +22,7 @@ hashes = { package = "bitcoin_hashes", path = "../hashes", version = "0.20.0", d
internals = { package = "bitcoin-internals", path = "../internals", version = "0.5.0" }
[dev-dependencies]
-hex_lit = "0.1.1"
+hex = { package = "hex-conservative", version = "0.3.2" }
[package.metadata.docs.rs]
all-features = true
diff --git a/base58/src/lib.rs b/base58/src/lib.rs
index 5a85068f..6590589b 100644
--- a/base58/src/lib.rs
+++ b/base58/src/lib.rs
@@ -266,7 +266,7 @@ where
mod tests {
use alloc::vec;
- use hex_lit::hex;
+ use hex::hex;
use super::*;
diff --git a/benches/Cargo.toml b/benches/Cargo.toml
index ba7ff442..3a71c72c 100644
--- a/benches/Cargo.toml
+++ b/benches/Cargo.toml
@@ -12,7 +12,7 @@ chacha20-poly1305 = { path = "../chacha20_poly1305" }
encoding = { package = "bitcoin-consensus-encoding", path = "../consensus_encoding" }
criterion = "0.7"
-hex_lit = "0.1.1"
+hex = { package = "hex-conservative", version = "0.3.2" }
[lints.clippy]
use_self = "warn"
diff --git a/benches/bitcoin/transaction.rs b/benches/bitcoin/transaction.rs
index ab8101fa..723f74a6 100644
--- a/benches/bitcoin/transaction.rs
+++ b/benches/bitcoin/transaction.rs
@@ -39,7 +39,7 @@ fn bench_tx(c: &mut Criterion) {
});
g.bench_function(BenchmarkId::new("deserialize", "raw_bytes"), |b| {
- let raw_tx = hex_lit::hex!(SOME_TX);
+ let raw_tx = hex::hex!(SOME_TX);
b.iter(|| {
let tx: Transaction = encode::deserialize(&raw_tx).unwrap();
black_box(tx);
diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml
index 804aca6b..6891d125 100644
--- a/bitcoin/Cargo.toml
+++ b/bitcoin/Cargo.toml
@@ -49,7 +49,6 @@ internals = { package = "bitcoin-internals", path = "../internals", features = [
serde_json = "1.0.68"
serde_test = "1.0.19"
bincode = "1.3.1"
-hex_lit = "0.1.1"
[package.metadata.docs.rs]
all-features = true
diff --git a/bitcoin/examples/sighash.rs b/bitcoin/examples/sighash.rs
index 1440cbbf..50788365 100644
--- a/bitcoin/examples/sighash.rs
+++ b/bitcoin/examples/sighash.rs
@@ -3,7 +3,7 @@ use bitcoin::{
consensus, ecdsa, sighash, Amount, CompressedPublicKey, ScriptPubKey, ScriptPubKeyBuf,
Transaction, WitnessScript,
};
-use hex_lit::hex;
+use hex_unstable::hex;
//These are real blockchain transactions examples of computing sighash for:
// - P2WPKH
diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs
index c591599f..c200a6d6 100644
--- a/bitcoin/src/address/mod.rs
+++ b/bitcoin/src/address/mod.rs
@@ -1025,7 +1025,7 @@ fn segwit_redeem_hash(pubkey_hash: PubkeyHash) -> hash160::Hash {
mod tests {
use alloc::string::ToString;
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
use crate::network::Network::{Bitcoin, Testnet};
diff --git a/bitcoin/src/bip158.rs b/bitcoin/src/bip158.rs
index 89be8945..9b3877c0 100644
--- a/bitcoin/src/bip158.rs
+++ b/bitcoin/src/bip158.rs
@@ -536,7 +536,7 @@ mod test {
#[cfg(feature = "std")]
use std::collections::HashMap;
- use hex_lit::hex;
+ use hex_unstable::hex;
#[cfg(feature = "std")]
use serde_json::Value;
@@ -672,7 +672,8 @@ mod test {
for p in &patterns {
query.push(p);
}
- query.push(&hex!("abcdef"));
+ let extra = hex!("abcdef");
+ query.push(&extra);
assert!(!reader
.match_all(&mut bytes.as_slice(), &mut query.iter().map(|v| v.as_slice()))
.unwrap());
diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs
index f2054ad7..c05e90f6 100644
--- a/bitcoin/src/bip32.rs
+++ b/bitcoin/src/bip32.rs
@@ -1110,7 +1110,7 @@ impl Common {
mod tests {
use alloc::string::ToString;
- use hex_lit::hex;
+ use hex_unstable::hex;
#[cfg(feature = "serde")]
use internals::serde_round_trip;
diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs
index 66b1739d..1425c9a7 100644
--- a/bitcoin/src/blockdata/block.rs
+++ b/bitcoin/src/blockdata/block.rs
@@ -393,7 +393,7 @@ impl std::error::Error for ValidationError {
mod tests {
use alloc::string::ToString;
- use hex_lit::hex;
+ use hex_unstable::hex;
use internals::ToU64 as _;
use primitives::Wtxid;
diff --git a/bitcoin/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs
index 5fec1961..66e6a8e4 100644
--- a/bitcoin/src/blockdata/constants.rs
+++ b/bitcoin/src/blockdata/constants.rs
@@ -286,7 +286,7 @@ impl ChainHash {
mod test {
use alloc::string::ToString;
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
use crate::consensus::encode::serialize;
diff --git a/bitcoin/src/blockdata/script/tests.rs b/bitcoin/src/blockdata/script/tests.rs
index b644417e..63c605c2 100644
--- a/bitcoin/src/blockdata/script/tests.rs
+++ b/bitcoin/src/blockdata/script/tests.rs
@@ -4,7 +4,7 @@
use alloc::borrow::ToOwned;
use alloc::string::ToString;
-use hex_lit::hex;
+use hex_unstable::hex;
use super::*;
use crate::consensus::encode::{deserialize, serialize};
diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs
index 6d1a7f65..79d637c4 100644
--- a/bitcoin/src/blockdata/transaction.rs
+++ b/bitcoin/src/blockdata/transaction.rs
@@ -1283,7 +1283,7 @@ impl<'a> Arbitrary<'a> for InputWeightPrediction {
mod tests {
use alloc::string::ToString;
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
use crate::consensus::encode::{deserialize, serialize};
diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs
index e155e166..8da50693 100644
--- a/bitcoin/src/blockdata/witness.rs
+++ b/bitcoin/src/blockdata/witness.rs
@@ -239,7 +239,7 @@ mod sealed {
mod test {
use alloc::vec::Vec;
- use hex_lit::hex;
+ use hex_unstable::hex;
use hex_unstable::DisplayHex;
use super::*;
diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs
index 886129cb..2533e0e8 100644
--- a/bitcoin/src/crypto/sighash.rs
+++ b/bitcoin/src/crypto/sighash.rs
@@ -1532,7 +1532,7 @@ mod tests {
use alloc::vec::Vec;
use hashes::HashEngine;
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
use crate::consensus::deserialize;
diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs
index 7465d3e7..86dec60c 100644
--- a/bitcoin/src/psbt/mod.rs
+++ b/bitcoin/src/psbt/mod.rs
@@ -1299,7 +1299,7 @@ mod tests {
use core::str::FromStr;
use hashes::{hash160, ripemd160, sha256};
- use hex_lit::hex;
+ use hex_unstable::hex;
#[cfg(all(feature = "rand", feature = "std"))]
use {
crate::bip32::Fingerprint, crate::locktime, crate::script::ScriptPubKeyBufExt as _,
diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml
index 8e5be39d..0c104046 100644
--- a/p2p/Cargo.toml
+++ b/p2p/Cargo.toml
@@ -33,9 +33,6 @@ units = { package = "bitcoin-units", path = "../units", version = "0.3.0", defau
arbitrary = { version = "1.4.1", optional = true }
serde = { version = "1.0.195", default-features = false, features = ["derive", "alloc"], optional = true }
-[dev-dependencies]
-hex_lit = "0.1.1"
-
[[example]]
name = "handshake"
required-features = ["std"]
diff --git a/p2p/src/address.rs b/p2p/src/address.rs
index 5b2e53a5..0e386f5a 100644
--- a/p2p/src/address.rs
+++ b/p2p/src/address.rs
@@ -1064,7 +1064,7 @@ mod test {
use std::net::IpAddr;
use bitcoin::consensus::encode::{deserialize, serialize};
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
use crate::hex;
diff --git a/p2p/src/merkle_tree.rs b/p2p/src/merkle_tree.rs
index daeeb9e8..ca6a26b1 100644
--- a/p2p/src/merkle_tree.rs
+++ b/p2p/src/merkle_tree.rs
@@ -738,8 +738,7 @@ impl<'a> Arbitrary<'a> for MerkleBlock {
mod tests {
use core::cmp;
- use hex_unstable::DisplayHex;
- use hex_lit::hex;
+ use hex_unstable::{hex, DisplayHex};
use primitives::block::Unchecked;
use super::*;
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index 98a0557b..d10c36d2 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -1993,7 +1993,7 @@ mod test {
use std::net::Ipv4Addr;
use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize};
- use hex_lit::hex;
+ use hex_unstable::hex;
use primitives::transaction::{Transaction, Txid};
use primitives::{Block, BlockHash};
use units::BlockHeight;
diff --git a/p2p/src/message_blockdata.rs b/p2p/src/message_blockdata.rs
index 4c2b34a7..46535213 100644
--- a/p2p/src/message_blockdata.rs
+++ b/p2p/src/message_blockdata.rs
@@ -432,7 +432,7 @@ impl<'a> Arbitrary<'a> for Inventory {
#[cfg(test)]
mod tests {
use bitcoin::consensus::encode::{deserialize, serialize};
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
diff --git a/p2p/src/message_network.rs b/p2p/src/message_network.rs
index 7df457d3..dfe35e6d 100644
--- a/p2p/src/message_network.rs
+++ b/p2p/src/message_network.rs
@@ -760,7 +760,7 @@ mod tests {
use alloc::string::ToString;
use bitcoin::consensus::encode::{deserialize, serialize};
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml
index d1e35162..7afe561e 100644
--- a/primitives/Cargo.toml
+++ b/primitives/Cargo.toml
@@ -35,7 +35,6 @@ hex-unstable = { package = "hex-conservative", version = "0.3.2", default-featur
[dev-dependencies]
serde_json = "1.0.68"
bincode = "1.3.1"
-hex_lit = "0.1.1"
[package.metadata.docs.rs]
all-features = true
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 46265047..8e3d248f 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -1662,7 +1662,7 @@ mod tests {
use encoding::Encoder as _;
#[cfg(feature = "hex")]
- use hex_lit::hex;
+ use hex_unstable::hex;
use super::*;
#[cfg(all(feature = "alloc", feature = "hex"))]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.