What changed, and why it matters
This commit only changes documentation comments in three source files. It replaces the word 'varint' with 'CompactSize' or 'length prefix' to match the project's current terminology. No code logic, serialization, or API behavior was altered.
No action required. This is a documentation-only terminology cleanup with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is limited to rustdoc and inline comments in bitcoin/src/blockdata/transaction.rs, bitcoin/src/merkle_tree/block.rs, and primitives/src/witness.rs. It updates terminology from ‘varint’ to ‘CompactSize’/’length prefix’ and adds a link to the Bitcoin wiki CompactSize definition. There are no functional code changes, no bug fixes, and no security-relevant behavior modifications.
Changed components
bitcoin/src/blockdata/transaction.rs (documentation only)bitcoin/src/merkle_tree/block.rs (documentation only)primitives/src/witness.rs (documentation only)Inspect captured patch +15 / −14
diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs
index c017a06a..c964c4e2 100644
--- a/bitcoin/src/blockdata/transaction.rs
+++ b/bitcoin/src/blockdata/transaction.rs
@@ -119,8 +119,8 @@ internal_macros::define_extension_trait! {
/// The weight of the TxIn when it's included in a SegWit transaction (i.e., a transaction
/// having at least one SegWit input).
///
- /// This always takes into account the witness, even when empty, in which
- /// case 1WU for the witness length varint (`00`) is included.
+ /// This always takes into account the witness, even when empty (in which
+ /// case 1WU for the witness length `00` is included).
///
/// Keep in mind that when adding a TxIn to a transaction, the total weight of the transaction
/// might increase more than `TxIn::segwit_weight`. This happens when:
@@ -795,8 +795,7 @@ pub fn effective_value(
/// of the to-be-constructed transaction.
///
/// Note that lengths of the scripts and witness elements must be non-serialized, IOW *without* the
-/// preceding compact size. The length of preceding compact size is computed and added inside the
-/// function for convenience.
+/// length prefix. The length is computed and added inside the function for convenience.
///
/// If you have the transaction already constructed (except for signatures) with a dummy value for
/// fee output you can use the return value of [`Transaction::script_pubkey_lens`] method directly
@@ -1116,7 +1115,7 @@ impl InputWeightPrediction {
}
/// Computes the **signature weight** added to a transaction by an input with this weight prediction,
- /// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint.
+ /// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count.
///
/// This function's internal arithmetic saturates at u32::MAX, so the return value of this
/// function may be inaccurate for extremely large witness predictions.
@@ -1138,7 +1137,7 @@ impl InputWeightPrediction {
}
/// Computes the **signature weight** added to a transaction by an input with this weight prediction,
- /// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint.
+ /// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count.
///
/// This function's internal arithmetic saturates at u32::MAX, so the return value of this
/// function may be inaccurate for extremely large witness predictions.
diff --git a/bitcoin/src/merkle_tree/block.rs b/bitcoin/src/merkle_tree/block.rs
index fe19904d..3629585f 100644
--- a/bitcoin/src/merkle_tree/block.rs
+++ b/bitcoin/src/merkle_tree/block.rs
@@ -163,11 +163,11 @@ impl Decodable for MerkleBlock {
/// N <= 1 + matched_transactions*tree_height
///
/// The serialization format:
-/// - uint32 total_transactions (4 bytes)
-/// - varint number of hashes (1-3 bytes)
-/// - uint256[] hashes in depth-first order (<= 32*N bytes)
-/// - varint number of bytes of flag bits (1-3 bytes)
-/// - byte[] flag bits, packed per 8 in a byte, least significant bit first (<= 2*N-1 bits)
+/// - uint32 total_transactions (4 bytes)
+/// - CompactSize number of hashes (1-3 bytes)
+/// - uint256[] hashes in depth-first order (<= 32*N bytes)
+/// - CompactSize number of bytes of flag bits (1-3 bytes)
+/// - byte[] flag bits, packed per 8 in a byte, least significant bit first (<= 2*N-1 bits)
///
/// The size constraints follow from this.
#[derive(PartialEq, Eq, Clone, Debug)]
diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs
index 02f9c7a7..098c5c64 100644
--- a/primitives/src/witness.rs
+++ b/primitives/src/witness.rs
@@ -31,12 +31,14 @@ use crate::prelude::{Box, Vec};
pub struct Witness {
/// Contains the witness `Vec<Vec<u8>>` serialization.
///
- /// Does not include the initial varint indicating the number of elements. Each element however,
- /// does include a varint indicating the element length. The number of elements is stored in
- /// `witness_elements`.
+ /// Does not include the initial length prefix indicating the number of elements. Each element
+ /// however, does include a [`CompactSize`] indicating the element length. The number of
+ /// elements is stored in `witness_elements`.
///
/// Concatenated onto the end of `content` is the index area. This is a `4 * witness_elements`
/// bytes area which stores the index of the start of each witness item.
+ ///
+ /// [`CompactSize`]: <https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer>
content: Vec<u8>,
/// The number of elements in the 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.