Move Transaction encoder inner type to alias
What changed, and why it matters
This commit is a minor internal code cleanup in the Rust Bitcoin library. It replaces a long, complex type definition inside a macro with a shorter type alias name. There is no change to how transactions are encoded, no change to public behavior, and no security relevance.
No action required. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces TransactionEncoderInner<'e> as a type alias for the existing Encoder6<...> composite type and updates the encoding::encoder_newtype! invocation to use that alias. The type structure, lifetimes, and public API remain unchanged. This is purely a maintainability refactor to avoid future lint warnings as lifetimes are introduced.
Changed components
primitives/src/transaction.rsInspect captured patch +8 / −7
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 61024cbb..7abeb739 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -323,18 +323,19 @@ fn hash_transaction(tx: &Transaction, uses_segwit_serialization: bool) -> sha256
}
#[cfg(feature = "alloc")]
-encoding::encoder_newtype! {
- /// The encoder for the [`Transaction`] type.
- pub struct TransactionEncoder<'e>(
- Encoder6<
- VersionEncoder,
+type TransactionEncoderInner<'e> = Encoder6<
+ VersionEncoder,
Option<ArrayEncoder<2>>,
Encoder2<CompactSizeEncoder, SliceEncoder<'e, TxIn>>,
Encoder2<CompactSizeEncoder, SliceEncoder<'e, TxOut>>,
Option<WitnessesEncoder<'e>>,
LockTimeEncoder,
- >
- );
+ >;
+
+#[cfg(feature = "alloc")]
+encoding::encoder_newtype! {
+ /// The encoder for the [`Transaction`] type.
+ pub struct TransactionEncoder<'e>(TransactionEncoderInner<'e>);
}
#[cfg(feature = "alloc")]
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.