primitives: Replace instances of old encoding trait names
What changed, and why it matters
This commit only updates documentation and code comments. It renames references to old trait names (Encodable/Decodable) to the new names (Encode/Decode) and adds clickable documentation links. No actual program logic or behavior was changed.
No action required; this is a non-functional documentation cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is limited to comment and doc-string changes in primitives/src/hex_codec.rs and primitives/src/transaction.rs. It replaces ‘Encodable’/’Decodable’ with ‘Encode’/’Decode’ and adds rustdoc intra-crate links. There are no code-path, API, serialization, or cryptographic changes.
Changed components
primitives/src/hex_codec.rsprimitives/src/transaction.rsInspect captured patch +8 / −8
### primitives/src/hex_codec.rs
@@ -5,7 +5,7 @@
//! Various types in primitives need to be rendered in hexadecimal.
//! Since `consensus_encoding` only provides a method using `alloc`
//! to do this, this module provides utilities for alloc-less encoding
-//! of `Encodable` types within the primitives crate.
+//! of [`Encode`](encoding::Encode) types within the primitives crate.
use core::fmt;
use core::fmt::Write as _;
### primitives/src/transaction.rs
@@ -329,7 +329,7 @@ fn hash_transaction(tx: &Transaction, uses_segwit_serialization: bool) -> sha256
let input_len = tx.inputs.len();
enc.input(crate::compact_size_encode(input_len).as_slice());
for input in &tx.inputs {
- // Encode each input same as we do in `Encodable for TxIn`.
+ // Encode each input same as we do in `Encode for TxIn`.
enc.input(input.previous_output.txid.as_byte_array());
enc.input(&input.previous_output.vout.to_le_bytes());
@@ -344,7 +344,7 @@ fn hash_transaction(tx: &Transaction, uses_segwit_serialization: bool) -> sha256
let output_len = tx.outputs.len();
enc.input(crate::compact_size_encode(output_len).as_slice());
for output in &tx.outputs {
- // Encode each output same as we do in `Encodable for TxOut`.
+ // Encode each output same as we do in `Encode for TxOut`.
enc.input(&output.amount.to_sat().to_le_bytes());
let script_pubkey_bytes = output.script_pubkey.as_bytes();
@@ -355,7 +355,7 @@ fn hash_transaction(tx: &Transaction, uses_segwit_serialization: bool) -> sha256
if uses_segwit_serialization {
// BIP-0141 (SegWit) transaction serialization also includes the witness data.
for input in &tx.inputs {
- // Same as `Encodable for Witness`.
+ // Same as `Encode for Witness`.
enc.input(crate::compact_size_encode(input.witness.len()).as_slice());
for element in &input.witness {
enc.input(crate::compact_size_encode(element.len()).as_slice());
@@ -364,7 +364,7 @@ fn hash_transaction(tx: &Transaction, uses_segwit_serialization: bool) -> sha256
}
}
- // Same as `Encodable for absolute::LockTime`.
+ // Same as `Encode for absolute::LockTime`.
enc.input(&tx.lock_time.to_consensus_u32().to_le_bytes());
sha256d::Hash::from_engine(enc)
@@ -777,9 +777,9 @@ pub struct TxIn {
pub sequence: Sequence,
/// Witness data: an array of byte-arrays.
/// Note that this field is *not* (de)serialized with the rest of the [`TxIn`] in
- /// Encodable/Decodable, as it is (de)serialized at the end of the full
- /// [`Transaction`]. It *is* (de)serialized with the rest of the [`TxIn`] in other
- /// (de)serialization routines.
+ /// [`Encode`](encoding::Encode)/[`Decode`](encoding::Decode), as it is (de)serialized at the
+ /// end of the full [`Transaction`]. It *is* (de)serialized with the rest of the [`TxIn`] in
+ /// other (de)serialization routines.
pub witness: Witness,
}
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.