What changed, and why it matters
This is a routine internal refactoring commit in the rust-bitcoin project. It removes a direct dependency on the main 'bitcoin' crate from the smaller 'p2p' (peer-to-peer messages) crate and instead pulls in the needed features from more focused sub-crates. The only code change is updating a documentation example to use a different decoding function. There is no security-relevant change visible in the diff.
No security action required. Reviewers may optionally verify that the new dependency features provide equivalent APIs used by the p2p crate, but the change is a standard dependency cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors dependency declarations in p2p/Cargo.toml and the workspace lockfiles. It drops the path dependency on ../bitcoin, enables ‘alloc’ on bitcoin-consensus-encoding, enables ‘hex’ and ‘alloc’ on bitcoin-primitives, and switches the ‘arbitrary’ feature from ‘bitcoin/arbitrary’ to ‘primitives/arbitrary’. In p2p/src/merkle_tree.rs a doc-test example is changed from bitcoin::consensus::deserialize to encoding::decode_from_slice. No runtime logic, parsing boundaries, cryptographic operations, or network handling code is modified.
Changed components
p2p/Cargo.tomlp2p/src/merkle_tree.rs (doc example only)Cargo-minimal.lockCargo-recent.lockInspect captured patch +5 / −8
diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock
index 2293ea15..6f79e4d9 100644
--- a/Cargo-minimal.lock
+++ b/Cargo-minimal.lock
@@ -197,7 +197,6 @@ name = "bitcoin-p2p-messages"
version = "0.1.0"
dependencies = [
"arbitrary",
- "bitcoin 0.33.0-beta",
"bitcoin-consensus-encoding",
"bitcoin-internals 0.5.0",
"bitcoin-network-kind",
diff --git a/Cargo-recent.lock b/Cargo-recent.lock
index 23079b50..81eac410 100644
--- a/Cargo-recent.lock
+++ b/Cargo-recent.lock
@@ -196,7 +196,6 @@ name = "bitcoin-p2p-messages"
version = "0.1.0"
dependencies = [
"arbitrary",
- "bitcoin 0.33.0-beta",
"bitcoin-consensus-encoding",
"bitcoin-internals 0.5.0",
"bitcoin-network-kind",
diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml
index 1d8bbc16..14a832d5 100644
--- a/p2p/Cargo.toml
+++ b/p2p/Cargo.toml
@@ -15,16 +15,15 @@ exclude = ["tests", "contrib"]
[features]
default = ["std"]
-std = ["encoding/std", "hashes/std", "network/std", "hex-stable/std", "hex-unstable/std", "internals/std", "units/std", "bitcoin/std", "primitives/std"]
-arbitrary = ["dep:arbitrary", "bitcoin/arbitrary"]
+std = ["encoding/std", "hashes/std", "network/std", "hex-stable/std", "hex-unstable/std", "internals/std", "units/std", "primitives/std"]
+arbitrary = ["dep:arbitrary", "primitives/arbitrary"]
serde = ["dep:serde", "hashes/serde"]
[dependencies]
-bitcoin = { path = "../bitcoin/", default-features = false }
-encoding = { package = "bitcoin-consensus-encoding", version = "0.2.0", path = "../consensus_encoding", default-features = false }
+encoding = { package = "bitcoin-consensus-encoding", version = "0.2.0", path = "../consensus_encoding", features = ["alloc"], default-features = false }
hashes = { package = "bitcoin_hashes", version = "0.20.0", path = "../hashes", default-features = false }
network = { package = "bitcoin-network-kind", path = "../network", version = "0.1.0", default-features = false }
-primitives = { package = "bitcoin-primitives", path = "../primitives", version = "0.102.0", default-features = false }
+primitives = { package = "bitcoin-primitives", path = "../primitives", version = "0.102.0", features = ["hex", "alloc"], default-features = false }
hex-stable = { package = "hex-conservative", version = "1.0.0", default-features = false, features = ["alloc"] }
hex-unstable = { package = "hex-conservative", version = "0.3.2", default-features = false }
internals = { package = "bitcoin-internals", path = "../internals", default-features = false }
diff --git a/p2p/src/merkle_tree.rs b/p2p/src/merkle_tree.rs
index a57bf02c..ca92ee8d 100644
--- a/p2p/src/merkle_tree.rs
+++ b/p2p/src/merkle_tree.rs
@@ -64,7 +64,7 @@ impl MerkleBlock {
/// d3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d\
/// 5d6cc8d25c6b241501ffffffff0100f2052a010000001976a914404371705fa9bd789a2fcd52d2c580b6\
/// 5d35549d88ac00000000").unwrap();
- /// let block: Block = bitcoin::consensus::deserialize(&block_bytes).unwrap();
+ /// let block: Block = encoding::decode_from_slice(&block_bytes).unwrap();
/// let block = block.validate().expect("valid block");
///
/// // Constructs a new Merkle block containing a single transaction
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.