primitives: Move TxMerkleNodeDecoder/Error to merkle_tree
What changed, and why it matters
This commit is a straightforward code organization change. It moves where two helper types (TxMerkleNodeDecoder and TxMerkleNodeDecoderError) are publicly exported so they sit alongside related types in the merkle_tree module instead of the transaction module. There is no change to how data is decoded, no bug fix, and no security impact.
No security action needed. Treat as a normal API cleanup; downstream users may need to update import paths if they were using the old re-export location.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adjusts public re-exports in rust-bitcoin. TxMerkleNodeDecoder and TxMerkleNodeDecoderError are re-exported from primitives::merkle_tree rather than primitives::transaction, and the bitcoin crate’s merkle_tree module is updated to expose them consistently with TxMerkleNode and TxMerkleNodeEncoder. The implementation of these types is unchanged; only their public module location changes. This is an API ergonomics refactor.
Changed components
primitives/src/merkle_tree.rsprimitives/src/transaction.rsprimitives/src/block.rsbitcoin/src/merkle_tree/mod.rsInspect captured patch +11 / −4
diff --git a/bitcoin/src/merkle_tree/mod.rs b/bitcoin/src/merkle_tree/mod.rs
index 16fad6cf..621ce768 100644
--- a/bitcoin/src/merkle_tree/mod.rs
+++ b/bitcoin/src/merkle_tree/mod.rs
@@ -18,7 +18,12 @@ use io::{BufRead, Write};
#[rustfmt::skip]
#[doc(inline)]
-pub use primitives::{TxMerkleNode, WitnessMerkleNode};
+pub use primitives::{
+ TxMerkleNode, WitnessMerkleNode,
+ merkle_tree::{TxMerkleNodeDecoder, TxMerkleNodeEncoder},
+};
+#[doc(no_inline)]
+pub use primitives::merkle_tree::TxMerkleNodeDecoderError;
use crate::consensus::{encode, Decodable, Encodable};
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index 005ef6b4..d5d5e14d 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -28,7 +28,7 @@ use crate::hex_codec::{HexPrimitive, ParsePrimitiveError};
#[cfg(feature = "alloc")]
use crate::prelude::Vec;
use crate::time::{BlockTimeDecoder, BlockTimeDecoderError};
-use crate::transaction::{TxMerkleNodeDecoder, TxMerkleNodeDecoderError};
+use crate::merkle_tree::{TxMerkleNodeDecoder, TxMerkleNodeDecoderError};
use crate::{BlockTime, CompactTarget, TxMerkleNode};
#[cfg(feature = "alloc")]
use crate::{Transaction, WitnessMerkleNode};
diff --git a/primitives/src/merkle_tree.rs b/primitives/src/merkle_tree.rs
index 49ac63c8..96fc9424 100644
--- a/primitives/src/merkle_tree.rs
+++ b/primitives/src/merkle_tree.rs
@@ -17,7 +17,9 @@ use hashes::{sha256d, HashEngine};
use internals::array_vec::ArrayVec;
#[doc(inline)]
-pub use crate::hash_types::{TxMerkleNode, TxMerkleNodeEncoder, WitnessMerkleNode};
+pub use crate::hash_types::{
+ TxMerkleNode, TxMerkleNodeDecoder, TxMerkleNodeEncoder, TxMerkleNodeDecoderError, WitnessMerkleNode
+};
use crate::hash_types::{Txid, Wtxid};
use crate::transaction::TxIdentifier;
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 4cdd4477..09294107 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -51,7 +51,7 @@ use crate::{absolute, Amount, ScriptPubKeyBuf, ScriptSigBuf, Sequence, Weight, W
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]
-pub use crate::hash_types::{Ntxid, Txid, Wtxid, BlockHashDecoder, TxMerkleNodeDecoder, TxMerkleNodeDecoderError};
+pub use crate::hash_types::{Ntxid, Txid, Wtxid, BlockHashDecoder};
#[doc(no_inline)]
pub use crate::hash_types::BlockHashDecoderError;
Why this scored 20/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.