Depend on primitives instead of bitcoin where type definitions overlap
What changed, and why it matters
This change is a routine internal dependency cleanup. The developers moved some shared type definitions (like block and transaction identifiers) from a large crate called `bitcoin` into a smaller, more focused crate called `bitcoin-primitives`. This reduces duplicate dependencies for downstream projects but does not change what the code does or fix any security problem.
No security action required. Treat as a normal dependency-refactoring commit; verify downstream builds still compile and tests pass.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors bitcoin-p2p-messages to import overlapping types (Block, BlockHash, Transaction, Txid, Wtxid) from bitcoin-primitives instead of the larger bitcoin crate. It updates p2p/Cargo.toml to add the new dependency and enables the std feature, and adjusts imports in p2p/src/message.rs, p2p/src/message_blockdata.rs, and p2p/src/message_filter.rs. Lock files are updated accordingly. No logic, serialization, or behavior changes are visible in the diff.
Changed components
p2p/Cargo.tomlp2p/src/message.rsp2p/src/message_blockdata.rsp2p/src/message_filter.rsCargo-minimal.lockCargo-recent.lockInspect captured patch +10 / −7
diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock
index 06a8bc12..5b02e75b 100644
--- a/Cargo-minimal.lock
+++ b/Cargo-minimal.lock
@@ -130,6 +130,7 @@ dependencies = [
"bitcoin-consensus-encoding",
"bitcoin-internals",
"bitcoin-io",
+ "bitcoin-primitives",
"bitcoin-units",
"bitcoin_hashes",
"hex-conservative 0.3.0",
diff --git a/Cargo-recent.lock b/Cargo-recent.lock
index 5efb757d..733ea21e 100644
--- a/Cargo-recent.lock
+++ b/Cargo-recent.lock
@@ -129,6 +129,7 @@ dependencies = [
"bitcoin-consensus-encoding",
"bitcoin-internals",
"bitcoin-io",
+ "bitcoin-primitives",
"bitcoin-units",
"bitcoin_hashes",
"hex-conservative 0.3.0",
diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml
index ee93bc22..a3109b90 100644
--- a/p2p/Cargo.toml
+++ b/p2p/Cargo.toml
@@ -14,13 +14,14 @@ exclude = ["tests", "contrib"]
[features]
default = ["std"]
-std = ["encoding/std", "hashes/std", "hex/std", "internals/std", "io/std", "units/std", "bitcoin/std"]
+std = ["encoding/std", "hashes/std", "hex/std", "internals/std", "io/std", "units/std", "bitcoin/std", "primitives/std"]
arbitrary = ["dep:arbitrary", "bitcoin/arbitrary"]
[dependencies]
bitcoin = { path = "../bitcoin/", default-features = false }
encoding = { package = "bitcoin-consensus-encoding", version = "=1.0.0-rc.2", path = "../consensus_encoding", default-features = false }
hashes = { package = "bitcoin_hashes", version = "0.18.0", path = "../hashes", default-features = false }
+primitives = { package = "bitcoin-primitives", path = "../primitives", version = "=1.0.0-rc.1", default-features = false }
hex = { package = "hex-conservative", version = "0.3.0", default-features = false }
internals = { package = "bitcoin-internals", path = "../internals", default-features = false }
io = { package = "bitcoin-io", path = "../io", default-features = false }
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index 84be6516..1d265321 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -16,7 +16,7 @@ use core::{cmp, fmt};
use arbitrary::{Arbitrary, Unstructured};
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
use bitcoin::merkle_tree::MerkleBlock;
-use bitcoin::{block, transaction};
+use primitives::{block, transaction};
use encoding;
use hashes::sha256d;
use internals::ToU64 as _;
@@ -1657,9 +1657,9 @@ mod test {
use alloc::vec;
use std::net::Ipv4Addr;
- use bitcoin::block::{Block, BlockHash};
+ use primitives::{Block, BlockHash};
use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize};
- use bitcoin::transaction::{Transaction, Txid};
+ use primitives::transaction::{Transaction, Txid};
use hex_lit::hex;
use units::BlockHeight;
diff --git a/p2p/src/message_blockdata.rs b/p2p/src/message_blockdata.rs
index 788e4c00..fef563f4 100644
--- a/p2p/src/message_blockdata.rs
+++ b/p2p/src/message_blockdata.rs
@@ -9,9 +9,9 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use bitcoin::block::BlockHash;
+use primitives::BlockHash;
use bitcoin::consensus::encode::{self, Decodable, Encodable};
-use bitcoin::transaction::{Txid, Wtxid};
+use primitives::transaction::{Txid, Wtxid};
use io::{BufRead, Write};
use crate::consensus::impl_consensus_encoding;
diff --git a/p2p/src/message_filter.rs b/p2p/src/message_filter.rs
index 01ca9221..9f740dce 100644
--- a/p2p/src/message_filter.rs
+++ b/p2p/src/message_filter.rs
@@ -8,7 +8,7 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use bitcoin::block::BlockHash;
+use primitives::BlockHash;
use hashes::{sha256d, HashEngine};
use units::BlockHeight;
Why this scored 18/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.