What changed, and why it matters
This commit fixes missing public re-exports of encoder/decoder types and their error types in the rust-bitcoin crate. It is a packaging/API consistency fix: the bitcoin crate is meant to expose everything primitives exposes, and primitives everything units exposes. The change adds those missing re-exports and updates the test scripts that check this property. There is no indication of a runtime vulnerability, memory corruption, or exploit path.
No security action required. Treat as a normal API consistency fix. If consuming this crate, note that additional encoder/decoder types are now available from the bitcoin crate public API.
Security signals we found
No unsafe code added
No parsing/serialization logic modified
No cryptographic operations changed
No input validation changes
No memory management changes
Change is limited to public re-export declarations and test-generation scripts
Evidence from the diff
The patch adds pub use re-exports for *Encoder, *Decoder, and *DecoderError types from primitives (and units) into the bitcoin crate modules (block, script, transaction, witness). It also removes a filter in generate-bitcoin-re-export-test.sh that skipped Encoder/Decoder names and adds a pub use check to generate-primitives-re-export-test.sh. This is purely an API surface completeness fix; no logic, parsing, serialization, or cryptographic code is changed.
Changed components
bitcoin/src/blockdata/block.rsbitcoin/src/blockdata/script/mod.rsbitcoin/src/blockdata/transaction.rsbitcoin/src/blockdata/witness.rscontrib/generate-bitcoin-re-export-test.shcontrib/generate-primitives-re-export-test.shInspect captured patch +35 / −16
diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs
index afcf91a5..66b1739d 100644
--- a/bitcoin/src/blockdata/block.rs
+++ b/bitcoin/src/blockdata/block.rs
@@ -25,15 +25,22 @@ use crate::{internal_macros, BlockTime, Target, Weight, Work};
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]
pub use primitives::block::{
- Block, Checked, Unchecked, Validation, Version, BlockHash, Header,
- WitnessCommitment, compute_merkle_root, compute_witness_root,
+ Block, BlockDecoder, BlockEncoder, BlockHash, BlockHashDecoder, BlockHashEncoder,
+ Checked, Unchecked, Validation, Version, VersionDecoder, VersionEncoder, Header,
+ HeaderDecoder, HeaderEncoder, WitnessCommitment, compute_merkle_root, compute_witness_root,
};
#[doc(no_inline)]
-pub use primitives::block::{InvalidBlockError, ParseBlockError, ParseHeaderError};
+pub use primitives::block::{
+ BlockDecoderError, BlockHashDecoderError, HeaderDecoderError, InvalidBlockError,
+ ParseBlockError, ParseHeaderError, VersionDecoderError,
+};
#[doc(inline)]
-pub use units::block::{BlockHeight, BlockHeightInterval, BlockMtp, BlockMtpInterval};
+pub use units::block::{
+ BlockHeight, BlockHeightDecoder, BlockHeightEncoder, BlockHeightInterval, BlockMtp,
+ BlockMtpInterval,
+};
#[doc(no_inline)]
-pub use units::block::TooBigForRelativeHeightError;
+pub use units::block::{BlockHeightDecoderError, TooBigForRelativeHeightError};
#[deprecated(since = "TBD", note = "use `BlockHeightInterval` instead")]
#[doc(hidden)]
diff --git a/bitcoin/src/blockdata/script/mod.rs b/bitcoin/src/blockdata/script/mod.rs
index b48470b8..894ce0d6 100644
--- a/bitcoin/src/blockdata/script/mod.rs
+++ b/bitcoin/src/blockdata/script/mod.rs
@@ -81,10 +81,13 @@ pub use self::{
#[doc(inline)]
pub use primitives::script::{
RedeemScript, RedeemScriptBuf, RedeemScriptSizeError, RedeemScriptTag, Script, ScriptBuf,
- ScriptHash, ScriptHashableTag, ScriptPubKey, ScriptPubKeyBuf, ScriptPubKeyTag, ScriptSig,
- ScriptSigBuf, ScriptSigTag, Tag, TapScript, TapScriptBuf, TapScriptTag, WScriptHash,
- WitnessScript, WitnessScriptBuf, WitnessScriptSizeError, WitnessScriptTag,
+ ScriptBufDecoder, ScriptEncoder, ScriptHash, ScriptHashableTag, ScriptPubKey,
+ ScriptPubKeyBuf, ScriptPubKeyTag, ScriptSig, ScriptSigBuf, ScriptSigTag, Tag, TapScript,
+ TapScriptBuf, TapScriptTag, WScriptHash, WitnessScript, WitnessScriptBuf,
+ WitnessScriptSizeError, WitnessScriptTag,
};
+#[doc(no_inline)]
+pub use primitives::script::ScriptBufDecoderError;
pub(crate) use self::borrowed::ScriptExtPriv;
pub(crate) use self::owned::ScriptBufExtPriv;
diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs
index 38510344..6d1a7f65 100644
--- a/bitcoin/src/blockdata/transaction.rs
+++ b/bitcoin/src/blockdata/transaction.rs
@@ -33,10 +33,17 @@ use crate::{internal_macros, Amount, FeeRate, Sequence, SignedAmount};
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(no_inline)]
-pub use primitives::transaction::{ParseTransactionError, ParseOutPointError};
+pub use primitives::transaction::{
+ BlockHashDecoderError, OutPointDecoderError, ParseTransactionError, ParseOutPointError,
+ TransactionDecoderError, TxInDecoderError, TxOutDecoderError,
+ VersionDecoderError,
+};
#[doc(inline)]
pub use primitives::transaction::{
- Ntxid, OutPoint, Transaction, TxIn, TxOut, Txid, Version, Wtxid,
+ BlockHashDecoder, Ntxid, OutPoint, OutPointDecoder, OutPointEncoder, Transaction,
+ TransactionDecoder, TransactionEncoder, TxIn, TxInDecoder, TxInEncoder,
+ TxOut, TxOutDecoder, TxOutEncoder, Txid, Version,
+ VersionDecoder, VersionEncoder, WitnessesEncoder, Wtxid,
};
impl Encodable for Txid {
diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs
index 4798f1c6..e155e166 100644
--- a/bitcoin/src/blockdata/witness.rs
+++ b/bitcoin/src/blockdata/witness.rs
@@ -17,9 +17,9 @@ type BorrowedControlBlock<'a> = ControlBlock<&'a TaprootMerkleBranch, &'a Serial
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]
-pub use primitives::witness::{Iter, Witness};
+pub use primitives::witness::{Iter, Witness, WitnessDecoder, WitnessEncoder};
#[doc(no_inline)]
-pub use primitives::witness::UnexpectedEofError;
+pub use primitives::witness::{UnexpectedEofError, WitnessDecoderError};
impl Decodable for Witness {
fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> Result<Self, Error> {
diff --git a/contrib/generate-bitcoin-re-export-test.sh b/contrib/generate-bitcoin-re-export-test.sh
index 1314d93d..f67a403d 100755
--- a/contrib/generate-bitcoin-re-export-test.sh
+++ b/contrib/generate-bitcoin-re-export-test.sh
@@ -95,16 +95,15 @@ EOF
# Extract pub mod
elif [[ "$line" =~ ^pub\ mod\ (bitcoin_primitives::[^[:space:]]+)$ ]]; then
path="${BASH_REMATCH[1]}"
+ # Extract pub use (re-exports)
+ elif [[ "$line" =~ ^pub\ use\ (bitcoin_primitives::[^[:space:]]+)$ ]]; then
+ path="${BASH_REMATCH[1]}"
fi
if [[ -n "$path" ]]; then
# Remove generic type parameters (e.g., <T>)
path="${path%%<*}"
- if [[ "$path" == *Encoder* ]] || [[ $path == *Decoder* ]]; then
- continue
- fi
-
# Convert bitcoin_primitives:: to bitcoin::
local bitcoin_path="${path//bitcoin_primitives::/bitcoin::}"
diff --git a/contrib/generate-primitives-re-export-test.sh b/contrib/generate-primitives-re-export-test.sh
index ca138ead..e052113f 100755
--- a/contrib/generate-primitives-re-export-test.sh
+++ b/contrib/generate-primitives-re-export-test.sh
@@ -99,6 +99,9 @@ EOF
# Extract pub mod
elif [[ "$line" =~ ^pub\ mod\ (bitcoin_units::[^[:space:]]+)$ ]]; then
path="${BASH_REMATCH[1]}"
+ # Extract pub use (re-exports)
+ elif [[ "$line" =~ ^pub\ use\ (bitcoin_primitives::[^[:space:]]+)$ ]]; then
+ path="${BASH_REMATCH[1]}"
fi
if [[ -n "$path" ]]; then
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.