What changed, and why it matters
This commit is a simple code reorganization: a small trait called TxIdentifier that was defined in the main bitcoin crate is moved into the p2p crate's BIP-152 module because that was its only real user. There is no security fix, behavior change, or vulnerability being patched. It is purely a refactoring/cleanup change.
No security action needed. Treat as a normal refactoring commit. Reviewers may want to verify downstream crates that imported `bitcoin::transaction::TxIdentifier` are updated to use `p2p::bip152::TxIdentifier` if applicable.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes the TxIdentifier trait from bitcoin/src/blockdata/transaction.rs and adds an equivalent trait (plus its sealed module) directly in p2p/src/bip152.rs. The trait still abstracts over Txid and Wtxid and is still sealed. The only functional difference is the import path and module location. No logic, serialization, hashing, or API semantics are altered.
Changed components
bitcoin/src/blockdata/transaction.rsp2p/src/bip152.rsInspect captured patch +12 / −7
diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs
index 61bd5513..ac0312a0 100644
--- a/bitcoin/src/blockdata/transaction.rs
+++ b/bitcoin/src/blockdata/transaction.rs
@@ -76,12 +76,6 @@ internal_macros::define_extension_trait! {
}
}
-/// Trait that abstracts over a transaction identifier i.e., `Txid` and `Wtxid`.
-pub trait TxIdentifier: sealed::Sealed + AsRef<[u8]> {}
-
-impl TxIdentifier for Txid {}
-impl TxIdentifier for Wtxid {}
-
// Duplicated in `primitives`.
/// The marker MUST be a 1-byte zero value: 0x00. (BIP-0141)
const SEGWIT_MARKER: u8 = 0x00;
diff --git a/p2p/src/bip152.rs b/p2p/src/bip152.rs
index 27678594..43254ff1 100644
--- a/p2p/src/bip152.rs
+++ b/p2p/src/bip152.rs
@@ -13,7 +13,6 @@ use std::error;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
-use bitcoin::transaction::TxIdentifier;
use bitcoin::{block, Block, BlockChecked, BlockHash, Transaction};
use hashes::{sha256, siphash24};
use internals::array::ArrayExt as _;
@@ -94,6 +93,18 @@ impl Decodable for PrefilledTransaction {
}
}
+/// Trait that abstracts over a transaction identifier i.e., `Txid` and `Wtxid`.
+pub trait TxIdentifier: sealed::Sealed + AsRef<[u8]> {}
+
+impl TxIdentifier for bitcoin::Txid {}
+impl TxIdentifier for bitcoin::Wtxid {}
+
+mod sealed {
+ pub trait Sealed {}
+ impl Sealed for bitcoin::Txid {}
+ impl Sealed for bitcoin::Wtxid {}
+}
+
/// Short transaction IDs are used to represent a transaction without sending a full 256-bit hash.
#[derive(PartialEq, Eq, Clone, Copy, Hash, Default, PartialOrd, Ord)]
pub struct ShortId([u8; 6]);
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.